Operating System - Linux
1832871 Members
3889 Online
110048 Solutions
New Discussion

Re: order of externad hard drive devices

 
Tonatiuh
Super Advisor

order of externad hard drive devices

Red Hat Enterprise Linux AS 4

I have two external disks connected to my system. One firewire and one USB. Both of them are recognized as /dev/sdx. The system always recognize the USB as /deb/sda and the firewire as /dev/sdb.

But I want that always the firewire external disk be recognized as /dev/sda and the USB always be recognized as /dev/sdb.

How can I do that?
12 REPLIES 12
Steven E. Protter
Exalted Contributor

Re: order of externad hard drive devices

Shalom,

You may not be able to do this.

Disconnect both devices.

rmsf all the device drivers for the devices in /dev

connect the one you wish to be a and boot the system.

Then connect the one you want to be b and boot.

Still though, I can think of better ways to allocate my time than this. Do you really need to do this?

Have fun.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Matti_Kurkela
Honored Contributor

Re: order of externad hard drive devices

RedHat ES/AS 4 use a system called "udev" to manage the devices in /dev. This is one of the new features made possible by the 2.6.x kernel.

To change the device names from the default ones, you must write custom "udev rules" for your device. The rules will go to /etc/udev/rules.d.

You can use the "udevinfo" tool to find what information is available for the udev system:
first run e.g. "udevinfo -q path -n /dev/sda" to get the sysfs path to your device, then run "udevinfo -a -p " to get the full information. If your device has meaningful model and/or serial numbers, they could be ideal for use in binding the device names to the correct devices.

Looks like udev is a standard part of a RedHat ES/AS 4 installation, so you don't need to install anything.

"man udev" and the files in /usr/share/doc/udev* directory on your system will tell you more, although it looks like /usr/share/doc/udev* is not very well organized: it is a collection of installation documents from udev source packages, some other non-RedHat-specific documentation and some files apparently written by RedHat people.

http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html
should be a good introduction to udev.
MK
Ivan Ferreira
Honored Contributor

Re: order of externad hard drive devices

To avoid messing with udev, you could use file system labels or the devlabel command to create a fixed device mapped to the UUID.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Tonatiuh
Super Advisor

Re: order of externad hard drive devices

Steven,

This is a very important issue for me. This server is in a site which is phisically several blocks away from my office. This is a test environment system and I reboot it several times a day, so that to walk several blocks to get the site and disconnect and connect the devices is an important problem. I have been done it in this way but is a very big problem about time lost.

By the way, there is nobody permanently there to do it for me. Each one who has any server in that site, take care of his servers by himeself.
Tonatiuh
Super Advisor

Re: order of externad hard drive devices

To complete the explanation Steven. I have installed certain service in the servers that has its config file maped to the device name of one of this external devices. So that if the devices get a different name, the services does not work.

Have fun,

UVR
Tonatiuh
Super Advisor

Re: order of externad hard drive devices

Ivan, I cannot find devlabel command or file.

Is it necessary to install some RPM? do you have mor info about that command?
TwoProc
Honored Contributor

Re: order of externad hard drive devices

In general, when I'm confronted by this type of problem (wherein I want device names deployed the same across servers for consistency), I make symbolic links for the devices and then tell the software/service to use the symbolic link. Think of it as a "handle" to a device. I often do this for SAN attached tape drives, and I've done it for a number of other things as well. Of course, this doesn't work for all software in all cases - but where it does, it is a simple solution that sort of "documents" what is being done in the implementation of each machine.

If I may refer to the tape drive example, on each machine I've got a links called "LIBAD1" "LIBAD2" "LIBAD3", etc. This would stand for " tape library a, drive 1", "tape library a, drive 2"," tape library a, drive 3" etc. On each of the machines these symbolic links are linked to the real device names "/dev/rmt/xxxxxx" for the tape drives - which are NOT consistent from machine to machine. However, the symbolic links, when I can use them clear the whole mess up so that each machine may refer to the tape drives by name as it needs to. This works pretty well in most any Unix (above example is HPUX), and I'd recommend giving it a try.

If you don't like using symbolic links, you can make the same special device file with the "mknod" command in the /dev/ direcoty and name the new special device file to your more realistic name, and as long as it has the same major,minor number as the real one, it does the same exact job. Then feed your configuration files for your software services the new names that you came up with, and don't use the system supplied ones.
We are the people our parents warned us about --Jimmy Buffett
Tonatiuh
Super Advisor

Re: order of externad hard drive devices

John,

If I underestood well, nothing of your ideas satisfy my need.

A link points to a specific device (/dev/sda) form example, but if the device which takes the name (/dev/sda) change, the link points to a different device and it does not found what it is looking for.

I created a device with the same characteristics (with special name) that the device I want to reach (mknod /dev/my_device b 8 1), but if the device takes a diferent name, it is the same result that with the link, it points to a device that is not the device I want to reach.

Tonatiuh
Super Advisor

Re: order of externad hard drive devices

Matti, I am trying with udev but I cannot get results.

This is the line I have inserted into '/etc/udev/rules.d/50-udev.rules'

BUS=="usb", ID=="usb1", SYSFS{product}=="EHCI Host Controller", NAME='usb_uvr'

It supouses that I should see a device with my name '/dev/usb_uvr' but not.

=============0
This is de udev info o the device I am testing with:

[root@monitor ~]# udevinfo -a -p $(udevinfo -q path -n /dev/sdb)

udevinfo starts with the device the node belongs to and then walks up the
device chain, to print for every device found, all possibly useful attributes
in the udev key format.
Only attributes within one device section may be used together in one rule,
to match the device for which the node will be created.

looking at class device '/sys/block/sdb':
SYSFS{dev}="8:16"
SYSFS{range}="16"
SYSFS{removable}="1"
SYSFS{size}="1024000"
SYSFS{stat}=" 8 26 272 21 0 0 0 0 0 21 21"

follow the class device's "device"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.3/usb1/1-2/1-2:1.0/host1/target1:0:0/1:0:0:0':
BUS="scsi"
ID="1:0:0:0"
SYSFS{detach_state}="0"
SYSFS{device_blocked}="0"
SYSFS{max_sectors}="256"
SYSFS{model}="TS512MJF2B "
SYSFS{queue_depth}="1"
SYSFS{rev}="2.00"
SYSFS{scsi_level}="3"
SYSFS{state}="running"
SYSFS{timeout}="30"
SYSFS{type}="0"
SYSFS{vendor}="JetFlash"

looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.3/usb1/1-2/1-2:1.0/host1/target1:0:0':
BUS=""
ID="target1:0:0"
SYSFS{detach_state}="0"

looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.3/usb1/1-2/1-2:1.0/host1':
BUS=""
ID="host1"
SYSFS{detach_state}="0"

looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.3/usb1/1-2/1-2:1.0':
BUS="usb"
ID="1-2:1.0"
SYSFS{bAlternateSetting}=" 0"
SYSFS{bInterfaceClass}="08"
SYSFS{bInterfaceNumber}="00"
SYSFS{bInterfaceProtocol}="50"
SYSFS{bInterfaceSubClass}="06"
SYSFS{bNumEndpoints}="03"
SYSFS{detach_state}="0"
SYSFS{iInterface}="00"

looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.3/usb1/1-2':
BUS="usb"
ID="1-2"
SYSFS{bConfigurationValue}="1"
SYSFS{bDeviceClass}="00"
SYSFS{bDeviceProtocol}="00"
SYSFS{bDeviceSubClass}="00"
SYSFS{bMaxPower}="200mA"
SYSFS{bNumConfigurations}="1"
SYSFS{bNumInterfaces}=" 1"
SYSFS{bcdDevice}="0200"
SYSFS{bmAttributes}="80"
SYSFS{detach_state}="0"
SYSFS{devnum}="3"
SYSFS{idProduct}="2168"
SYSFS{idVendor}="0ea0"
SYSFS{manufacturer}="USB "
SYSFS{maxchild}="0"
SYSFS{product}="Flash Disk "
SYSFS{serial}="61100741775E874B"
SYSFS{speed}="480"
SYSFS{version}=" 2.00"

looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.3/usb1':
BUS="usb"
ID="usb1"
SYSFS{bConfigurationValue}="1"
SYSFS{bDeviceClass}="09"
SYSFS{bDeviceProtocol}="01"
SYSFS{bDeviceSubClass}="00"
SYSFS{bMaxPower}=" 0mA"
SYSFS{bNumConfigurations}="1"
SYSFS{bNumInterfaces}=" 1"
SYSFS{bcdDevice}="0206"
SYSFS{bmAttributes}="e0"
SYSFS{detach_state}="0"
SYSFS{devnum}="1"
SYSFS{idProduct}="0000"
SYSFS{idVendor}="0000"
SYSFS{manufacturer}="Linux 2.6.9-22.EL ehci_hcd"
SYSFS{maxchild}="6"
SYSFS{product}="EHCI Host Controller"
SYSFS{serial}="0000:00:10.3"
SYSFS{speed}="480"
SYSFS{version}=" 2.00"

looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.3':
BUS="pci"
ID="0000:00:10.3"
SYSFS{class}="0x0c0320"
SYSFS{detach_state}="0"
SYSFS{device}="0x3104"
SYSFS{irq}="10"
SYSFS{subsystem_device}="0x3104"
SYSFS{subsystem_vendor}="0x1106"
SYSFS{vendor}="0x1106"

looking at the device chain at '/sys/devices/pci0000:00':
BUS=""
ID="pci0000:00"
SYSFS{detach_state}="0"

Tonatiuh
Super Advisor

Re: order of externad hard drive devices

Matti, Sorry I mistaken the device. The correct info of my device is:

[root@monitor ~]# udevinfo -a -p $(udevinfo -q path -n /dev/sda)

udevinfo starts with the device the node belongs to and then walks up the
device chain, to print for every device found, all possibly useful attributes
in the udev key format.
Only attributes within one device section may be used together in one rule,
to match the device for which the node will be created.

