Sunday, September 28, 2008

USER DEFINED DEVICE NAMES

I got a chance to go thru this link which dealt with the user defined device names in linux.
This red hat manual entry can be found HERE

A gist of this manual entry is presented here:

1. The /dev/ directory contains virtual files that represent devices. Device names for IDE devices begin with hd, and device names for SCSI devices begin with sd.For example, /dev/hda is the first IDE hard drive, /dev/hdb is the second IDE hard drive.If the device name is followed by a number, the number represents the partition number. For example, /dev/hda1 represents the first partition on the first IDE drive

2. Configuration: User-defined device names can be added based on the device name, partition name, or the UUID of the drive.
[a]: syntax to add a user-defined device name for a storage device
devlabel add -d -s
[b]: To add a device name for a device based on a UUID:
devlabel add -u -s
[c]: To use devlabel to retrieve the UUID for a device:
devlabel printid -d
[d]: To remove the symbolic link
devlabel remove -s

[e]: To determine the status of the devlabel symbolic links:
devlabel status

3. FOR HOTPLUG Devices:
A program called hotplug performs actions when a system event, such as hardware being added or removed, takes place while the system is running. For example, if a USB hard drive or a USB media card reader is attached to the system, hotplug notifies users by logging a message in the system log file (/var/log/messages) and loads the proper kernel modules so the device works.

After inserting the USB card reader into the USB port of the computer, issue the following command as root (where /dev/sda1 is the device name for the media card and /dev/usbcard is the user-defined device name to use:
devlabel add -d /dev/sda1 -s /dev/usbcard --automount
This commands adds an entry for the mount point to /etc/sysconfig/devlabel and creates a symbolic link from /dev/usbcard to /dev/sda1.The --automount option to devlabel specifies that the device should be automatically mounted when devlabel restarts if an entry for it is located in /etc/fstab and if the device exists (a device with the same UUID is found).

The updfstab is a program that scans the IDE and SCSI buses for new devices and adds entries to /etc/fstab for them if entries do not already exist. It also adds entries for USB devices since they appear as SCSI devices.

When a USB device is inserted, hotplug runs the updfstab program, which adds an entry to /etc/fstab for the storage device (such as the media card) if it exists. (If a card reader without a card in it is inserted, an entry is not added.) The line added contains the actual device name (such as /dev/sda1) and the kudzu option. The kudzu option tells Kudzu [1] that it can remove the line if the device does not exist. Since the line is required by devlabel, the kudzu option must be removed so the line remains in the file. Also change the device name to the devlabel device name (such as /dev/usbcard) and create the mount point (such as /mnt/usbcard).

Because of --automount, when devlabel is restarted, the storage media in the USB card reader device is mounted in /mnt/usbcard when the USB device is plugged into the computer. The trick is that when the USB card reader is plugged into the computer, the card must already be in the reader. If not, devlabel can not find the storage device, and thus it can not automatically mount it.

If the USB card reader is already plugged in without a card, when the card is inserted, run the command devlabel restart as root to mount the media card.






No comments: