Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there a way to name devices such that any drive plugged into slot 1 is always named /dev/sda? Rather than just first drive inserted sda even though it's plugged into the last slot, second sdb wherever it goes, etc...

Edit (after more research): How does /dev/disk/by-path work? Does part of the name map to a physical port?

Edit again: by-path does not seem to work at all with the hotswap drives. They do not show up.

share|improve this question
    
I need a way to distinguish ports. So that my program can alert that the drive in port __ is ready to be removed. –  Duke Silver Aug 7 '12 at 19:46

1 Answer 1

Rather than rely on device names being always the same, why not use filesystem labels? Those are a lot easier to deal with.

To set a label on a partiton (ext2/3/4 in this case):

$ e2label /dev/sda1 FOOBAR

Then in /etc/fstab:

LABEL=FOOBAR     /mnt/foobar    ext3   defaults 0 0
share|improve this answer
2  
UUIDs are good too, though more painful to read. –  Zoredache Aug 7 '12 at 19:25
    
These drives will only be plugged in once for a few hours before a completely new drive comes in. Will this map the physical location of the drive or the drive itself? –  Duke Silver Aug 7 '12 at 19:37
    
This will give the kernel a clue as to where to mount the drive when it's presented, regardless of physical slot. –  rnxrx Aug 7 '12 at 19:40
1  
It will label a device, not a port. –  Hennes Aug 7 '12 at 19:40
    
I need a way to distinguish ports. So that it can alert that the drive in port __ is ready to be removed. Without writing specific information about each drive before plugging it in. –  Duke Silver Aug 7 '12 at 19:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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