Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
FYI: Mounting USB drives at known points
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
lyallp
Veteran
Veteran


Joined: 15 Jul 2004
Posts: 1616
Location: Adelaide/Australia

PostPosted: Thu Jul 26, 2007 10:43 am    Post subject: FYI: Mounting USB drives at known points Reply with quote

Given that if you plug in a usb drive, depending on how you have things setup, your device mounts at /media/blah or is assigned device /dev/sda

Now, unplug that drive, put in another and it will get the same mounts/devices.
Plug the second one in, it ends up with a different device, different mount point.
This always annoyed me.
I discovered, by digging around /dev/ and /proc that the directory /dev/disk/by-id is amazingly useful for identifying removable drives

This led to me creating the following fstab entries.
Code:

# Memory cards (flash card) and USB Disks
/dev/disk/by-id/usb-DataFab_Systems_Inc._USB_to_CF.SM_Combo_7797D71897-part1 /mnt/usb/dataFab      vfat      noauto,sync,user,gid=usbd,umask=0,umask=007,quiet      0 0
/dev/disk/by-id/usb-Transcend_USB_2.0_Reader_363603001E7D-part1           /mnt/usb/transcend      vfat      noauto,sync,user,gid=usbd,umask=0,umask=007,quiet      0 0
/dev/disk/by-id/usb-WDC_WD20_00JB-00GVA0_DEF1082AC0DB-part1           /mnt/usb/externalCase   vfat      noauto,user,gid=usbd,umask=0,umask=007,quiet      0 0


So, now, it doesn't matter what I plug in, in what order, the devices always appears in the expected place, for that device.

I am wondering if this is the most effective means but it seems to work fine for me :-)
_________________
...Lyall
Back to top
View user's profile Send private message
swimmer
Veteran
Veteran


Joined: 15 Jul 2002
Posts: 1330
Location: Netherlands

PostPosted: Thu Jul 26, 2007 11:44 am    Post subject: Reply with quote

In case you are using udev (which is default nowadays on Gentoo systems) you could solve that with a few additional udev-rules. But you still need the fstab entries of course ...

Here's how I did it:
Code:

/etc/udev/rules.d/10-local.rules
--------------------------------
BUS=="usb", SYSFS{manufacturer}=="LaCie", KERNEL=="sd?", NAME="lacie"
BUS=="usb", SYSFS{manufacturer}=="LaCie", KERNEL=="sd?[0-9]", NAME="lacie%n"
BUS=="usb", SYSFS{manufacturer}=="iRiver", KERNEL=="sd?", NAME="iriver", OWNER="swimmer"
BUS=="usb", SYSFS{manufacturer}=="iRiver", KERNEL=="sd?[0-9]", NAME="iriver%n", OWNER="swimmer"
ATTRS{media}=="cdrom", KERNEL=="hdc", SYMLINK+="cdrom", OWNER="swimmer"

Code:

/etc/fstab
----------
# Lacie
/dev/lacie1     /media/lacie  auto      auto,user       0 0
# Iriver H340
/dev/iriver1    /media/iriver auto      auto,user,flush,iocharset=utf8,uid=1000,umask=007 0 0
# DVD
/dev/hdc        /media/dvd    auto      auto,user       0 0
# Cdrom
/dev/cdrom      /media/cdrom  auto      auto,user       0 0


Greetz
swimmer
Back to top
View user's profile Send private message
lyallp
Veteran
Veteran


Joined: 15 Jul 2004
Posts: 1616
Location: Adelaide/Australia

PostPosted: Tue Jul 31, 2007 11:21 am    Post subject: Reply with quote

Actually, with a touch more investigation, I have managed to get my USB keys to mount as I expect.

I previously showed how I setup my /etc/fstab to take advantage of udev symlinks in /dev/disk/by-id
Code:

# Memory cards (flash card) and USB Disks
/dev/disk/by-id/usb-DataFab_Systems_Inc._USB_to_CF.SM_Combo_7797D71897-part1 /mnt/usb/dataFab           vfat            noauto,user,gid=usbd,umask=0,umask=007,quiet            0 0
/dev/disk/by-id/usb-Transcend_USB_2.0_Reader_363603001E7D-part1              /mnt/usb/transcend         vfat            noauto,user,gid=usbd,umask=0,umask=007,quiet            0 0
/dev/disk/by-id/usb-WDC_WD20_00JB-00GVA0_DEF1082AC0DB-part1                  /mnt/usb/externalCase      vfat            noauto,user,gid=usbd,umask=0,umask=007,quiet            0 0
/dev/disk/by-id/usb-USB_Flash_Drive_123456789ABCDEF                          /mnt/usb/KanesUSB          vfat            noauto,user,gid=usbd,umask=0,umask=007,quiet            0 0
/dev/disk/by-id/usb-USB_Flash_Disk_90740C0025A6-part1                        /mnt/usb/LyallsUSB         vfat            noauto,user,gid=usbd,umask=0,umask=007,quiet            0 0


I have my local /etc/udev/rules.d/98-local.rules (rather than 10-local.rules, or in addition to), which I modified to contain...
Code:

BUS=="usb", SYSFS{serial}=="DEF1082AC0DB",    ACTION=="add", RUN+="/bin/mount /mnt/usb/externalCase"
BUS=="usb", SYSFS{serial}=="363603001E7D",    ACTION=="add", RUN+="/bin/mount /mnt/usb/transcend" 
BUS=="usb", SYSFS{model}=="PNY/Datafab CF+S", ACTION=="add", RUN+="/bin/mount /mnt/usb/dataFab"     
BUS=="usb", SYSFS{serial}=="90740C0025A6",    ACTION=="add", RUN+="/bin/mount /mnt/usb/LyallsUSB"
BUS=="usb", SYSFS{serial}=="123456789ABCDEF", ACTION=="add", RUN+="/bin/mount /mnt/usb/KanesUSB"


The reason for the 98 prefix rather than 10 is that the symlinks in /dev/disk/by-id are not created until rule 60-persistent-storage.rules, so I had to move my rules to execute after them.
_________________
...Lyall
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum