3

On linux, if one deletes a (MSDOS) extended partition and there are extended partitions in use with higher numbers than the deleted one, the kernel fails to rescan the partitions with partprobe. This happens, I presume because the partitions following the removed one will have their number reduced by 1

Is there any way around this (without unmounting the other partitions)?

1 Answer 1

1

Unfortunately the Linux kernel is not even that smart. Even if you remove the very last partition Linux won't reload partition table if there is any, even totally unaffected, partition in use on this device. There is no way to reload partition table if any partitions there are in use. Which usually means reboot if it is the disk holding the root file system.


And here is an ugly (and DANGEROUS!) hack that can help sometimes…

I am not sure if it helps you, but I have recently found a workaround allowing me to access freshly created/modified partition even if Linux refused to reload the partition table:

# losetup --find --partscan --show /dev/sda
/dev/loop0
losetup: /dev/sda: warning: file smaller than 512 bytes, the loop device maybe be useless or invisible for system tools.

(the warning may be ignored)

This will made all the partition currently defined on /dev/sda as: /dev/loop0p1, /dev/loop0p2, etc. BE CAREFUL! It is very easy to destroy your data this way, as Linux won't even notice if you try to do anything (mount, create file system, etc.) with a partition which is in use.

1
  • Thanks for the clarification. And that's an interesting hack! Best left untouched on production machines though :) Nov 11, 2012 at 7:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .