0

I wiped (erased from device) all partitions from a logical volume (lv in LVM). Then I did partprobe -s (and other similar commands: partprobe returned no output, partx said partition: none & failed to read partition table). The problem I had is that I could neither do:

  • mkfs /dev/vg/lv because /dev/vg/lv is apparently in use by the system; will not make a filesystem here!
  • lvremove /dev/vg/lv the device because Logical volume vg/lv is used by another device.

This is because the kernel still sees a partition within the lv block device:

# grep dm /proc/partitions
 254        0   85852160 dm-0
 254        1   84850688 dm-1

and

# ls -lh /dev/dm-*                           
brw-rw---T 1 root disk 254, 0 May 23 14:32 /dev/dm-0                                                       
brw-rw---T 1 root disk 254, 1 May 23 14:08 /dev/dm-1

I finally rebooted the machine, which resolved my problem (kernel did not see non-existent partition anymore).

Do you know a way to solve this without having to reboot?

Tested on a 3.2 kernel.

0

LVM devices (or Device Mapper in general) do not support partitions in the same sense as e.g. the sd devices do. With partx, you can only manage the normal type of partitions. On top of LVM devices, partitions must be managed with kpartx:

kpartx -d /dev/vg/lv

The kpartx manpage is a bit terse. To check this, I found a usage example which looks consistent with my assumptions: https://bugzilla.redhat.com/show_bug.cgi?id=187781

1
  • Next time I run into this problem, I'll try this. It may take several years though. ;)
    – Totor
    Jun 4 '18 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.