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?

4

4 に答える 4

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 :)

于 2013-04-14T14:09:32.277 に答える
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).

于 2012-07-05T18:14:56.877 に答える
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.

于 2012-07-09T19:13:10.340 に答える
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"
于 2017-04-05T14:56:28.077 に答える