42

I need to hide an NTFS partition from listing in the nautilus. How can I achieve that?

Is there any tool to do that?

And how can I hide files in ubuntu (except . operator)

3
  • Is this NTFS partition on an internal drive or an external. If it is internal then just don't mount it via fstab or otherwise. If it is external then it gets more complicated with udev rules.
    – Huckle
    Apr 22, 2012 at 2:02
  • mount it to another place apart from /media, such as /mnt
    – Tachyons
    Apr 22, 2012 at 5:22
  • I use Cinnamon desktop on Ubuntu Groovy. I would like to hide some mounted volumes (RAID parts) in Nemo. Is there any command to do this in terminal or system preference settings ? The settings in "Disks" do not seem to apply to Nemo. For Gnome i found these commands usefull and secure: # Set icon views in Gnome Remove user’s home desktop icon: gsettings set org.gnome.shell.extensions.desktop-icons show-home false Remove desktop trash icon: gsettings set org.gnome.shell.extensions.desktop-icons show-trash false Remove desktop mounted device icon: gsettings set org.gnome.shell.extensions.deskto
    – user849355
    Feb 10, 2021 at 11:29

13 Answers 13

38

Hiding partitions from Nautilus via »Disks«

In Ubuntu 12.10 and onward, there is a utility called Disks which shows all the available disks and allows to modify mount options for each partition.

Amongst the various options, you can decide if the partition will be mounted at boot time or not, and if it will appear in the user interface. Admin privileges are needed to apply changes.

Gnome Disks screenshot

7
  • My nfs parition don't appear in disk utility, how to see it ?
    – Nymeria
    Jul 30, 2014 at 14:00
  • Note the small two-gear-wheels symbol below the partitions - there the options to auto-mount and to show in GUI can be changed.
    – BurninLeo
    Mar 25, 2015 at 8:32
  • Hidden, yes, but user mountable. Clicking on Disk "Play" icon mounts the disk, whatever the options.
    – KrisWebDev
    Jul 16, 2016 at 18:19
  • Same tool can be found in Ubuntu MATE 16.04 (with Caja), and helps with hiding partitions you don't want to have cluttering the disk-lists on desktop GUI. I have a setup with multiple partitions, and had 4 partitions showing up here and there (Places-menu, Disk Mounter-widget, etc.) without any real use or purpose. Not anymore.
    – F-3000
    Aug 25, 2017 at 12:22
  • I still see the drive when open Home + Other locations under This computer which is called Volume. When I click on it, the window pops up asking me credentials to mount the drive. Is is possible to make it NOT show up in the other locations?
    – Nazar
    Dec 29, 2017 at 13:25
20

This guide may help you.

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.

enter image description here

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.

enter image description here

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! But before that, make sure you know which partitions you want to hide (like how I identified them above). You can also list all of your partitions using the command sudo fdisk -l to identify them faster. I'm going to be hiding sda1 and sdb2 in the next steps, but you should substitute your partition names instead.

  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.

Edit:

At least for Ubuntu 12.10, the lines above don't work anymore, and should be changed to use this format instead:

