Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have an HP xw8200 workstation running linux with two small, fast SCSI drives hooked up to the onboard LSI SCSI controller. The drives get labeled /dev/sda & /dev/sdb in /dev, respectively. I have a large SATA disk that I want to add to the system to store data, but every time I connect it, it's /dev gets assigned sda & the two scsi drives are assigned sdb,c, which messes with the boot procedure. How can I get this SATA drive to use sdc? Or what's the quickest way to get this set up?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

The default order in which sda, sdb, sdc are assigned is unpredictable. But it can be overridden through udev. You can control the name of the block device files by adding directives in /etc/udev/rules.d/local.rules (some (older?) systems may only support /etc/udev/rules.conf). Better, you can add directives to create symbolic links, and use those symbolic links in your fstab. You can match by driver, by serial number, or call external programs to read things like filesystem UUIDs. The official documentation is a bit dry; if you need to write udev rules, you may prefer to start with a tutorial.

KERNEL=="sd*", DRIVERS="ahci", SYMLINK+="sata"

If you're using LVM exclusively on a drive, it doesn't matter what the letter the block device for the disk uses: you'll just be using the volume names. (That's one of the major advantages of LVM.)

If you look in /dev/disk/by-*, you'll see various ways of naming disks that are part of udev's default setup: /dev/disk/by-id (disk serial number and more), /dev/disk/by-label (filesystem or other label), /dev/disk/by-path (SCSI IDs and so on), /dev/disk/by-uuid (filesystem UUIDs and the like). These may be sufficient for your purposes.

It's better to match filesystem labels or UUIDs than disk serial numbers, because those don't change if you crash a disk in a RAID array or restore from a byte-for-byte copy (or, for labels, make label restoration part of your recovery procedure). You can use filesystem UUIDs directly in /etc/fstab: use UUID=01234567-89ab-cdef-0123-456789abcdef in the first field, instead of a block device path.

share|improve this answer
    
also /dev/disk/by-id works well. –  ultrasawblade Apr 12 '11 at 21:48
    
@ultrasawblade: Right, thanks, I meant to discuss /dev/by-* and forgot. –  Gilles Apr 12 '11 at 21:55
    
I am making the changes right now to use UUID, which I got from the blkid command. Do I need to also update grub? Grub is pointing to the device itself (/dev/mapper/pva-root). –  churnd Apr 13 '11 at 3:11
    
@churnd: /dev/mapper/pva-root is fine, that's an LVM volume label. That's better than a filesystem UUID that will change if you restore from a backup. –  Gilles Apr 13 '11 at 7:16
    
The directories are /dev/disk/by-{id,uuid,label,path} –  camh Apr 13 '11 at 8:23

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.