在线调整kvm客户根文件系统的大小?

我有一个直接使用LVM卷作为根文件系统的Linux来宾(即没有分区表)。 libvirtconfiguration看起来如此:

<os> <type arch='x86_64' machine='rhel6.4.0'>hvm</type> <kernel>/boot/vmlinuz-XYZel6.x86_64</kernel> <initrd>/boot/initramfs-XYZel6.x86_64.img</initrd> <cmdline>console=ttyS0 root=/dev/vda</cmdline> <boot dev='hd'/> </os> <disk type='block' device='disk'> <driver name='qemu' type='raw' cache='none' io='native'/> <source dev='/dev/vg/guest'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </disk> 

从客人的内部:

 $ mount /dev/vda on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) 

是否可以在不重新启动guest虚拟机的情况下调整guest虚拟机的根分区? 只是在主机上进行lvextend,而从客户机上调用resize2fs似乎还不够。

是的,你需要使用virsh blockresize来通知客人的变化。

语法应该是这样的:

 virsh blockresize INSTANCE_NAME --path /dev/vg/guest --size NEWSIZEG