kvm虚拟机挂载lvm卷

kvm虚拟机挂载lvm卷

virsh attach-disk kvm-3 /dev/vg_shkvm3/kvm-3-data vdb --driver qemu --mode shareable

登录到kvm-3

[root@sh-kvm-3-3 ~]# fdisk -l

Disk /dev/vda: 21.5 GB, 21474836480 bytes
16 heads, 63 sectors/track, 41610 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00002155

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           3        1018      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2            1018       41611    20458496   8e  Linux LVM
Partition 2 does not end on cylinder boundary.

Disk /dev/mapper/VolGroup-lv_root: 18.8 GB, 18798870528 bytes
255 heads, 63 sectors/track, 2285 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/VolGroup-lv_swap: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/vdb: 53.7 GB, 53687091200 bytes
16 heads, 63 sectors/track, 104025 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
[root@sh-kvm-3-3 ~]# fdisk /dev/vdb #分区 
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x93edb871.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-104025, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-104025, default 104025): 
Using default value 104025

Command (m for help): p

Disk /dev/vdb: 53.7 GB, 53687091200 bytes
16 heads, 63 sectors/track, 104025 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x93edb871

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1               1      104025    52428568+  83  Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
  • 挂载lvm 到data目录
mkfs.ext4 /dev/vdb1
pvcreate /dev/vdb1
vgextend VolGroup /dev/vdb1
lvcreate -n data -L 30G VolGroup
mkdir /data
mkfs.ext4 /dev/VolGroup/data
mount /dev/VolGroup/data  /data/
echo "/dev/mapper/VolGroup-data    /data                   ext4    defaults        1 1"  >> /etc/fstab
  • 扩容根目录
# lvextend -l +100%FREE /dev/mapper/VolGroup-lv_root
# resize2fs /dev/mapper/VolGroup-lv_root
# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      103G   40G   58G  41% /
tmpfs                 4.9G   12K  4.9G   1% /dev/shm
/dev/xvda1            477M  153M  299M  34% /boot

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏数据库新发现

Emulex光纤卡lpfc配置文件的修改

# cd /kernel/drv # vi sd.conf "sd.conf" 65 lines, 1611 characters # # Copyright...

1222
来自专栏草根专栏

用VSCode开发一个asp.net core2.0+angular5项目(5): Angular5+asp.net core 2.0 web api文件上传

这部分就讲从angular5的客户端上传图片到asp.net core 2.0的 web api. 这是需要的源码: https://pan.baidu.com...

3585
来自专栏运维

在线收缩和扩展LVM

在安装系统时LVM的大小没有设定好,还好可以在线收缩和扩展。 1,看下各逻辑卷大小 [root@bogon ~]# df -h Filesystem   ...

452
来自专栏张善友的专栏

How to build Multi-Language Web Sites with ASP.NET 2.0 and VS.Net 2005

Introduction: In order to reach international markets through the Internet, sup...

2058
来自专栏北京马哥教育

centos7上的xfs配置

XFS是扩展性高、高性能的文件系统。也是rhel7/centos7的默认文件系统。 XFS支持metadata journaling,这使其能从crash中更快...

2773
来自专栏c#开发者

XmlSerializerFactory Is Pretty Cool[转]

The XmlSerializerFactory is a new class in .NET 2.0 that provides a factory patt...

2814
来自专栏Android知识点总结

5--安卓网络编程之OKHttp3的使用

723
来自专栏数据和云

日常答疑:关于 standby logfile 的 thread 参数分析

作者|卢立广:云和恩墨交付工程师,有多年数据库运维工作经验,擅长数据库性能优化和数据迁移等,长期服务于政府、能源、通信等行业客户。

924
来自专栏岑玉海

Distribute Cached 使用

  在Kettle中说到Pentaho的MapReduce要用到它,就查了一下关于它的资料,以下是从官方查到的内容,记录一下。   DistributedCac...

2414
来自专栏ASP.NET MVC5 后台权限管理系统

ASP.NET MVC5+EF6+EasyUI 后台管理系统(7)-MVC与EasyUI DataGrid

本节知识点 为了符合后面更新后的重构系统,文章于2016-11-1日重写 EasyUI读取MVC后台Json数据 开始实现 我们的系统似乎越来越有趣了 首先...

3026

扫码关注云+社区