LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 11-04-2021, 10:09 AM   #1
itm60
LQ Newbie
 
Registered: Jan 2020
Posts: 7

Rep: Reputation: Disabled
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:

Code:
/dev/sda1   /media/Samsung2Tb1    ext4    defaults,nofail   0    0
/dev/sdb1   /media/Hitachi2Tb    ext4    defaults,nofail  0    0
/dev/sdd1   /media/WD2Tb    ext3    defaults,nofail   0    0
/dev/sdg2   /media/Hitachi3Tb    ntfs    defaults,nofail   0    0
/dev/sde2   /media/USB4Tb    ntfs    defaults,nofail   0    0
/dev/sdc1   /media/Elements4Tb    ntfs    defaults,nofail   0    0
(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:

Code:
/dev/sda1   /media/Samsung2Tb1    ext4    defaults,nofail   0    0
/dev/sdb1   /media/Hitachi2Tb    ext4    defaults,nofail  0    0
/dev/sdc1   /media/WD2Tb    ext3    defaults,nofail   0    0
/dev/sdg2   /media/Hitachi3Tb    ntfs    defaults,nofail   0    0
/dev/sde2   /media/USB4Tb    ntfs    defaults,nofail   0    0
/dev/sdd1   /media/Elements4Tb    ntfs    defaults,nofail   0    0
...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.
 
Old 11-04-2021, 10:12 AM   #2
Timothy Miller
Moderator
 
Registered: Feb 2003
Location: Arizona, USA
Distribution: Debian, EndeavourOS, OpenSUSE, KDE Neon
Posts: 4,005
Blog Entries: 26

Rep: Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521
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.
 
Old 11-04-2021, 10:13 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
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).
 
Old 11-04-2021, 10:30 AM   #4
itm60
LQ Newbie
 
Registered: Jan 2020
Posts: 7

Original Poster
Rep: Reputation: Disabled
Excellent - thanks that looks like a much better way of doing things!
 
Old 11-04-2021, 11:38 AM   #5
rclark
Member
 
Registered: Jul 2008
Location: Montana USA
Distribution: KUbuntu, Fedora (KDE), PI OS
Posts: 480

Rep: Reputation: 179Reputation: 179
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 .
 
Old 11-04-2021, 12:39 PM   #6
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,141

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
It can be done by label as well. Create the label when making the partition(s) then just mount as such.

https://wiki.archlinux.org/title/fst..._system_labels

Easier to deal with than the UUID imho if you don't have a way to direct copy paste.
 
1 members found this post helpful.
Old 11-04-2021, 01:05 PM   #7
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,573
Blog Entries: 19

Rep: Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452
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?
 
Old 11-04-2021, 01:07 PM   #8
itm60
LQ Newbie
 
Registered: Jan 2020
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jmgibson1981 View Post
It can be done by label as well. Create the label when making the partition(s) then just mount as such.

https://wiki.archlinux.org/title/fst..._system_labels

Easier to deal with than the UUID imho if you don't have a way to direct copy paste.
Yes labels sound like an even better way. Unfortunately some of the drives don't have labels, and when I try to edit their labels I get:
Code:
Cannot change label on mounted device of type filesystem:ntfs (udisks-error-quark,11)
 
Old 11-04-2021, 01:08 PM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
so you need to umount first. Or use uuids.
 
Old 11-04-2021, 01:10 PM   #10
itm60
LQ Newbie
 
Registered: Jan 2020
Posts: 7

Original Poster
Rep: Reputation: Disabled
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?
 
Old 11-04-2021, 01:13 PM   #11
itm60
LQ Newbie
 
Registered: Jan 2020
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
so you need to umount first. Or use uuids.
I don't seem to be able to unmount it. Looks like it may need to wait for a reboot?
 
Old 11-04-2021, 01:14 PM   #12
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
hm, I'm not really sure about that, probably an umount/mount helps, but probably you need to reboot.
 
Old 11-04-2021, 02:40 PM   #13
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 5,808
Blog Entries: 1

Rep: Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066
Quote:
Originally Posted by itm60 View Post
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.
 
Old 11-04-2021, 03:23 PM   #14
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by hazel View Post
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.
 
Old 11-04-2021, 03:35 PM   #15
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by mrmazda View Post
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.
 
1 members found this post helpful.
  


Reply

Tags
disks



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Drive designations change randomly? (sda vs sdb vs sdc) haertig Linux - Software 9 08-17-2016 01:33 PM
repository designations plutek Studio 13.37 3 06-21-2013 07:21 PM
How To Make Linux Partition Letter/Number Designations Persistent? -kg- Linux - General 4 08-17-2010 06:45 AM
Confused about HDD designations in Linux jacatone Linux - Newbie 3 06-06-2008 02:42 PM
why my eth0 changed mac every time I reboot to FE:FF:FF and so on golpemortal Linux - Hardware 2 09-23-2007 04:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration