Red Hat Bugzilla – Bug 1342337
Should remind a warning about disk image has a partition when using virt-p2v-make-disk
Last modified: 2016-11-03 14:00:53 EDT
Description of problem: Should remind a warning about disk image has a partition when using virt-p2v-make-disk Version-Release number of selected component (if applicable): virt-p2v-1.32.4-1.el7.iso How reproducible: 100% Steps to Reproduce: 1.Check usage info in virt-p2v-make-disk manual page, it said disk image shouldn't have a partation #man virt-p2v-make-disk EXAMPLES Write a virt-p2v bootable USB key on /dev/sdX (any existing content on /dev/sdX is erased): virt-p2v-make-disk -o /dev/sdX 2.Prepare a 16G usb key, format and make a partition for usb key 2.1 #mkfs -t ext4 /dev/sdc 2.2 #fdisk /dev/sdc 2.3 #fdisk -l Disk /dev/sdc: 16.0 GB, 16022241280 bytes, 31293440 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x5c970635 Device Boot Start End Blocks Id System /dev/sdc1 2048 31293439 15645696 83 Linux 3.Inject the private key to usb key with virt-p2v-make-disk and the building was finished without error about disk image has a partition # virt-p2v-make-disk -o /dev/sdc1 --inject-ssh-identity id_rsa [ 3.0] Downloading: http://libguestfs.org/download/builder/fedora-23.xz [ 4.4] Planning how to build this image [ 4.4] Uncompressing [ 16.7] Resizing (using virt-resize) to expand the disk to 14.9G [ 510.4] Opening the new disk [ 513.9] Setting a random seed [ 513.9] Updating packages [1136.0] Installing packages: pcre libxml2 gtk2 /usr/bin/ssh /usr/bin/qemu-nbd curl ethtool hwdata xterm /usr/bin/xinit /usr/bin/Xorg xorg-x11-drivers xorg-x11-fonts-Type1 mesa-dri-drivers metacity NetworkManager nm-connection-editor network-manager-applet dbus-x11 @hardware-support [1235.0] Uploading: /usr/share/virt-p2v/issue to /etc/issue [1235.1] Uploading: /usr/share/virt-p2v/issue to /etc/issue.net [1235.1] Making directory: /usr/libexec [1235.1] Uploading: /usr/libexec/virt-p2v to /usr/libexec [1235.1] Changing permissions of /usr/libexec/virt-p2v to 0755 [1235.1] Uploading: /usr/share/virt-p2v/launch-virt-p2v to /usr/bin/ [1235.1] Changing permissions of /usr/bin/launch-virt-p2v to 0755 [1235.1] Uploading: /usr/share/virt-p2v/p2v.service to /etc/systemd/system/ [1235.1] Making directory: /etc/systemd/system/default.target.wants [1235.1] Linking: /etc/systemd/system/default.target -> /usr/lib/systemd/system/multi-user.target [1235.1] Linking: /etc/systemd/system/default.target.wants/p2v.service -> /etc/systemd/system/p2v.service [1235.1] Editing: /usr/lib/systemd/system/getty@.service [1235.2] Editing: /etc/systemd/logind.conf [1235.2] Uploading: id_rsa to /var/tmp/id_rsa [1235.2] Editing: /etc/selinux/config [1235.2] Uploading: /tmp/tmp.8PdSnKAZiU/p2v.conf to /etc/dracut.conf.d/ [1235.2] Running: /tmp/tmp.8PdSnKAZiU/post-install [1308.0] Setting passwords [1342.7] Finishing off Output file: /dev/sdc1 Output size: 14.9G Output format: raw Total usable space: 14.3G Free space: 12.8G (89%) Actual results: As above description Expected results: Because building need a long time, it will save customer's time if the building could be failed with a warning or error "disk image shouldn't have a partiation " Additional info:
I posted a patch for this yesterday. The new output has a warning which reads: virt-builder: warning: output device (/dev/sdb1) is a partition. If you are writing to a USB key or external drive then you probably need to write to the whole device, not to a partition. If this warning is wrong then you can disable it with --no-warn-if-partition https://www.redhat.com/archives/libguestfs/2016-June/msg00002.html
I can reproduce this issue with build: # rpm -q virt-v2v virt-p2v virt-v2v-1.32.4-3.el7.x86_64 virt-p2v-1.32.4-3.el7.noarch Then try to verify with new build: virt-v2v-1.32.5-6.el7.x86_64 virt-p2v-1.32.5-6.el7.noarch Steps: 1. Prepare a USB device with 1 partition # fdisk -l /dev/sdb Disk /dev/sdb: 16.0 GB, 16022241280 bytes, 31293440 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x8f3f3a11 Device Boot Start End Blocks Id System /dev/sdb1 2048 31293439 15645696 83 Linux 2. Use virt-p2v-make-disk creates a bootable disk image or USB key containing virt-p2v to this USB device. # virt-p2v-make-disk -o /dev/sdb1 virt-builder: warning: output device (/dev/sdb1) is a partition. If you are writing to a USB key or external drive then you probably need to write to the whole device, not to a partition. If this warning is wrong then you can disable it with --no-warn-if-partition [ 2.6] Downloading: http://libguestfs.org/download/builder/fedora-24.xz [ 12.8] Planning how to build this image [ 12.8] Uncompressing [ 19.5] Resizing (using virt-resize) to expand the disk to 14.9G [ 508.2] Opening the new disk [ 510.8] Setting a random seed [ 510.8] Updating packages [ 721.2] Installing packages: pcre libxml2 gtk2 /usr/bin/ssh /usr/bin/qemu-nbd curl ethtool hwdata pciutils hdparm smartmontools util-linux xterm /usr/bin/xinit /usr/bin/Xorg xorg-x11-drivers xorg-x11-fonts-Type1 dejavu-sans-fonts dejavu-sans-mono-fonts mesa-dri-drivers metacity NetworkManager nm-connection-editor network-manager-applet dbus-x11 net-tools @hardware-support [1014.4] Uploading: /usr/share/virt-p2v/issue to /etc/issue [1014.4] Uploading: /usr/share/virt-p2v/issue to /etc/issue.net [1014.4] Making directory: /usr/libexec [1014.4] Uploading: /usr/libexec/virt-p2v to /usr/libexec [1014.4] Changing permissions of /usr/libexec/virt-p2v to 0755 [1014.4] Uploading: /usr/share/virt-p2v/launch-virt-p2v to /usr/bin/ [1014.4] Changing permissions of /usr/bin/launch-virt-p2v to 0755 [1014.4] Uploading: /usr/share/virt-p2v/p2v.service to /etc/systemd/system/ [1014.4] Making directory: /etc/systemd/system/default.target.wants [1014.4] Linking: /etc/systemd/system/default.target -> /usr/lib/systemd/system/multi-user.target [1014.5] Linking: /etc/systemd/system/default.target.wants/p2v.service -> /etc/systemd/system/p2v.service [1014.5] Editing: /usr/lib/systemd/system/getty@.service [1014.6] Editing: /etc/systemd/logind.conf [1014.6] Editing: /etc/selinux/config [1014.6] Uploading: /tmp/tmp.TCh3Ea6cfq/p2v.conf to /etc/dracut.conf.d/ [1014.6] Running: /tmp/tmp.TCh3Ea6cfq/post-install [1134.3] Setting passwords [1180.1] Finishing off Output file: /dev/sdb1 Output size: 14.9G Output format: raw Total usable space: 14.3G Free space: 12.9G (90%) Result: After step2, We can get a clear warning when output device is a partition: virt-builder: warning: output device (/dev/sdb1) is a partition. If you are writing to a USB key or external drive then you probably need to write to the whole device, not to a partition. If this warning is wrong then you can disable it with --no-warn-if-partition Then try with "--no-warn-if-partition" but failed. # virt-p2v-make-disk -o /dev/sdb1 --no-warn-if-partition virt-p2v-make-disk: unrecognized option '--no-warn-if-partition' virt-p2v-make-disk: problem parsing the command line arguments So rjones, please help me have a look about option '--no-warn-if-partition', how make it work, thanks.
Moving back to ASSIGNED. I will add --no-warn-if-partition to virt-p2v-make-disk too.
Added this option to virt-p2v-make-disk in this commit: https://github.com/libguestfs/libguestfs/commit/07137ea565653ca22e055cef09a08add6ad5f1c9
Verify bug with new build: virt-v2v-1.32.5-7.el7.x86_64 Steps: 1.Check --no-warn-if-partition info in virt-builder manual page # man virt-builder --no-warn-if-partition Do not emit a warning if the output device is a partition. This warning avoids a common user error when writing to a USB key or external drive, when you should normally write to the whole device (--output /dev/sdX), not to a partition on the device (--output /dev/sdX1). Use this option to suppress this warning. 2. Prepare a USB device with 1 partition # fdisk -l Device Boot Start End Blocks Id System /dev/sdb1 2048 31293439 15645696 83 Linux 3. Use virt-p2v-make-disk to build p2v to USB key without parameter "--no-warn-if-partition", there is a warning about partition and the building process will not show details info like before # virt-p2v-make-disk -o /dev/sdb1 virt-builder: warning: output device (/dev/sdb1) is a partition. If you are writing to a USB key or external drive then you probably need to write to the whole device, not to a partition. If this warning is wrong then you can disable it with --no-warn-if-partition [ 2.8] Downloading: http://libguestfs.org/download/builder/fedora-24.xz 3.4% 4. Use virt-p2v-make-disk to build p2v to USB key with parameter "--no-warn-if-partition", there is no a warning about partition # virt-p2v-make-disk -o /dev/sdb1 --no-warn-if-partition [ 3.1] Downloading: http://libguestfs.org/download/builder/fedora-24.xz 0.8% Result now: According to step4's result,arameter "--no-warn-if-partition" works well Hi rjones I have some query with fixing method of this bug, because using virt-p2v-make-disk to build p2v to USB key which has partition, the host can't boot into the usb key after building, the building has no any meaning, besides ,building need a long time, it will waste customer's time, why not failed this building directly using error "output device (/dev/sdb1) is a partition" ? Thanks
I sort of agree with you. The problem is that only virt-builder knows that the output is a partition, but we want to allow virt-builder (in the general case) to write to partitions as well as whole block devices. virt-p2v-make-disk doesn't "know" that the output is a partition, so it cannot do anything here. There's no good answer here, but at least there is a warning.
According to comment 9 and comment 10, the bug has been fixed, so move the bug from ON_QA to VERIFIED
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHSA-2016-2576.html