|
/Linux/misc:
Removable Storage Should Always Mount on the Same Mount Point
I am writing this as of the kernel 2.6.30/udev era, on Debian testing.
I have a an external USB hard drive that I use all the time. When I boot from scratch, the default udev configuration always assigns the first partition to /dev/sda1. However, when I suspend and then resume, udev likes to put it somewhere else, /dev/sdb1 for instance. Therefore an /etc/fstab entry of the following variety:
/dev/sda1 /mnt/usbfat vfat user,exec,dev,suid,rw,umask=0000 0 0
will not always work because there is no guarantee the partition will get /dev/sda1 every time. The solution is to identify the partition by its label in /etc/fstab. First assign a label to the partition.
For a FAT partition, use the mtools package. First configure mtools by adding the following line
drive x: file="/dev/sdb1"
to /etc/mtools.conf. (This of course assumes that the drive is being assigned currently to /dev/sdb1, which you can verify in /var/log/syslog.) Then write the label to the partion:
# mlabel x:
Volume has no label
Enter the new volume label : USBFAT1
For an ext2/ext3 partition, use:
# e2label /dev/sdb1 USBEXT1
For KDE users, and probably Gnome users as well, this is already enough, it should automount on insertion to the same mount point every time. If you are using a window manager with fewer bells'n'whistles, you probably need to explicitly specify the mount point. There are two ways to set up /etc/fstab. Edit /etc/fstab to contain ONE of the following lines:
LABEL=USBFAT1 /mnt/usbfat vfat user,exec,dev,suid,rw,umask=0000 0 0
OR
/dev/disk/by-label/USBFAT1 /mnt/usbfat vfat user,exec,dev,suid,rw,umask=0000 0 0
Unplug your USB drive, wait a few seconds, then plug it back in. Now type:
mount /mnt/usbfat
References:
http://wiki.archlinux.org/index.php/Persistent_block_device_naming
http://reactivated.net/writing_udev_rules.html
posted at: 05:51 | path: /Linux/misc | permanent link to this entry