Hide Your Disks Or Partitions From Nautilus

closeThis post was published 3 years 4 months 1 day ago which may make many or all of its content outdated. Please follow at your own risk.

Ever got tired of Nautilus showing all disks or partitions present on your system?

While it helps you access these devices quickly, sometimes it becomes an eye sore when there are too many disks with long funny names, and add to that your external disks, flash and CD/DVD drives – the list becomes confusingly long.

For several reasons you also don’t want your Windows partition’s drive C: or your other Linux distro’s root drive to show up too. If you’re like me where you have a common space for both operating system’s to store and retrieve files, then you don’t want your Nautilus to be unnecessarily cluttered with all those disks and/or partitions.

How do you hide disks from showing up in Nautilus?

First you must know what disks and/or partitions you want to hide. From what I’ve observed, Nautilus will either present these devices by label. If it does not have a label, then the device will be associated with the disk/partition size.

Look at the image below. The ones in the red box don’t have labels. File System is always the current /root partition, while the 45 GB File System is a partition that does not have a label. In this example, it is the /root partition of my Ubuntu 10.10 (I’m running on Natty Narwhal but have kept my Maverick Meerkat as a backup of sorts). The other two – Lucid Lynx and Karmic Koala -  are the labels of my 2 NTFS partitions.

The labels are important in case you are not familiar with how Linux refer to these devices. In Windows, whether it is a disk or a partition, they are called by letters – C or D – and so on. Linux has a more specific naming system. It is normally sdaX or hdbY, where X and Y are the numbers of the partitions on the sda or hdb drives, respectively. Thus, if there are 3 partitions on sda drive, then there will be sda1, sda2 and sda3. Windows will more likely just call it C, D, and E.

Now mount all of your drives and/or partitions. You know how to do that, don’t you? Click the name in Nautilus and it will mount it for you. I suggest you unmount and remove all removable drives to avoid confusion.

Once you’ve mounted all, open a terminal by running gnome-terminal. Just type that in dash if you’re using Natty, or find it in the menu if you’re using the classic Ubuntu desktop. The reason why mounting all is the easier way to find out the device names is because mount will literally tell you that device X is mounted at directory Y with the name Z. Easy right? You can look in /proc/partitions or /dev/disks/ but it will only confuse you.

Run the command mount once. From the output, take note of the names of the drive or partitions through its associated label. It will look something like the image below.

On the second image above, you will notice that there is no reference to the mounted 45 GB File System. That is because the latter does not have a label, as I’ve mentioned previously, and the uuid is too long and will look horrible on Nautilus. The underlying system will mount it by its uuid name on /media, while the rest are mounted by its label.

Since the 45 GB File System (/dev/sdb2) really has no business being displayed on Nautilus, I want to hide that. I also want to hide Karmic Koala (/dev/sda1) because it is my Windows C partition. Heaven forbid I delete files from any of these partitions by accident.

Now the hiding begins!

1) Create a file named 99-hide-disks.rules using your favorite editor. This file is where we put the rule to tell the Linux kernel to hide the device. I won’t explain why the file name sounds funny. That will be the subject for another post here if I won’t feel too lazy explaining it.

2) Put the text below in the file you just created, but make sure to change the device name that applies to your case. On mine I want to hide sda1 and sdb2.

The general format is (this is case sensitive):

KERNEL==”device name“, ENV{UDISKS_PRESENTATION_HIDE}=”1″

In my case, I will write the following in 99-hide-disks.rules:

KERNEL==”sda1″, ENV{UDISKS_PRESENTATION_HIDE}=”1″
KERNEL==”sdb2″, ENV{UDISKS_PRESENTATION_HIDE}=”1″

Don’t forget to save when you’re done.

3) Now copy the file to /etc/udev/rules.d/ with the command,

sudo cp 99-hide-disks.rules  /etc/udev/rules.d/

Now we’re done. This will have been noticed immediately by the system because udev (the device manage for Linux) looks for changes to the rules folder through inotify (this is a file system event notifier service). However it will not be applied until you reboot. Supposedly you can use the udevadm command to trigger the new rules, but I haven’t really tested it yet. Reboot your Ubuntu and notice how the partitions are no longer visible in Nautilus.

Note: I recommend you don’t hide File System or the current /root partition.

Note: You may want to read up on  UDISKS_IGNORE as one comment from below suggested. (Thanks to Ilia)

Warning: This post is more than a year old and done at the time when the Ubuntu version was still at 11.x. As such, the steps provided here may not work for the current releases, or versions above 11.x


Related Posts:

16 Responses to “Hide Your Disks Or Partitions From Nautilus”

  1. Thanks for the article!
    Does this just hide the partitions from Nautilus or does it completely stop them from being mounted?
    Will i still be able to access it once hidden?
    Thanks for any additional help :)

    • Supposedly you are still able to mount the drive “by hand”, assuming you know which device it is. You can easily access it using the `mount` command.

  2. udevadm trigger works under fedora 15

  3. oops I forgot to say Thank You. Thank you for this info.

  4. Ubuntu 12.04 – works perfectly, thanky you. Do you know maybe how to change names of the devices? I mean, in your example: instead of “Karmic Koala” to write “AAA”, instead of “Lucid Lynx” – “BBB”, any other than renaming whole partition?

    • There is a disk manager installed by default on Ubuntu. If you type “disk” on Dash, it will show up a list of apps and select the correct one. Once opened select the partition and I am almost sure you can rename it from there. I’m not on Ubuntu right now so I can’t check.

  5. thanks so much! i was searching all over the net for this!

  6. Thanks for the post, I love the site! I’m just wondering if there was a way to hide the partition for a particular group and have it available for admins / sudoers?

    • That I’m not so sure about. I suppose udev doesn’t really handle users and permissions. If you want to do something else that involves multiple users I think you should look into kiosk or kiosk-like apps for Linux.

  7. Oddly not working on my 12.04 install. Verified everything, but the partition is still showing in Nutilus.

  8. Is it possible to specify the device using its UUID?

  9. @Iain:

    Try adjusting permissions of the device itself, that does the job.

  10. Also not working for me in 12.04. I’ve been fiddling with the rule, udevadm, udisks. No joy.

    • The above article was written back in the 11.x days of Ubuntu. I’ll try to test it on my 12.04 and see if I can get things right. Then I’ll update this post on whatever I find.

  11. For latest Ubuntu and Fedora you must use UDISKS_IGNORE instead of UDISKS_PRESENTATION_HIDE

    Also remember to remove fancy ″ all over!

    Thanks for the post! Updated please!

You Comment, I Follow

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Tweets