Description of problem: 1. create a LV on /dev/sda1, then re-partition /dev/sda1 without remove LV 2. reload disk and re-partition again, we can see LV still exists. 3. LV can't be removed Version-Release number of selected component (if applicable): libguestfs-1.22.6-22.el7.x86_64 How reproducible: 100% Steps to Reproduce: 1. create a disk. # dd if=/dev/zero of=/tmp/lvmtest.img bs=1M count=1024 2. create a lvm on /dev/sda1, then re-partition /dev/sda1 without remove lvm. (All commands in one line) # guestfish -a /tmp/lvmtest.img run : part-disk /dev/sda msdos : pvcreate /dev/sda1 : vgcreate vg /dev/sda1 : lvcreate lv vg 50 : lvs : part-disk /dev/sda msdos /dev/vg/lv libguestfs: error: part_disk: parted: /dev/sda: Error: Partition(s) 1 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. 3. reload disk , re-partition and do lvremove # guestfish -a /tmp/lvmtest.img run : part-disk /dev/sda msdos : lvs : lvremove /dev/vg/lv Actual results: libguestfs: error: lvremove: lvremove_stub: /dev/vg/lv: No such file or directory Expected results: lv can be removed. Additional info: Same operation on rhel7 guest, LV can be removed successfully # parted -s -- /dev/xvdb mklabel msdos mkpart primary 128s -128s # lvm pvcreate --force /dev/xvdb1 # lvm vgcreate vg /dev/xvdb1 # lvm lvcreate -L 50 -n lv vg # parted -s -- /dev/xvdb mklabel msdos mkpart primary 128s -128s After reboot, # parted -s -- /dev/xvdb mklabel msdos mkpart primary 128s -128s # lvremove /dev/vg/lv
I think LVM gets confused temporarily, but it doesn't seem to be "exploitable" in any way. ie. You cannot create a disk image which libguestfs cannot handle. Simpler procedure for displaying the error: $ guestfish -N lv -- -part-disk /dev/sda mbr $ guestfish -a test1.img run : part-disk /dev/sda mbr : lvs : lvremove /dev/VG/LV The second command prints: /dev/VG/LV libguestfs: error: lvremove: lvremove_stub: /dev/VG/LV: No such file or directory I guess we might consider doing a wipefs all operations that create a new partition table.
(In reply to Richard W.M. Jones from comment #1) > I guess we might consider doing a wipefs all operations that ^before^ > create a new partition table.
Bug still happens (even upstream).
Still happens (even upstream). However as this is low priority I'm moving it to RHEL 7.4.
We may as well handle this upstream. It's a very contrived test case which would not affect RHEL customers.