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.

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements None
Est. reading time N/A
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

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 9 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
9 comments… add one
  • John Aug 28, 2012 @ 3:04

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

  • Sami Aug 28, 2012 @ 5:56

    Why would one do such a thing?

  • Marcello Aug 28, 2012 @ 6:56

    Can’t imagine a use case either…

  • punktyras Aug 28, 2012 @ 8:40

    And how to get deleted partition back?

  • 🐧 nixCraft Aug 28, 2012 @ 9:54


    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 Aug 28, 2012 @ 11:20

    Good for hide a special partition from others :)

  • John Aug 28, 2012 @ 13:02


    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 Sep 12, 2012 @ 1:56

    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 Sep 27, 2012 @ 6:40

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

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum