Leverage udev to use the same device name
Instead of listing UUIDs in /etc/fstab
, you could list a device name, and set up udev to use the same device name for all of these devices. Put a line like this in a file in /etc/udev/rules.d
:
KERNEL=="sd*", ATTRS{serial}=="123456798", NAME="one_of_my_disks%n"
or
KERNEL=="sd*", ATTRS{serial}=="123456798", SYMLINK+="one_of_my_disks%n"
Run udevadm info -a -n sdb
to see what attributes of the disk (like ATTRS{serial}=="123456798"
in the example above) you can match against. Note that you can only use multiple attributes but they all have to be from the same section.
Then, in /etc/fstab
, use /dev/one_of_my_disks
as the block device.
If your disks have different layouts, this is more complicated. You can use auto
for the filesystem type; this should work most of the type. If you need different partition numbers or mount options, however, you'll need different fstab entries. You can work around that by editing fstab
on the fly through a script invoked by the udev entry, which will be executed when the disk is detected by the system. For example, use the following udev rule:
KERNEL=="sd*", ATTRS{serial}=="123456798", ENV{FSTAB4}="compress=lzo", NAME="one_of_my_disks%n", RUN+="/usr/local/sbin/fstab_update_my_disk"
and the following fstab_update_my_disk
script (untested):
#!/bin/sh
/usr/bin/sed -i -e '/^\/dev\/one_of_my_disks1/ s/\([^ \t][^ \t]*[ \t][ \t]*[^ \t][^ \t]*[ \t][ \t]*[^ \t][^ \t]*[ \t][ \t]*\)[^ \t][^ \t]*/\1'"$FSTAB4"'/'
Leverage udev to not care about the mount point
Another approach would be to keep separate fstab entries, with distinct device names and distinct mount points. But use a udev RUN
hook to update a symbolic link that points to the mount point.
KERNEL=="sd*", ATTRS{serial}=="123456798", RUN+="/bin/ln -snf /media/disk1 /media/one_of_my_disks"
Have you tried "killall sshfs"? That always works for me. Of course if you have more than one, you might want to narrow it down (ps -ef f) + (kill ###). You might need to kill[all] "-9" ###.
I've found that certain unclean umounts leave the process running and tie up the sshfs system (or at least that directory) until the process is killed. (Sometimes, there's an "ssh" job forked from an sshfs, identifiable by a number of command line parameters including "ClearAllForwardings", as well as sshfs jobs)
Fractal
Best Answer
If the filesystem is already mounted and you need to change the mount options, you must remount the filesystem. You can either
umount
thenmount
or you can use theremount
option to mount. Here is an example: