virt-resize로 크기를 조정한 후 KVM .img를 부팅할 수 없습니다

virt-resize로 크기를 조정한 후 KVM .img를 부팅할 수 없습니다

Ubuntu 12.04 amd64 호스트에 KVM을 통해 CentOS 6.4 이미지를 설치했습니다. centos.img의 디스크 레이아웃은 다음과 같습니다.

# virt-filesystems --long -h --all -a centos.img 
Name                   Type       VFS  Label MBR Size Parent
/dev/sda1              filesystem ext4 -     -   500M -
**/dev/vg_centos/lv_root filesystem ext4 -     -   2.5G -**
/dev/vg_centos/lv_swap filesystem swap -     -   2.0G -
/dev/vg_centos/lv_root lv         -    -     -   2.5G /dev/vg_centos
/dev/vg_centos/lv_swap lv         -    -     -   2.0G /dev/vg_centos
/dev/vg_centos         vg         -    -     -   4.5G -
/dev/sda2              pv         -    -     -   4.5G -
/dev/sda1              partition  -    -     83  500M /dev/sda
/dev/sda2              partition  -    -     8e  4.5G /dev/sda
/dev/sda               device     -    -     -   5.0G -

/root에 공간을 더 추가하고 싶어서 virt-resize를 사용해 보았습니다. 20G img를 생성한 다음 다음을 수행하여/root를 크기 조정합니다.

# truncate -s 20G centos-new.img 
# virt-resize centos.img centos-new.img --expand /dev/sda2 --LV-expand /dev/vg_centos/lv_root 

출력은 괜찮은 것 같습니다

**********
Setting up initial partition table on centos-new.img ...
Copying /dev/sda1 ...
 100% ⟦▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓⟧ 00:00
Copying /dev/sda2 ...
 100% ⟦▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓⟧ 00:00
Expanding /dev/sda2 using the 'pvresize' method ...
Expanding /dev/vg_centos/lv_root using the 'resize2fs' method ...

새 VM의 레이아웃을 확인했는데 괜찮습니다.

# virt-filesystems --long -h --all -a centos-new.img 
Name                   Type       VFS  Label MBR Size Parent
/dev/sda1              filesystem ext4 -     -   500M -
**/dev/vg_centos/lv_root filesystem ext4 -     -   18G  -**
/dev/vg_centos/lv_swap filesystem swap -     -   2.0G -
/dev/vg_centos/lv_root lv         -    -     -   18G  /dev/vg_centos
/dev/vg_centos/lv_swap lv         -    -     -   2.0G /dev/vg_centos
/dev/vg_centos         vg         -    -     -   20G  -
/dev/sda2              pv         -    -     -   20G  -
/dev/sda1              partition  -    -     83  500M /dev/sda
/dev/sda2              partition  -    -     8e  20G  /dev/sda
/dev/sda               device     -    -     -   20G  -

크기 조정 작업이 오류 없이 완료되었습니다. 기존 디스크를 삭제하기 전에 크기가 조정된 디스크가 올바르게 부팅되고 작동하는지 주의 깊게 확인하세요.

그런 다음 virsh를 사용하여 KVM에 새 vm을 정의합니다. /var/libvirt/qemu에 있는 현재 centos.img의 구성 파일을 복사하고 이를 편집한 다음 vm을 정의합니다. 모든 것이 정상이지만 centos-new를 시작할 수 없습니다. 로그는 다음과 같습니다.

# virsh start centos-new
error: Failed to start domain centos-new
error: internal error process exited while connecting to monitor: char device redirected to /dev/pts/13
kvm: -drive file=/home/tungns/VirtualBox VMs/centos-new.img,if=none,id=drive-ide0-0-0,format=qcow2: could not open disk image /home/tungns/VirtualBox VMs/centos-new.img: Invalid argument

다음은 마지막 부분입니다./var/log/libvirt/libvirtd.log:

2013-06-07 10:59:33.391+0000: 5553: error : qemuMonitorOpenUnix:295 : failed to connect to monitor socket: No such process
2013-06-07 10:59:33.392+0000: 5553: error : qemuProcessWaitForMonitor:1301 : internal error process exited while connecting to monitor: char device redirected to /dev/pts/13
kvm: -drive file=/home/tungns/VirtualBox VMs/centos-new.img,if=none,id=drive-ide0-0-0,format=qcow2: could not open disk image /home/tungns/VirtualBox VMs/centos-new.img: Invalid argument

그리고로부터/var/log/libvirt/qemu/centos-new.log:

2013-06-07 10:59:32.712+0000: starting up
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin QEMU_AUDIO_DRV=none /usr/bin/kvm -S -M pc-1.0 -enable-kvm -m 1024 -smp 1,sockets=1,cores=1,threads=1 -name centos-new -uuid 1acf632e-cea2-4754-8f36-30799fecc3d0 -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/centos-new.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -drive file=/home/tungns/VirtualBox VMs/centos-new.img,if=none,id=drive-ide0-0-0,format=qcow2 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 -drive if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,fd=18,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=00:16:3e:76:04:23,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -usb -vnc 0.0.0.0:0 -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
char device redirected to /dev/pts/13
kvm: -drive file=/home/tungns/VirtualBox VMs/centos-new.img,if=none,id=drive-ide0-0-0,format=qcow2: could not open disk image /home/tungns/VirtualBox VMs/centos-new.img: Invalid argument
2013-06-07 10:59:33.392+0000: shutting down

두 개의 VM이 동일한 권한 + 소유자로 동일한 폴더에 있습니다. centos.img는 정상적으로 부팅됩니다.

 784460 -rw-r--r--  1 root   root     803405824 Jun  7 16:20 centos.img
5468088 -rw-r--r--  1 root   root   21474836480 Jun  7 17:17 centos-new.img

나는 다음과 같은 가이드를 많이 읽었습니다.http://n40lab.wordpress.com/2013/05/29/resizing-a-qemu-kvm-linux-image-using-virt-resize-in-centos-6-4/지침은 동일합니다.

제안하는 것이 있나요? 다들 감사 해요.

답변1

qemu-create의 truncate 명령을 변경하여 이 문제를 해결했습니다. 예를 들어 대신

# truncate -s 20G centos-new.img 

사용:

# qemu-img create -f qcow2 centos-new.img 20G

해당 변경이 없으면 소스 디스크는 qcow2였지만 새 디스크는 원시 디스크였습니다. 이 혼란스러운 qemu.

관련 정보