KERNEL=="sda1", ENV{UDISKS_IGNORE}="1"
KERNEL=="sdb2", ENV{UDISKS_IGNORE}="1"
8
  • 1
    I am sorry, Nautilus Still displays those drive names :(
    – Sreevisakh
    Apr 22, 2012 at 12:19
  • 1
    @Sreevisakh: The quotes were invalid. (eg KERNEL==”sda1″... they have now been changed in the answer). It works with normal ASCII quotes.
    – Peter.O
    Mar 8, 2013 at 17:41
  • 1
    Also. sudo udevadm trigger will update the devices. There is no need to restart nautilus
    – Peter.O
    Mar 8, 2013 at 19:08
  • So basically the second (untested) "fb" solution just uses fdisk to find device's identifier instead of first mounting it, running mount and unmounting again. => much faster :)
    – nuala
    Apr 3, 2013 at 19:42
  • Great, I had to use UDISKS_IGNORE (I'm on Xubuntu 13.10), and I found it only here!
    – lorenzo-s
    Nov 10, 2013 at 16:21
9

Thanks for this, very handy tutorial. I actually found a much easier way to do this in Ubuntu 14.04

  1. Hit the super/windows key
  2. Type and open disks
  3. Select the partition you want to hide so it becomes orange
  4. select the cog/settings/advanced settings icon. Click Edit Mount Options
  5. Turn auto mount off
  6. Uncheck both Mount at Startup and Show in user interface
  7. Save & Reboot

No terminal required, maybe this is a new feature for 14.04 ? Not sure either way this was much easier and effective.

I rebooted again to double check windows system after this task was complete and dual boot worked perfectly. This is an awesome way if you don't have time to stuff about in case something goes wrong OR if you are still learning the fine art of terminal commands :P

Hope this helps.

Cheers

9

Tachyons presents a great answer that shows how to hide a partition to udisks applications (such as Dolphin). Relying on a fixed partition name is error-prone though, it's better to use UUID that are unique to a partition. This answer was tested with Kubuntu 13.10.

To do so, one first has to find a UUID. That can be found in multiple ways, one of them is by running the command udisksctl info -b /dev/sda1 (where /dev/sda1 is your partition of course). The UUID is visible under IdUUID and the partition is not marked as hidden (ignored):

/org/freedesktop/UDisks2/block_devices/sda1:
  org.freedesktop.UDisks2.Block:
    Configuration:              []
    CryptoBackingDevice:        '/'
    Device:                     /dev/sda1
    DeviceNumber:               2049
    Drive:                      '/org/freedesktop/UDisks2/drives/...'
    HintAuto:                   false
    HintIconName:
    HintIgnore:                 false
    HintName:
    HintPartitionable:          true
    HintSymbolicIconName:
    HintSystem:                 true
    Id:                         by-id-ata-...-part1
    IdLabel:                    SystemReserved
    IdType:                     ntfs
    IdUUID:                     A10CDE7682786D73
    IdUsage:                    filesystem
    IdVersion:
    MDRaid:                     '/'
    MDRaidMember:               '/'
    PreferredDevice:            /dev/sda1
    ReadOnly:                   false
    Size:                       104857600
    Symlinks:                   /dev/disk/by-id/ata-...-part1
                                /dev/disk/by-id/wwn-...-part1
                                /dev/disk/by-label/SystemReserved
                                /dev/disk/by-uuid/A10CDE7682786D73

Now, in order to hide this partition, create a udev rule that matches the partition by this UUID and hide it from udisks. For instance, if you want to hide the above NTFS partition (with UUID A10CDE7682786D73), and another ext4 partition (with UUID faae2c6a-0545-4bfa-a545-440c63467467), your /etc/udev/rules.d/99-hide-partitions.rules file should contain:

# hide "SystemReserved" partition in UI
SUBSYSTEM=="block", ENV{ID_FS_UUID}=="A10CDE7682786D73", ENV{UDISKS_IGNORE}="1"
# hide /home partition in left panel
SUBSYSTEM=="block", ENV{ID_FS_UUID}=="faae2c6a-0545-4bfa-a545-440c63467467", ENV{UDISKS_IGNORE}="1"

The comments are optional, but recommended so that the UUID becomes less magic. Be sure not to mix up = with ==, one sets the variable, the other compares against a variable.

After creating the rules file, apply it by rebooting or by running:

sudo udevadm control --reload
sudo udevadm trigger --subsystem-match=block

Now run the udisksctl info -b /dev/sda1 command again and it should contain:

    HintIgnore:                 true
2
  • This is the right answer and still valid in ubuntu 14.04
    – ceztko
    Sep 27, 2014 at 16:32
  • On Ubuntu 20.04, having HintIgnore: true my EFI boot partition still shows up in the tray and has a mount point /media/{username}/EFI. I have HintAuto: true - don't know if that is the issue nor how to set it to false.
    – Anthony
    Jul 27, 2021 at 23:19
3

The answer should now be updated. You can follow this guide, but with a difference: you don't have to write this (as was originally written in the other answer)

KERNEL=="sda1", ENV{UDISKS_PRESENTATION_HIDE}="1"
KERNEL=="sdb2", ENV{UDISKS_PRESENTATION_HIDE}="1"

Instead, you should write this:

KERNEL=="sda1", ENV{UDISKS_IGNORE}="1"
KERNEL=="sdb2", ENV{UDISKS_IGNORE}="1"

The rest is the same :)

2

You can't really hide partitions so that they absolutely 100% can't be mounted in Linux, short of physically removing the disks on which they reside. That said, I don't think you need that level of safety. I suspect you just don't want to accidentally click an icon and get into the NTFS partition. To do that, you can edit the /etc/fstab file. Add an entry like this for each partition you want hidden:

Suppose your ntfs partition is dev/sda1 Then use this code

/dev/sda1  /mnt/hidden  ntfs-3g  noauto,ro  0 0

This configures the system to keep /dev/sda1 from being mounted automatically at boot time (the "noauto" part of the entry). It also sets it up so that it can be mounted manually at /mnt/hidden, but only as a read-only partition (the "ro" option). If you add the "users" option (as in "noauto,ro,users"), ordinary users (that is, you) will be able to mount the partition; but with this option missing, you'll need to use sudo to mount the partition. It's your choice how far you want to go with this -- you could leave out the "ro" and/or add "users", for instance.

.

And how can i hide files in ubuntu (except . operator)?

See this Answer

.

Source

  1. http://ubuntuforums.org/showthread.php?p=9901316
1
  • This will help in stop mounting a partition I want to hide it from the fav list on left side of nautlius any way?
    – Sreevisakh
    Apr 22, 2012 at 4:40
1

In Dolphin, which is not Nautilus but similar application for Kubuntu, I can just right click on the device in the left pane. Then a menu pops up an I can choose Hide entry 'humpty dumpty'. You might want to check if there is a similar option in Nautilus.

1

In my version, 14.04.2, I have a slightly different menu in the Disks option to hide partitions.

1 Open Disks

2 Left click the drive with partitions you want to hide (it turns orange)

3 Left click the partition you want to hide (it turns orange)

4 Click the double-cog in the bar below the partitions

5 Click "Edit Mount Options"

6 Turn Automatic Mount Options Off

7 Uncheck "Mount at startup"

8 Uncheck "Show in user interface"

9 Click "OK"

10 Enter password

This took immediate effect in my computer.

1

Get your disk UUID:

blkid

Edit /etc/fstab as root:

UUID="XXX" /media/root/nowhere auto nosuid,nodev,nofail,noauto,nouser,x-gvfs-hide,x-udisks-auth 0 0

Create a protected /media/root folder (to prevent users to access the partition if mounted):

sudo mkdir -m=000 /media/root

Several independant layers of protection against mounting and visibility:

  • noauto prevents automatic mounting at startup
  • nouser requires being root to mount (NB: already the default behavior, and udisk is root)
  • x-gvfs-hide explicitely tells Nautilus to hide it
  • x-udisks-auth should require admin rights when mounting but it has no effect. I guess it needs additional configuration.

Documentation: mount, fstab, gvfs.

Note that the block device (eg. /dev/sdX) is still visible by all users, especially in the Disk utility. It can still be manually mounted elsewhere by root, but not by a standard user by default. If you don't trust root or the system processes, you need to use one of the lower-level kernel approaches.

To go further: After that, if you want to mount the block device invisibly, in a container-like approach, you can use unshare:

unshare -m bash
MOUNT_DIR="XXX"
mkdir "$MOUNT_DIR"
mount --bind "$MOUNT_DIR" "$MOUNT_DIR"
mount --make-private "$MOUNT_DIR"
mount "/dev/sdX" "$MOUNT_DIR"
ls "$MOUNT_DIR"

BEWARE: Most/all answers, including the udev rule answers, just hide the partition from Nautilus but users can still mount it with standard permissions, through the Disk utility ( icon). Putting the fstab mount point in an unaccessible directory will prevent user access.

1
  • This answer also shows how to do it manually, as this Disks application mentioned in other answers edits fstab. Most meaningful options with a fstab entry are adding of noauto (disabling of automount at startup) and removal of x-gvfs-show (removing icons from desktop GUI). These are the only differences that Disks did when I used it. (Ubuntu MATE 16.04)
    – F-3000
    Aug 25, 2017 at 12:18
0

This will be the easiest way to hide the "Weak" Windows Partitions from the "Robust" Ubuntu 14.4.

Ubuntu:

Click on: Search your computer and online sources

Write Disks in the dialog box, then Click on (Disks)

Click the partition you want to hide (it changes color)

Click the double-star (More Options) in the bar below the partitions

Select "Edit Mount Options"

Turn Automatic Mount Options (OFF)

Uncheck "Mount at startup"

Uncheck "Show in user interface"

Click "OK"

Enter password. ( YOU ARE DONE! )

This will take immediate effect but, reboot is necessary.

Windows:

No need to hide Ubuntus Partition from Windows! Windows automatically Ignores other non windows OS's Partitions.

0

(this assumes, that your drive has a GPT partition table. If you are still on MBR, the UUID-part will vary)

  1. start the „disks“ utility (i.e. named gnome-disks) if you need to find out the names of the partitions to hide. (in my case, due to windows dual boot, win and res

  2. figure out uuids of the partition(s):

    sudo blkid | grep -e win -e res

    • the sudo is important!
    • of course, you may also go with just one search term
  3. sudo <editorOfYourChoice> /etc/fstab

  4. add at bottom:

    # hide win:
    PARTUUID=89849072-d255-4363-89d0-b8c45626cfc5 none noauto,nofail,nosuid,nodev,x-gvfs-hide,comment=hidden 0 0
    # hide msres:
    PARTUUID=5ac96edf-f0db-4c6d-9751-dd06dda2abe7 none noauto,nofail,nosuid,nodev,x-gvfs-hide,comment=hidden 0 0
    
    

(yes, quite a list of attributes, but then this should please most file manager)

Note: now that /etc/fstab is aware of that partition (even to ignore it), you will see a star next to it in disks.

Note: using PARTUUID=... here, not UUID...

-1

You may set a partition as hidden in gparted if your disk has a GUID Partition Table (GPT).

Simply install and run gparted, right-click your partition, manage flags, and set the partition as hidden.

1
  • NOTE! This will do much more than just hide the partition from the Linux desktop GUI. Should not be used if you wish to use partition with Windows, as the OS will ignore the partition's existence if this flag is set. Partition hiding with linux but not with Windows while using GPT and setting a partition as hidden by using (g)parted is a bug, and should not be relied upon.
    – F-3000
    Aug 25, 2017 at 13:11
-2
  1. make a hidden folder
  2. mount any partition there,,,,

    mkdir ./.test

    sudo mount /dev/sda1 ./.test/

To unmount

sudo umount ./.test/

./.test/is hidden

you can only mount a device if its not mounted already by the command I given or u have to use

mount --bind oldmount newmount

oldmount and newmount are folder names

0

You must log in to answer this question.

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