Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] Assign specific device ID to USB external disk
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
solamour
l33t
l33t


Joined: 21 Dec 2004
Posts: 698
Location: San Diego, CA

PostPosted: Fri Nov 16, 2012 6:09 pm    Post subject: [Solved] Assign specific device ID to USB external disk Reply with quote

I have 2 USB external disks: Seagate and WD.

Code:
$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 125: ID 1058:1021 Western Digital Technologies, Inc. Elements 2TB
Bus 001 Device 013: ID 0bc2:3320 Seagate RSS LLC


Seagate was plugged in first, so it is recognized as /dev/sdb, while WD is /dev/sdc. The problem is, whenever I reboot, depending on which one gets recognized first, the drive IDs get switched (i.e. WD gets /dev/sdb, and Seagate gets /dev/sdc), and that messes up my backup scripts.

How do I always assign /dev/sdb to Seagate no matter which one gets plugged first? I think it has something to do with udev rules (because that's how network adapters are done), but I'm not sure how to proceed from here. I'd appreciate any suggestions.
__
sol


Last edited by solamour on Sun Nov 18, 2012 5:34 am; edited 1 time in total
Back to top
View user's profile Send private message
gabrielg
Tux's lil' helper
Tux's lil' helper


Joined: 16 Nov 2012
Posts: 134

PostPosted: Fri Nov 16, 2012 6:22 pm    Post subject: Reply with quote

I believe that you can play with udev's rules, but I never tried it.

I'm not sure what your problem is, but what I do to overcome the order in which external drives are selected is by using labels (tune2fs /dev/partition -L nameoflabel) and then using that in /etc/fstab, for example:
Code:

LABEL=nameoflabel       /path/to/mountpoint       ext4        [your options]    0   0


All this, assuming you use ext4, perhaps it works with vfat and friends, haven't tried it.
Back to top
View user's profile Send private message
solamour
l33t
l33t


Joined: 21 Dec 2004
Posts: 698
Location: San Diego, CA

PostPosted: Fri Nov 16, 2012 6:30 pm    Post subject: Reply with quote

Use the label of the disk... clever. Will try. Thanks.
__
sol
Back to top
View user's profile Send private message
Adel Ahmed
Veteran
Veteran


Joined: 21 Sep 2012
Posts: 1510

PostPosted: Fri Nov 16, 2012 6:33 pm    Post subject: Reply with quote

well as gabriel said you can use the label, you can also use the UUID of the media
I don't know the exact commands for managing the whole uuid thingie, but i suppose this would be helpful:
http://www.gentoo-wiki.info/Gentoo:/dev/disk/by-uuid
there's an fstab entry example here: http://linux.byexamples.com/archives/321/fstab-with-uuid/
labels are just easier though
Back to top
View user's profile Send private message
solamour
l33t
l33t


Joined: 21 Dec 2004
Posts: 698
Location: San Diego, CA

PostPosted: Sun Nov 18, 2012 5:33 am    Post subject: Reply with quote

After trying a few different methods,

1) Use the label of the disk.
2) Add "udev" entry (https://wiki.archlinux.org/index.php/Map_Custom_Device_Entries_with_udev).
3) Use UUID in /etc/fstab.

I ended up with the UUID method. No particular reason, and other methods worked equally well. Thank you everyone for taking time to share your suggestions.
__
sol
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