public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] Teaching Linux to remember USB
@ 2006-02-26 20:12 daniel
  2006-02-26 20:36 ` Richard Fish
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: daniel @ 2006-02-26 20:12 UTC (permalink / raw
  To: gentoo-user

I have a number of USB devices.  Card Reader, Flash drive, iPod, Camera etc.  
But every time I plug in my CF reader My machine assigns a different id to 
it.  Sometimes it's /dev/sdb sometimes its /dev/sdg etc.  It seems to be 
based on the order in which I plug the devices in, or maybe the port used, or 
both, I'm not sure.

What I'd like to know is how to plug it in and have it always get the same id.  
Is this even possible?  I just want my normal user to always be able to mount 
my flash drive without having to su to root to edit fstab first.  Auto 
mounting would be cool as well but isn't necessary.  I'm just trying to avoid 
hassle.

Ideas? Suggestions?
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-user] Teaching Linux to remember USB
  2006-02-26 20:12 [gentoo-user] Teaching Linux to remember USB daniel
@ 2006-02-26 20:36 ` Richard Fish
  2006-02-26 20:39 ` Brett I. Holcomb
  2006-02-27  1:14 ` K Barter
  2 siblings, 0 replies; 5+ messages in thread
From: Richard Fish @ 2006-02-26 20:36 UTC (permalink / raw
  To: gentoo-user

On 2/26/06, daniel <danstemporaryaccount@yahoo.ca> wrote:
> What I'd like to know is how to plug it in and have it always get the same id.
> Is this even possible?

Write udev rules to create persistent device names.

An example from my /etc/udev/rules.d/10-local.rules file:
BUS=="usb", KERNEL=="sd[a-z]2", SYSFS{serial}=="300000005AF6",
SYMLINK="%k", NAME="backups%e"

> I just want my normal user to always be able to mount
> my flash drive without having to su to root to edit fstab first.

You could also use filesystem labels in /etc/fstab.  Instead of
/dev/sdX, use LABEL=mylabel as the device name.  You can set
filesystem labels on any current filesystem.  For example with ext3,
you use e2label.

With this, you don't need to mess with udev rules.

-Richard

-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-user] Teaching Linux to remember USB
  2006-02-26 20:12 [gentoo-user] Teaching Linux to remember USB daniel
  2006-02-26 20:36 ` Richard Fish
@ 2006-02-26 20:39 ` Brett I. Holcomb
  2006-02-27  1:14 ` K Barter
  2 siblings, 0 replies; 5+ messages in thread
From: Brett I. Holcomb @ 2006-02-26 20:39 UTC (permalink / raw
  To: gentoo-user

Check out udev and set them up in the /etc/udev local file.  The Gentoo site 
has docs on udev with links to some good references.

On Sunday February 26 2006 15:12, daniel wrote:
> I have a number of USB devices.  Card Reader, Flash drive, iPod, Camera
> etc. But every time I plug in my CF reader My machine assigns a different
> id to it.  Sometimes it's /dev/sdb sometimes its /dev/sdg etc.  It seems to
> be based on the order in which I plug the devices in, or maybe the port
> used, or both, I'm not sure.
>
> What I'd like to know is how to plug it in and have it always get the same
> id. Is this even possible?  I just want my normal user to always be able to
> mount my flash drive without having to su to root to edit fstab first. 
> Auto mounting would be cool as well but isn't necessary.  I'm just trying
> to avoid hassle.
>
> Ideas? Suggestions?

-- 

Brett I. Holcomb
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-user] Teaching Linux to remember USB
  2006-02-26 20:12 [gentoo-user] Teaching Linux to remember USB daniel
  2006-02-26 20:36 ` Richard Fish
  2006-02-26 20:39 ` Brett I. Holcomb
@ 2006-02-27  1:14 ` K Barter
  2006-02-28 16:34   ` daniel
  2 siblings, 1 reply; 5+ messages in thread
From: K Barter @ 2006-02-27  1:14 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 1658 bytes --]

I just did something similar today.  I have a USB hard drive, and a USB mp3
player, and I used udev to set up the nodes so that they will always be the
same.

I created a new file under /etc/devfs/rules.d, and called it 10-local.rules.
I used 10 so that it will be processed before the main rules files for udev.

The contents of the file are:
# Thompson/RCA MP3 player.  Mounts as a USB removable drive
# For mounting
BUS=="usb", KERNEL=="sd?1", SYSFS{product}=="RCA_MPCF2473_US ", NAME="%k",
SYMLINK="rca_mp3"
# For fdisk
BUS=="usb", KERNEL=="sd?", SYSFS{product}=="RCA_MPCF2473_US ", NAME="%k",
SYMLINK="rca_mp3_fdisk"

# External USB Hard Drives
BUS=="usb", KERNEL=="sd*", SYSFS{serial}=="DEF10B2734EF", NAME="%k",
SYMLINK="usbhd%n"

As a reference, I used this
document.<http://reactivated.net/writing_udev_rules.html>

Now I can reference the new /dev entries in /etc/fstab like this:
# MP3 Player/USB Storage
/dev/rca_mp3            /media/rca_mp3  auto noauto,noatime,user
0 0

# USB Hard disk
# VFAT partition for windows stuff
/dev/usbhd1             /media/usbhd_10g_vfat   auto \
noauto,noatime,user             0 0
# Ubuntu Linux that can boot from the drive
/dev/usbhd2             /media/usbhd_9gig_ubuntu        auto  \
noauto,noatime,user             0 0
# boot directory for Ubuntu
/dev/usbhd3             /media/usbhd_15m_boot   auto   \
noauto,noatime,user             0 0
# ext3 partition with lots of space
/dev/usbhd5             /media/usbhd_47G_ext3   auto   \
noauto,noatime,user             0 0
/dev/usbhd6             /media/usbhd_211G_ext3  auto   \
noauto,noatime,user             0 0

[-- Attachment #2: Type: text/html, Size: 2817 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-user] Teaching Linux to remember USB
  2006-02-27  1:14 ` K Barter
@ 2006-02-28 16:34   ` daniel
  0 siblings, 0 replies; 5+ messages in thread
From: daniel @ 2006-02-28 16:34 UTC (permalink / raw
  To: gentoo-user

On Sunday 26 February 2006 20:14, K Barter wrote:
> I just did something similar today.  I have a USB hard drive, and a USB mp3
> player, and I used udev to set up the nodes so that they will always be the
> same.
>
> I created a new file under /etc/devfs/rules.d, and called it
> 10-local.rules. I used 10 so that it will be processed before the main
> rules files for udev.
>

Awesome.  This is exactly what I was looking for.  Thanks so much!

-- 
The majority of the stupid is invincible and guaranteed for all time. The 
terror of their tyranny, however, is alleviated by their lack of consistency.
  - Albert Einstein
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-02-28 16:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-26 20:12 [gentoo-user] Teaching Linux to remember USB daniel
2006-02-26 20:36 ` Richard Fish
2006-02-26 20:39 ` Brett I. Holcomb
2006-02-27  1:14 ` K Barter
2006-02-28 16:34   ` daniel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox