Some Background...

I think this should be a general linux kernel (or kernel module) related question, though I'm facing the issue while preseeding debian for an automated installation.

Every time I boot the installer from a usb disk, the usb disk turns out to be /dev/sda, but the preseed file I'm using assumes the first hard disk (sata in this case) should be /dev/sda. I'm using the same system for a pxe network installation, and I would prefer to keep them consistent. I also fear that if I wrote a preseed config that assumed the first disk was sdb instead, that for some reason it might not be at some point.

I've tried writing udev rules that changes the device name of the usb disk to "INSTALLMEDIA" which seems to work, however it does not cause the SATA disk to start at sda, they still start at sdb.

My questions...

What determines the order that disks are discovered and named?

What, if anything, can I do to control this?

If I cannot do anything to control it, would it be safe to assume when booting from USB that the USB disk can be more or less guaranteed to be sda and the first SATA disk would always be sdb?

2 Answers 2


The most reliable answer to this question, that I'm aware of, is to use the newer symlinks that udev can create for you. Udev enumerates the disk drives, and creates several trees with devices - explaining for you what kind of devices they are.

This is located in /dev/disk.

You have, by-path:


Which clearly tells you if the device is a usb-device, for instance.

  • 1
    This is extremely helpful, although I'm a bit worried about being able to reliably predict the correct pci or scsi address on my preseed config, but this might give me something to work with. Oct 19, 2011 at 16:36
  • 3
    You got other lookup-methods in the /dev/disk directory as well - maybe by-id or by-label is useful to you?
    – Kvisle
    Oct 19, 2011 at 16:48
  • This would work if there was something like by-type/ata-1, but the other lookups are just too complex and subject to change. But you definitely won me over by bringing this to my attention, I've already found two other uses for it. Oct 26, 2011 at 20:00

The other option would be to create your own symlink (or even a device file) if you can run some sort of script before you actually need to access the device. Something like

for i in  /dev/sd? ; do 
  if detect installation drive somehow ; then ln -s $i /dev/install ; fi ; 
done ;

And as a very last resort solution you could "swap" the sda,sdb,... device files in /dev, but I would try hard to avoid this solution as it could introduce a lot of new problems.

  • I just could move them all down with the udev rules instead. I was just hoping for something more reliable, like a kernel switch or blacklisting a module to disable loading USB storage or something. That would allow me to use my same installer on PXE without making assumptions about what order the disks are plugged in. Oct 26, 2011 at 20:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .