[olug] How to force internal HDD to be sda?

Christopher Cashell topher-olug at zyp.org
Wed Sep 15 22:23:15 UTC 2010

On Sat, Sep 11, 2010 at 8:09 AM, Kevin D. Snodgrass
<kdsnodgrass at yahoo.com> wrote:
> I have 2 external hard drive cases that I use extensively.  On my laptop (mostly), in Fedora 13 if I boot with the external drive plugged in via USB it gets assigned /dev/sda and the laptop internal drive gets assigned /dev/sdb.  When the external is not attached the internal gets assigned /dev/sda.  Why?  Sorry to be blunt, but that is just damn stupid.  (Says the crusty old UNIX guy)

It's actually pretty logical.  Disks are named in the order in which
the system sees them.  Apparently, USB is getting scanned for disks
before IDE/SATA/SCSI is.  Thus, if your external disk is connected
prior to boot, it ends up as /dev/sda.  Otherwise, it gets added as
the next available disk when connected (typically /dev/sdb,

> Is there some way I can force whatever is doing this (I'm guessing udev, since this problem starting showing up with it's introduction) to assign the internal to /dev/sda?

Yes.  udev is the correct place to handle this, provided the currently
available information (see below) isn't good enough.  First question,
do you *need* /dev/sda and /dev/sdb to point to these specific drives?
 Or do you just need a persistent device name that you can always
refer to for one or both of them?

If they absolutely must be /dev/sda or /dev/sdb, respectively, then
you need to write/edit some udev rules in /etc/udev/rules.d/.
Depending on your distribution, you may have some samples there that
you can work from.  If not, you can find references and documentation
on the web.  Basically, you'll need to write a rule for udev so that
when a disk is found, it is checked a certain way (commonly using
/lib/udev/scsi_id, or something similar), and depending on the
information found about that disk, it is named/renamed/aliased

If you just need any persistent name, and it doesn't absolutely have
to be /dev/sda or /dev/sdb, then you should already have what you need
on a modern Linux distribution.  Just go to /dev/disk/by-id/ and find
the entry for whatever you need.  That symlink will always exist if
the device is available, and it will always have the same name.  You
can reference that without caring whether the actual device is
/dev/sda, /dev/sdb, or /dev/sdxyz.

> Kevin D. Snodgrass


More information about the OLUG mailing list