Udev: Assign unique names to your devices: Difference between revisions
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 22: | Line 22: | ||
<li>Remove and re-plugin your device. It should now show up at [/dev/your_name]!</li> | <li>Remove and re-plugin your device. It should now show up at [/dev/your_name]!</li> | ||
<li>If it's a drive, add a mount rule to [/etc/fstab] like this: | <li>If it's a drive, add a mount rule to [/etc/fstab] like this: | ||
<pre></pre></li> | <pre>/dev/sdhc_via_usb /mnt/8gb_sdhc vfat</pre></li> | ||
<li>Now you can mount your device reliably, using the mount path, no matter where you plug in your device, or what order you plug it in. | <li>Now you can mount your device reliably, using the mount path, no matter where you plug in your device, or what order you plug it in. | ||
<pre>mount /mnt/8gb_sdhc</pre>Pretty cool, eh?</li> | |||
</ol> | </ol> | ||
Next, we'll work on [[Automatically mount and unmount your devices|automounting your device]] when it is inserted... | Next, we'll work on [[Automatically mount and unmount your devices|automounting your device]] when it is inserted... |
Latest revision as of 17:49, 17 October 2008
[udev] was born for this job. This is fun stuff! (I'm a sick geek.)
- Make sure you've emerged [sys-fs/udev] and [sys-apps/baselayout].
- Put [/etc/udev/rules.d/10-local.rules] under version control, you're going to put your rules there.
- Make sure the kernel has the following enabled:
File systems ---> Pseudo filesystems ---> [*] /proc file system support [*] Virtual memory file system support (former shm fs)
- Run [lsusb], plug your device in, run it again and compare. This will show you the bus+device+deviceid. For USB devices, you can use the Device ID as a unique identifier.
- If needed, run [lsusb -D /proc/bus/usb/#bus#/#device#] to find out everything about your device.
- If you still want more help, plug in your device while watching /var/log/messages to get the dev path, then use this to get more udev identifiers:
udevinfo -a -p `udevinfo -q path -n /dev/sda`
- Write a rule using the selected identifier. Add it to [/etc/udev/rules.d/10-local.rules]. Here's one using a device with ID [090c:6000]:
BUS=="usb", SYSFS{idVendor}=="090c", SYSFS{idProduct}=="6000", NAME="sdhc_via_usb"
- Tell udev to reload rules, and wait for it to finish:
udevadm control --reload_rules udevadm trigger udevadm settle
- Remove and re-plugin your device. It should now show up at [/dev/your_name]!
- If it's a drive, add a mount rule to [/etc/fstab] like this:
/dev/sdhc_via_usb /mnt/8gb_sdhc vfat
- Now you can mount your device reliably, using the mount path, no matter where you plug in your device, or what order you plug it in.
mount /mnt/8gb_sdhc
Pretty cool, eh?
Next, we'll work on automounting your device when it is inserted...