≡ Menu

HowTo: Linux Remove a Partition Name (/dev/sdXY entry) Temporarily

I‘d like to remove /dev/sdc5 temporarily without deleting partitions on hard drive /dev/sdc under Linux operating systems?

You can use old good rm command (make sure /dev/sdc5 is not mounted). Another option is to use the delpart command that asks the Linux kernel to remove a partition.

This command doesn’t manipulate with partitions on hard drive. The syntax is as follows:
delpart /dev/sdX Number
rm /dev/sdXY

rm command example

Type the following rm command as root:
# umount /dev/sdc5
# rm /dev/sdc5
# ls /dev/sdc*

delpart command example

Type the following as root:
# umount /dev/sdc5
# delpart /dev/sdc 5
# ls /dev/sdc*

How do I re-read (or add) temporarily deleted partition?

Use partprobe command. It will informs Linux operating system kernel of partition table changes, by requesting that the operating system re-read the partition table:
# partprobe /dev/sdX
# partprobe /dev/sdc

Share this tutorial on:

Like this? Follow us on Twitter OR support us by using Patreon

{ 9 comments… add one }
  • John August 28, 2012, 3:04 am

    I am really curious why someone would want to do this.

  • Sami August 28, 2012, 5:56 am

    Why would one do such a thing?

  • Marcello August 28, 2012, 6:56 am

    Can’t imagine a use case either…

  • punktyras August 28, 2012, 8:40 am

    And how to get deleted partition back?

  • nixCraft August 28, 2012, 9:54 am


    Use partprobe command.

    I am really curious why someone would want to do this.
    Why would one do such a thing?
    Can’t imagine a use case either…

    May be to avoid accidental mounting and deleting files. For example, boot embedded nas / router from /boot and run this command from /etc/rc.local. Now, apt-get or yum or ipkg will not able to update kernel and install at /boot.

    Say are writing a script that modifies /boot or other part of fs. In that case you can delete /dev/whatever and use some image file on /boot and test your config without committing anything to real /dev/whatever and be done with testing.

    Hope this helps!

  • mesuutt August 28, 2012, 11:20 am

    Good for hide a special partition from others :)

  • John August 28, 2012, 1:02 pm


    Wouldn’t you then use fstab to point /boot at another partition?

    I fear that the person who submitted the question is trying to get something done at their job, and will screw something up because they are approaching the solution wrong.

  • Jeremy September 12, 2012, 1:56 am

    This could be used to test an application or something for disk failures. Like removing the drive suddenly to see what an application would do. As you can see partprobe would be able to get back the drive so no harm is done.

  • Lynx September 27, 2012, 6:40 am

    you can do this when you don’t want airport customs to see your files

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , ,