the 60 seconds guide to persistent device naming
so you’ve got a couple of usb-discs (ipod, etc.) and would like them to have persistent names like /dev/ipod, /dev/usbdisk. You can use udev to achieve this easily. I will use my external USB disc as an example.
1. know the block device
Plug in the USB device and watch for messages like ‘scsi device detected’ and note the block device (sda1 in this case).
2. get the corresponding sysfs attributes
execute udevinfo and notice the needed BUS, SYSFS{model} and SYSFS{vendor} attributes after the follow the device-link to the physical device line.
udevinfo -a -p /sys/block/sda/sda1
device ‘/sys/block/sdb/sdb1′ has major:minor 8:17
looking at class device ‘/sys/block/sdb/sdb1′:
SUBSYSTEM==”block”
SYSFS{dev}==”8:17″
SYSFS{size}==”78139360″
SYSFS{start}==”32″
SYSFS{stat}==” 913548 917013 74665370 74665370″
follow the "device"-link to the physical device:
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.7/\
usb4/4-5/4-5:1.0/host2/target2:0:0/2:0:0:0':
BUS=="scsi"
ID=="2:0:0:0"
DRIVER=="sd"
SYSFS{model}=="MK4025GAS "
SYSFS{queue_type}=="none"
SYSFS{rev}=="0811"
SYSFS{scsi_level}=="3"
SYSFS{state}=="running"
SYSFS{vendor}=="TOSHIBA "
3. add rules to udev.rules
Add a new rule to /etc/udev/rules.d/udev.rules. It should contain all attributes from above. The additional NAME attribute denotes the new name for the device node.
BUS=="scsi", SYSFS{vendor}=="TOSHIBA ",SYSFS{model}=="MK4025GAS ",NAME="toshiba".
4. add new /etc/fstab-rules
i.e. dev/toshiba /media/usbdisk vfat user,noauto 0 0
All those information was just posted to get my mind free of other stuff..
No related posts.
From → Admin-stuff, Desktop-related, Linux