KVM LVM动态增加虚拟机磁盘最佳实践
1. 虚拟机安装时使用主机的LVM分区
1.1 主机创建lvm分区
# lvcreate -L 10G -n lv_vm_img vg
1.2 使用此分区创建虚拟机
# koan --server=localhost --port="11180" --virt --system="vm_img1" --virt-path="/dev/mapper/vg-lv_vm_img" --virt-type=kvm --qemu-disk-type=virtio --qemu-net-type=virtio
2. 为虚拟机增加新的磁盘空间
2.1 主机创建lvm分区
# lvcreate -L 40G -n lv_vm_img1 vg
2.2 添加此分区到虚拟机中
# virsh attach-disk --domain vm_img1 --source /dev/mapper/vg-lv_vm_img1 --target vdb --persistent
2.3 进入虚拟机扩展VG空间
# virsh console vm_img1
Connected to domain vm_img1
Escape character is ^]
CentOS release 6.3 (Final)
Kernel 2.6.32-279.2.1.el6.x86_64 on an x86_64
vm_img1 login: root
Password: ************
# pvcreate /dev/vdb
# vgextend vg_vm_img1 /dev/vdb
# vgs
2.4 为虚拟机的特定应用创建lv
# lvcreate -L 20G -n lv_www vg_vm_img1
# mkfs.ext4 /dev/mapper/vg_vm_img1-lv_www
# vi /etc/fstab
/dev/mapper/vg_vm_img1-lv_www /var/www ext4 defaults 1 2
# mount /var/www
# fixfiles restore /var/
相关推荐
ScienceExplorer 2020-06-14
星愿心愿 2020-11-24
ruancw 2020-11-10
VFCSDN 2020-10-14
somyjun 2020-09-29
longjing 2020-09-18
KINGJENSEN 2020-09-14
85251846 2020-09-14
周公周金桥 2020-09-06
lxttiger 2020-08-18
ARMOTO机器人 2020-08-18
atb 2020-08-17
SeetyST 2020-08-13
85206633 2020-08-15
yunna0 2020-08-15
young依然 2020-08-06
成长路上 2020-07-29
xiaogoua 2020-07-29