looking at class device '/sys/block/sda':
SYSFS{dev}="8:0"
SYSFS{range}="16"
SYSFS{removable}="1"
SYSFS{size}="1001472"
SYSFS{stat}=" 20 583 960 74 0 0 0 0 0 74 74"

follow the class device's "device"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.3/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0':
BUS="scsi"
ID="0:0:0:0"
SYSFS{detach_state}="0"
SYSFS{device_blocked}="0"
SYSFS{max_sectors}="256"
SYSFS{model}="DataTraveler 2.0"
SYSFS{queue_depth}="1"
SYSFS{rev}="1.00"
SYSFS{scsi_level}="3"
SYSFS{state}="running"
SYSFS{timeout}="30"
SYSFS{type}="0"
SYSFS{vendor}="Kingston"

looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.3/usb1/1-1/1-1:1.0/host0/target0:0:0':
BUS=""
ID="target0:0:0"
SYSFS{detach_state}="0"

looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.3/usb1/1-1/1-1:1.0/host0':
BUS=""
ID="host0"
SYSFS{detach_state}="0"

looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.3/usb1/1-1/1-1:1.0':
BUS="usb"
ID="1-1:1.0"
SYSFS{bAlternateSetting}=" 0"
SYSFS{bInterfaceClass}="08"
SYSFS{bInterfaceNumber}="00"
SYSFS{bInterfaceProtocol}="50"
SYSFS{bInterfaceSubClass}="06"
SYSFS{bNumEndpoints}="03"
SYSFS{detach_state}="0"
SYSFS{iInterface}="00"

looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.3/usb1/1-1':
BUS="usb"
ID="1-1"
SYSFS{bConfigurationValue}="1"
SYSFS{bDeviceClass}="00"
SYSFS{bDeviceProtocol}="00"
SYSFS{bDeviceSubClass}="00"
SYSFS{bMaxPower}="100mA"
SYSFS{bNumConfigurations}="1"
SYSFS{bNumInterfaces}=" 1"
SYSFS{bcdDevice}="0100"
SYSFS{bmAttributes}="80"
SYSFS{detach_state}="0"
SYSFS{devnum}="2"
SYSFS{idProduct}="6533"
SYSFS{idVendor}="0930"
SYSFS{manufacturer}="Kingston"
SYSFS{maxchild}="0"
SYSFS{product}="DataTraveler 2.0"
SYSFS{speed}="480"
SYSFS{version}=" 2.00"

looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.3/usb1':
BUS="usb"
ID="usb1"
SYSFS{bConfigurationValue}="1"
SYSFS{bDeviceClass}="09"
SYSFS{bDeviceProtocol}="01"
SYSFS{bDeviceSubClass}="00"
SYSFS{bMaxPower}=" 0mA"
SYSFS{bNumConfigurations}="1"
SYSFS{bNumInterfaces}=" 1"
SYSFS{bcdDevice}="0206"
SYSFS{bmAttributes}="e0"
SYSFS{detach_state}="0"
SYSFS{devnum}="1"
SYSFS{idProduct}="0000"
SYSFS{idVendor}="0000"
SYSFS{manufacturer}="Linux 2.6.9-22.EL ehci_hcd"
SYSFS{maxchild}="6"
SYSFS{product}="EHCI Host Controller"
SYSFS{serial}="0000:00:10.3"
SYSFS{speed}="480"
SYSFS{version}=" 2.00"

looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.3':
BUS="pci"
ID="0000:00:10.3"
SYSFS{class}="0x0c0320"
SYSFS{detach_state}="0"
SYSFS{device}="0x3104"
SYSFS{irq}="10"
SYSFS{subsystem_device}="0x3104"
SYSFS{subsystem_vendor}="0x1106"
SYSFS{vendor}="0x1106"

looking at the device chain at '/sys/devices/pci0000:00':
BUS=""
ID="pci0000:00"
SYSFS{detach_state}="0"
Tonatiuh
Super Advisor

Re: order of externad hard drive devices

I have tested with a very simple udev rule without results:

KERNEL=="sda", NAME="usb_uvr"

It is a very simple rule tha should not fail, but it fails.

Any idea?
Matti_Kurkela
Honored Contributor

Re: order of externad hard drive devices

I've used rules like this with success:

# Buffalo Clipdrive
BUS="scsi", KERNEL="sd*", SYSFS{vendor}="BUFFALO ", SYSFS{model}="ClipDrive ", NAME="stick%n", MODE="0640", GROUP="hal", SYMLINK="%k"

This causes the actual device name be /dev/stick, with partitions as /dev/stick1 and onwards if necessary.

Note that the vendor and the model strings may have spaces (or other whitespace-like characters) at the end. I copy-pasted the quoted strings directly from udevinfo output to be sure.

The SYMLINK is there to create symbolic links using the "default" device names. I used that while testing my rules. A simple "ls -l /dev/sda*" allows you to see whether your rule was correct or not.
MK