• Home
  • Help
  • Search
  • Login
  • Register
Pages: [1]
Author Topic: Automounting  (Read 2530 times)
karurosu
Global Moderator
Full Member
*****

Karma: 0
Posts: 116



View Profile WWW
« on: May 24, 2009, 08:15:13 PM »

Hi, I have a question about how linux mounts stuff, I am using gentoo, but I think the instructions should be more or less the same for all distros.
My problem is that I have 2 USB storage devices, my rootfs is in the NAND and I have several folders (usr, var, ...) in a flash drive mounted at /mnt/usb. Also, I have another HDD formated with hfsplus that hold my information.
So far everything has worked ok, every time I boot my flash drive gets /dev/sda and my hdd gets /dev/sdb, however it has happened to me that the HDD jumps to sdc, since my fstab has sda and sdb, any screw up with the letters breaks my system.

So my question is: how can I force the system to always give the same /dev entry to a device? I've looked a bit and it seems udev rules are the way to go, but I am not sure how to handle those.
The other question is: how to implement automount? I would like to have the SD mounted at /media when I plug it, or other flash drives.

Thanks.
Logged

zoloto
Newbie
*

Karma: 0
Posts: 1


View Profile
« Reply #1 on: May 24, 2009, 11:18:58 PM »

Hi,

You can use udev rules to assign custom device names to transient devices (such as USB flash drives) - check http://archive.atomicmpc.com.au/forums.asp?s=2&c=16&t=4775 or http://www.reactivated.net/writing_udev_rules.html and scripts in udev rules can be used to automatically mount such devices on specific mount points, but in your case I would rather use UUID or volume label (man fstab) to mount system partitions, e.g.:

LABEL=/                 /                       ext3    defaults        1 1
LABEL=/boot          /boot                ext3    defaults        1 2
LABEL=/var            /var                  ext3    defaults        1 2


To use automount create /etc/auto.master:
/media /etc/auto.media

and /etc/auto.media (to automount /dev/my_sd on /media/sd):
sd   auto,rw,nosuid,nodev :/dev/my_sd

where my_sd is a custom /dev symlink created using udev rule (see above links). Of course, you can also use udev scripts to automagically mount/umount flash drives.

BR.
Logged

bogolisk
Newbie
*

Karma: 0
Posts: 6


View Profile
« Reply #2 on: May 25, 2009, 04:19:37 AM »

Hi, I have a question about how linux mounts stuff, I am using gentoo, but I think the instructions should be more or less the same for all distros.
My problem is that I have 2 USB storage devices, my rootfs is in the NAND and I have several folders (usr, var, ...) in a flash drive mounted at /mnt/usb. Also, I have another HDD formated with hfsplus that hold my information.
So far everything has worked ok, every time I boot my flash drive gets /dev/sda and my hdd gets /dev/sdb, however it has happened to me that the HDD jumps to sdc, since my fstab has sda and sdb, any screw up with the letters breaks my system.

As already posted, you can use LABEL= in fstab. /dev/disk/by-label/XXX is another way of accessing disk using volume name.


Quote
So my question is: how can I force the system to always give the same /dev entry to a device? I've looked a bit and it seems udev rules are the way to go, but I am not sure how to handle those.
The other question is: how to implement automount? I would like to have the SD mounted at /media when I plug it, or other flash drives.

Thanks.

see http://plugcomputer.org/plugforum/index.php?topic=298.msg1911#msg1911
however you'll have to add an entry in the case clause for hfs.


Logged

karurosu
Global Moderator
Full Member
*****

Karma: 0
Posts: 116



View Profile WWW
« Reply #3 on: May 25, 2009, 09:59:53 PM »

Thanks for the pointers, I resolved it with udev rules. Here is how I did it:

http://plugcomputer.org/plugwiki/index.php/Udev_and_usb
Logged

hammerinhank
Newbie
*

Karma: 0
Posts: 24


View Profile
« Reply #4 on: May 26, 2009, 08:50:13 AM »

Another way is to use UUID 

Quote
UUID=550e2f5f-e4f9-41c0-a89f-3d51f3030d23       /               ext3    relatime,errors=remount-ro,noatime 0       0

for example.  You can get the UUID number by

Quote
ls -la /dev/disk/by-uuid/
Logged

Pages: [1]
Print
Jump to: