• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Two HDDs are switching their device names in Ubuntu Linux

grigory

Member
Hello!

Not like it's a problem so far, but mostly my curiosity. I have 2 disks -- internal and external. The latter is connected via USB3 cable. My Ubuntu install is on the external drive. W10 is inside my laptop (it's a dual-boot system). So usually my internal drive is sda and my external one is sdb in Ubuntu (they're both SATA drives, of course). But today they switched their device names, so the internal became sdb and external became sda. After the reboot everything got back to normal. I personally haven't done anything in this regard. To me that's strange. Maybe someone could explain that to me, please.
 
It happens. I can't give a technical explanation, but I think it occurs at start up, when device names are assigned. It's a bad idea to rely on those when scripting recurring tasks, or making big changes to hard drives(partitioning, mass deletion...) without confirming first. Instead, uuid should be used.
 
It happens. I can't give a technical explanation, but I think it occurs at start up, when device names are assigned.

I believe the kernel assigns device handles to the SATA ports in the order that they are initialized and presented to it, and in theory, there is no reason why they MUST have the same device label each time the system is booted.

It's a bad idea to rely on those when scripting recurring tasks, or making big changes to hard drives(partitioning, mass deletion...) without confirming first. Instead, uuid should be used.
Agree 100%.

Everything important that relies on paths to devices/volumes (GRUB, fstab, LLVM, dm-crypt/LUKS) should be using UUIDs so OP, there is no reason to worry if your SATA ports switch their initialization each time you boot. Just don't rely on the label /dev/sdX corresponding to a specific device. Rely on the UUIDs. You can check these by typing 'blkid' at a bash terminal.
 
Back
Top