Drive designations changing every reboot when no hardware is changed
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Drive designations changing every reboot when no hardware is changed
My Lubuntu machine is changing the way it designates the hard drives every time I change /etc/fstab and reboot it. For example, if I have the definition below the /media/WD2Tb and /media/Elements4Tb drives are not mounted:
(The first 4 drives are internally mounted. The last 2 are external USB drives).
When I look at the disks in settings I see that the WD2Tb drive is designated as /dev/sdc1, and the Elements4Tb is designated as /dev/sdd1. So I edit /etc/fstab to change it to this:
...but after a reboot the /media/WD2Tb and /media/Elements4Tb drives are not mounted again. This time when I look at the Disks in Settings I see that the WD2Tb drive is now designated as /dev/sdd1, and the Elements4Tb is designated as /dev/sdc1 (which is how I had them defined in the first place).
I can repeat this process ad infinitum - whenever I edit fstab, revert the designations of those two drives, and reboot the designation of the drives reverts back to its previous value. If I reboot without editing fstab then the designations stay the same. So it's basically whack-a-mole.
I know that the designations are arbitrary, but I don't understand why these two drives are having their designations changed whenever I edit fstab and reboot, despite no changes being made to the hardware.
All comes down to when they report their status to the kernel. This is part of the reason that it's suggested to use UUID instead of partition # in fstab. I'd do a
Code:
lsblk -o +UUID
to get the UUID of all the partitions, and then redo your fstab replacing /dev/sdxx with UUID=xxx so that it doesn't MATTER what dev ID they get, they'll always mount where you want them.
you ought to use uuids or tags instead of device names like /dev/sdXY.
The uuids and tags are stable, but the name of the devices may change, it probably depends on the order of detection (or something similar).
I had to go to UUIDs too on my server for the same problem. I liked the old way with nice straight forward /dev/sd<id> ... but ... that doesn't work so well now in the 'modern' age .
I was allowed to edit the label of one of the EXT3 partitions, but the new label wasn't displayed when I re-ran lsblk -f. Do I need to unmount/remount to see the new label?
I don't seem to be able to unmount it. Looks like it may need to wait for a reboot?
Sometimes when doing various multiple changes, it takes a reboot to straighten things out. If it happens again, check to see if the state of things is as you expect with findmnt and/or lsblk.
LABEL is king among humans, much easier to use than UUID, which was apparently designed for robots and scripts.
I thought that modern udev rules enforce consistent naming of drives regardless of the order in which the kernel detects them. Is this not so?
Yes & No
The device name is assigned in the order detected/configured ever since drive controllers went to the SATA standard. With the earlier IDE drive controllers they were always assigned by bus & controller sequence but SATA is different.
This change in hardware is why UUIDs were designated/assigned and why the only sure way to always have the same device mounted at the same location is to use the UUID assigned to the file system or the file system LABEL.
I have a 4 HDD raid array, and often see the devices (sdb, sdc, sdd & sde) activated in different order, but the UUID always keeps the array properly configured.
Similarly the VG and LV names always work to properly mount the volumes in an LVM managed machine as do the UUIDs + subvolume names with btrfs.
As far as naming goes --
Yes the UUID is generally guaranteed to be unique and always the same for a specific device.
No, the /dev name is not guaranteed to be always the same since that is defined by the order the machine configures it during boot or connection.
Udev does not define the name, only triggers the config when a device is detected. All you need do to see that is have 2 different usb flash drives. Plug them in in one particular order and the first plugged in gets the first available device name in /dev and the second gets the next available name. Plug them in in a different order and the /dev names will be reversed. The UUID however still identifies each correctly.
Using 'ls -l /dev/disk/by-uuid' each time will show the differences in /dev names for each UUID.
Last edited by computersavvy; 11-04-2021 at 03:47 PM.
LABEL is king among humans, much easier to use than UUID, which was apparently designed for robots and scripts.
Labels are easy to read but often duplicated on different machines. This can often present a problem in moving devices between machines where duplicate labels can be encountered.
UUIDs are intended to be unique even between machines which is why they are such a large group of seemingly random characters. It is seldom that a UUID is duplicated even with a lot of different devices.
I agree that it is easier to read the label since that is human assigned, but for what they were designed for the UUID is arguably more reliable and generally guaranteed to be unique.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.