View Issue Details

IDProjectCategoryView StatusLast Update
0008317CentOS-7libvirtpublic2015-03-19 02:20
Reportertbblake 
PrioritynormalSeveritymajorReproducibilityalways
Status newResolutionopen 
Platformx86_64OSCentOS 7 CoreOS Version7
Product Version7.0-1406 
Target VersionFixed in Version 
Summary0008317: virt-clone creating a truncated disk?
DescriptionMy hypervisor is CentOS 7, and I'm trying to learn KVM. As part of it, I'm trying build my own little cloud setup, where I can spin up VMs adhoc. I've been looking at virt-clone to create clones of an existing CentOS 6 VM I've already created, but am running into a roadblock. As near as I can tell, whenever I use virt-clone, it copies my disk, but truncates it.

I'm using this command to clone the vm named centos6, which is powered off at the moment:

[root@topo ~]# virt-clone --original centos6 --name centos6_2 --file /var/lib/libvirt/images/centos6_2-disk1.raw
WARNING Setting the graphics device port to autoport, in order to avoid conflicting.
Cloning centos6-disk1.raw

After the fact, qemu-img thinks they images are essentially the same in their contents, but also lists them at different virtual sizes:

[root@topo ~]# qemu-img info /var/lib/libvirt/images/centos6-disk1.raw
image: /var/lib/libvirt/images/centos6-disk1.raw
file format: raw
virtual size: 20G (21474836480 bytes)
disk size: 20G
[root@topo ~]# qemu-img info /var/lib/libvirt/images/centos6_2-disk1.raw
image: /var/lib/libvirt/images/centos6_2-disk1.raw
file format: raw
virtual size: 18G (19400757248 bytes)
disk size: 1.5G
[root@topo ~]# ls -lh /var/lib/libvirt/images/centos6-disk1.raw /var/lib/libvirt/images/centos6_2-disk1.raw
-rwxr-xr-x 1 root root 19G Mar 14 15:37 /var/lib/libvirt/images/centos6_2-disk1.raw
-rwxr-xr-x 1 qemu qemu 20G Mar 13 15:32 /var/lib/libvirt/images/centos6-disk1.raw
[root@topo ~]# du -sh /var/lib/libvirt/images/centos6-disk1.raw /var/lib/libvirt/images/centos6_2-disk1.raw
21G /var/lib/libvirt/images/centos6-disk1.raw
1.6G /var/lib/libvirt/images/centos6_2-disk1.raw
[root@topo ~]# qemu-img compare /var/lib/libvirt/images/centos6-disk1.raw /var/lib/libvirt/images/centos6_2-disk1.raw
Warning: Image size mismatch!
Images are identical.
[root@topo ~]#


But when booting, I don't believe they are. I get this on boot from the cloned VM, talking about not being able to resume the swap LV, and complaints of the size of sda2(the LVM PV), which leads me to believe the cloned disk has had the last bit of it lopped off:

dracut: Scanning devices sda2 for LVM logical volumes vg_centos6/lv_swap vg_centos6/lv_root
dracut: inactive '/dev/vg_centos6/lv_root' [17.54 GiB] inherit
dracut: inactive '/dev/vg_centos6/lv_swap' [1.97 GiB] inherit
device-mapper: table: 253:1: sda2 too small for target: start=36784128, len=4128768, dev_size=36866056
dracut: device-mapper: resume ioctl on failed: Invalid argument
dracut: Unable to resume vg_centos6-lv_swap (253:1)
dracut: Scanning devices sda2 for LVM logical volumes vg_centos6/lv_swap vg_centos6/lv_root
dracut: ACTIVE '/dev/vg_centos6/lv_root' [17.54 GiB] inherit
dracut: ACTIVE '/dev/vg_centos6/lv_swap' [1.97 GiB] inherit
dracut: PARTIAL MODE. Incomplete logical volumes will be processed.
device-mapper: table: 253:1: sda2 too small for target: start=36784128, len=4128768, dev_size=36866056
dracut: device-mapper: resume ioctl on failed: Invalid argument
dracut: Unable to resume vg_centos6-lv_swap (253:1)
dracut Warning: No root device "block:/dev/mapper/vg_centos6-lv_root" found
dracut Warning: LVM vg_centos6/lv_swap not found
dracut Warning: Boot has failed. To debug this issue add "rdshell" to the kernel command line.
dracut Warning: Signal caught!
dracut Warning: LVM vg_centos6/lv_swap not found
dracut Warning: Boot has failed. To debug this issue add "rdshell" to the kernel command line.
Kernel panic - not syncing: Attempted to kill init!
Pid: 1, comm: init Not tainted 2.6.32-504.8.1.el6.x86_64 #1
Call Trace:
[<ffffffff815292d6>] ? panic+0xa7/0x16f
[<ffffffff8107a5f2>] ? do_exit+0x862/0x870
[<ffffffff8118fa25>] ? fput+0x25/0x30
[<ffffffff8107a658>] ? do_group_exit+0x58/0xd0
[<ffffffff8107a6e7>] ? sys_exit_group+0x17/0x20
[<ffffffff8100b072>] ? system_call_fastpath+0x16/0x1b

The part about **Unable to resume vg_centos6-lv-swap** is of course telling me "hey, I can't see all the right volumes", and the part about **sda2 too small for target** is complaining about disk length I believe.

My fix has been (pastebin link - http://pastebin.com/NeZS3cDs):

* Boot the cloned VM via virt-rescue
* Remove the swap logical volume that's at the end
* Shrink the root filesystem to as small as possible
* Shrink the root logical volume to a few gigs bigger than the root fs
* Expand the root fs to fill the extra few gigs.
* Re-create the swap logical volume.

And then it'll boot without issue. Obviously something's wrong here, and I can't for the life of me figure out if it's me, or a bug. Debug mode on virt-clone doesn't seem to shed much more light on anything than it already logs in ~/.virtinst/virt-clone.log (pastebin link - http://pastebin.com/CJd75D1w).

(As an aside, I need to convert those raw disks to qcow2, or at least from what I gather that's a better idea than raw).


EDIT: Booted both VMs (altered NIC and hostnames only), checked out fdisk -l on /dev/sda, and different sizes there too...but the same partition sizes.

Original VM:

[root@centos6 ~]# fdisk -l /dev/sd?

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x0008f678

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2611 20458496 8e Linux LVM
[root@centos6 ~]#

Cloned VM:

[root@centos6_2 ~]# fdisk -l /dev/sd?

Disk /dev/sda: 19.4 GB, 19400757248 bytes
255 heads, 63 sectors/track, 2358 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: 0x0008f678

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2611 20458496 8e Linux LVM
[root@centos6_2 ~]#
Steps To ReproduceCreate VM under qemu/kvm using virt-install and the --cdrom option, complete install via VNC, using raw disk images
clone vm using the virt-clone command
TagsNo tags attached.
abrt_hash
URL

Activities

tbblake

tbblake

2015-03-19 02:20

reporter   ~0022541

For fun, I converted the raw image to a qcow2 image on the main VM, and used virsh edit to update the XML to point to the new image. I ran virt-clone against it with this config, and it worked flawlessly.

Issue History

Date Modified Username Field Change
2015-03-19 02:18 tbblake New Issue
2015-03-19 02:20 tbblake Note Added: 0022541