17

I'm wondering if disk labels like sda/sdb/sdc/... are associated with physical ports on the mainboard? For instance, if I have sda/sdb/sdc and remove the first 2 disks, will sdc become sda or will it stay sdc? Is the principle behind assigning disk labels documented somewhere?

  • In the good old days, they were. Then we ran out of device numbers. – Simon Richter Oct 13 '18 at 11:54
21

No.

udev drive identifiers are done in multiple ways, but they are allocated dynamically on bootup and therefore they will change if you unplug devices (or even if one just happens to spin up slower one day). Slightly more consistent than this is /dev/by-path which will give you a path by connection to the machine, e.g. PCI bus -> Card 0 -> Port 2 (so long as the chip maintains consistent numbering, which isn't guaranteed in all cases).

However, if you want almost perfectly consistent devices*, use their UUID by calling blkid on the partition (like blkid /dev/sda1) and then use that in your mount options or /etc/fstab with UUID=

If you did this as a recent installation, then you should already see an example of this in your /etc/fstab.

*Consistency is not guaranteed if you bitwise-copy (e.g. dd) an entire device or partition because it copies the UUID as well. You'll have to change the UUID if you want to use both copies in the same machine. Use the applicable partition or file system management tool for such a change.

  • 3
    And after changing UUID of the copy you need to ensure that its internal fstab and other config files reference the new UUID instead of the original, otherwise you'll get some unexpected results if you try to boot into this copy. – Ruslan Oct 13 '18 at 17:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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