Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an USB stick which contains private stuff like the SSH key. I want to mount this stick to my own home directory with 0700 permissions. Currently I do this with this line in /etc/fstab:

LABEL=KAYSTICK /home/k/.kaystick auto rw,user,noauto,umask=077,fmask=177 0 0

This works great but there is one minor problem: In Nautilus (The Gnome file manager) the mount point ".kaystick" is displayed. I guess Nautilus simply scans the /etc/fstab file and displays everything it finds there. This mount point is pretty useless because it can't be clicked when the device is not present and it can't be clicked when the device is present (Because then it is already mounted). I know this is a really minor problem because I could simply ignore it but I'm a perfectionist and so I want to get rid of this useless mount point in Nautilus.

Is there another way to customize the mount point and mount options for a specific USB device? Maybe it can be configured in udev? If yes, how?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Found it out by myself. I added the file /lib/udev/rules.d/99-kaystick.rules with this content:

IMPORT{program}="/sbin/blkid -o udev -p %N"
ENV{ID_FS_LABEL}!="KAYSTICK", GOTO="kaystick_end"
ACTION=="add", RUN+="/bin/mkdir -m 0 -p /home/k/KAYSTICK", RUN+="/bin/mount -o noatime,umask=077,fmask=177,utf8,uid=1000,gid=1000,sync /dev/%k /home/k/KAYSTICK"
ACTION=="remove", RUN+="/bin/umount -l /dev/%k", RUN+="/bin/rmdir /home/k/KAYSTICK"

and then ran this command to reload the udev rules:

udevadm control --reload-rules

Now everytime I insert my USB stick a directory /home/k/KAYSTICK is created and the stick is mounted to this directory with custom mount options. When removing the stick it is automatically unmounted and the directory is removed. Auto-unmounting wasn't working with the /etc/fstab solution I tried before so this solution is much better.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.