Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Device names on hotswap server. (Name by port rather than insert order?)

I need a way to access the drive in sata port ?? on a hotswappable server. I was previously trying to access by a /dev/ name and find the port it belongs to but I cannot seem do that. The drives will basically be assembly lined through the server so I can not do anything drive specific (rename by uuid etc...).

I will need to be able to use hdparm and dd on the drive.

share|improve this question

marked as duplicate by Shane Madden, Zoredache, Michael Hampton, mdpc, rnxrx Aug 21 '12 at 22:31

This question was marked as an exact duplicate of an existing question.

No that was about renaming the drive as it comes in, this is about accessing the drive by port. – Duke Silver Aug 8 '12 at 15:21
Nice username btw, I have a copy of the breakfast poster not ten feet away from me. – Chopper3 Aug 8 '12 at 15:29
Thanks ha ha, surprised it wasn't taken actually – Duke Silver Aug 8 '12 at 15:41
For better or worse, names on the SE sites aren't unique. I am but one of many Charleses, for example. – Charles Aug 8 '12 at 15:51
I probably should have noticed that ha ha. – Duke Silver Aug 8 '12 at 16:03
up vote 0 down vote accepted

On most modern distros, you'll have a /dev/disk directory. Inside will be a handful of other directories, each corresponding to one way to find a disk device.

Inside by-id, you'll see drives and partition "names" as made up by the kernel. Usually these names will include the disk model number and serial number. For example, a name I have on one of my systems is scsi-SATA_ST3808110AS_5LR187B2 is a SCSI (SATA) Seagate ST3808110AS with the serial number 5LR187B2.

Inside by-label, you'll see partition labels, as discussed in your earlier question. You might not have labels, and they're for partitions, not drives.

Inside by-path, you'll see path name built from the chain of devices that lead to the device. For example, I have one called pci-0000:00:1f.2-scsi-3:0:0:0 -- the fourth (counting from zero) SCSI device attached to a SCSI adapter attached to the PCI bus.

Finally, by-uuid contains the UUIDs assigned to each partition on the available drives.

All of these are simple symlinks back to the appropriate device in /dev.

If you're trying to find a device on a specific SATA port, using the device names in by-path is probably going to work for you.

share|improve this answer
Is there a way to make by-path work with hot-swapped sata drives? For some reason it works with usb, but not the sata. – Duke Silver Aug 8 '12 at 15:40
@DukeSilver, at least on the systems I'm working with here (CentOS 5 and 6), hot-swap drives appear correctly inside the /dev/disk hierarchy. The device names I gave above are hot-swap devices on that machine. – Charles Aug 8 '12 at 15:41
For some reason the contents of by-path do not change when I add drives to the system. Every other folder seems to change, but not by-path. Ubuntu 10.04 – Duke Silver Aug 8 '12 at 15:44
Hmm. Well, the node names in there won't change, but do the drive letters that they point at change? I'm assuming that by-id changes, right? Given that the names in there are generated based on the model and serial of the drive, I'd certainly hope so. You can use the combined data between the two to derive the port number for any given disk device. Don't forget that hot-swaps are likely to appear in your syslog. – Charles Aug 8 '12 at 15:51
@Charles, dmesg is for more then just boot processes. The dmesg command displays the kernel ring buffer. Basically anything the kernel wants to log. When the system boots, this has the messages from when the kernel loads, but if your system is up long enough and it is active enough the boot messages will fall out of the list to be replaced by other kernel messages. – Zoredache Aug 8 '12 at 16:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.