Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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)?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
Thanks for the clarification. And that's an interesting hack! Best left untouched on production machines though :) –  goncalopp Nov 11 '12 at 7:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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