Hiding a mounted device in nautilus
Asked Answered
S

4

6

I am running Ubuntu Precise. In my /etc/init.d I have a bash script that, does the following on startup:

  1. loop mounts an image on an NTFS drive. That image contains an ext2 file system with a directory named home

  2. It then does a mount with a --rbind option that mounts the home within the image file onto /home.

Works well so far, although having open files in /home doesn't prevent the loop mount from being unmounted.

Unfortunately, Nautilus displays the loop mount in the list of removable drives with an icon that allows a user to unmount the loop mount. Unmounting the drive on which /home is mounted is not conducive to a well running system.

How can I keep Nautilus from displaying this loop mounted device?

man udisk(7) says that one of the 'Influential device properties in the udev database' is:

UDISKS_PRESENTATION_HIDE

If set to 1 this is a hint to presentation level software that the device should not be shown to the user.

I assume that setting this property on the /dev/loop would tell Nautilus not to show the device.

How would I set the UDISKS_PRESENTATION_HIDE in a bash script?

Seventieth answered 18/6, 2012 at 23:43 Comment(1)
Off-topic for SO; belongs on askubuntu.comAugmentation
S
0

Another approach is to mount the device somewhere other than under /media. I chose under /run, which allows /mnt to be used for temporary mounts.

Seventieth answered 9/7, 2012 at 19:13 Comment(0)
F
6

The answer should now be updated (at least for Ubuntu 12.10). You don't have to write this anymore (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 :)

Feodore answered 14/4, 2013 at 14:9 Comment(1)
This is also true for Fedora 19. I tried UUID but it didn't work for some reason?Dillard
A
4

You have to write the following on /etc/udev/rules.d/99-hide-disks.rules:

KERNEL=="sdxy", ENV{UDISKS_PRESENTATION_HIDE}="1"

Where sdxy is the partition inside /dev. You can easily find the partition by running mount (but I think you already know it).

Audette answered 5/7, 2012 at 18:14 Comment(0)
S
0

Another approach is to mount the device somewhere other than under /media. I chose under /run, which allows /mnt to be used for temporary mounts.

Seventieth answered 9/7, 2012 at 19:13 Comment(0)
O
0

According to the udisk page on archlinux wiki and to sum up the others answers:
Add a file named /etc/udev/rules.d/99-hide-disks.rules

For udisk:

# hide the device sda1
KERNEL=="sda1", ENV{UDISKS_PRESENTATION_HIDE}="1"

For udisk2:

# hide the device sda1
KERNEL=="sda1", ENV{UDISKS_IGNORE}="1"

# hide the device sda2 using UUID
# use: blkid /dev/sda2    to get the UUID of /dev/sda2
ENV{ID_FS_UUID}=="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX", ENV{UDISKS_IGNORE}="1"
Orff answered 5/4, 2017 at 14:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.