Page 1 of 1

[Solved] Is it possible to add a label on a fstab created by UUID?

Posted: 2023-09-11 23:32
by lospala
Hi
Al tough I posted this problem before: I have a 120 gb sdd containing sda1 (home partition) and sda2 (root partition)
Additionally I have a mechanical 4tb hdd (sdb1)
Bookwworm when booting randomly swaps sda1 with sdb1 labels and despite this is not a big problem, I would like to know if based upon the actual fstab (created by Debian installer by UUID) it would be possible to add a label to force sda1 to appear permantly labelled as sda1 and if the answer is yea how would I do it..

Here goes the fstabv

Code: Select all

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda2 during installation
UUID=d6e70001-0d10-489e-b9c8-5540d103f2e7 /               ext4    errors=remount-ro 0       1
# /home was on /dev/sda1 during installation
UUID=0e71ce84-b217-4b90-8bf3-34cbe083f886 /home           ext4    defaults        0       2
##########################################################################
#Entry for /dev/sdb1 :
#/dev/sdb1	/media/WIN2K	ext4	rw,nosuid,user,nodev,uhelper=devkit	0	2
UUID="03ee29ab-d62f-4a32-87b7-cd0afff2ca70"	/media/WIN2K	ext4	rw,nosuid,user,nodev,uhelper=devkit	0	2
Thanka for any help

Re: Is it possible to add a label on a fstab created by UUID?

Posted: 2023-09-13 17:15
by Aki
Hello,
lospala wrote: 2023-09-11 23:32 [..] when booting randomly swaps sda1 with sdb1 labels and despite this is not a big problem, I would like to know if based upon the actual fstab (created by Debian installer by UUID) it would be possible to add a label to force sda1 to appear permantly labelled as sda1 [..]
It depends on what you mean for "label".

If you mean the device name (/dev/sda1, /dev/sdb1, etc), it's not possible (AFAIK).

If you mean to specify a different label for each file system, it is possible. For example, you may configure the label "sda1" for the file system in the partition /dev/sda1 . If the same device is recognized at boot as /dev/sdb1, you will find that its label is "sda1". I don't know if it's worth it.

Re: Is it possible to add a label on a fstab created by UUID?

Posted: 2023-09-13 17:35
by pwzhangzz
We typically use gparted to add a "label" to a partition and then edit the fstab file by replacing "UUID=" with "LABEL=" as in the following example:

Code: Select all

  UUID=ae472421-5730-4487-b314-825fbe9b371f  /extra   ext4   defaults,noatime 0 2

  LABEL=extra  /extra   ext4   defaults,noatime 0 2
Of course you can name your label any way you want.

Re: Is it possible to add a label on a fstab created by UUID?

Posted: 2023-09-13 18:27
by CwF
pwzhangzz wrote: 2023-09-13 17:35 We typically use gparted to add a "label" to a partition and then edit the fstab file by replacing "UUID=" with "LABEL="...snip... Of course you can name your label any way you want.
Yes, gparted is likely the easiest way.
There is no default use for 'Label' and if a user does not name the file systems (~syn with disk or partition) manually then there will be no /dev/disk/by-label directory or listings. I mention using labels often. A consistent use of labels helps id disk when moved to another system, a best practice. We can Label or re-Label a disk at anytime independent of any other designation.

UUID is created on creation of the disk or partition, IIRC at format, maybe without...?

dev/sdx are on the fly enumerations that depend on the boot properties of the machine, maybe detection order, maybe response order, maybe fixed by port connection as on upscale motherboards, etc. sdx# is then the sub partitions.

Re: Is it possible to add a label on a fstab created by UUID?

Posted: 2023-09-13 18:51
by pwzhangzz
CwF wrote: 2023-09-13 18:27 UUID is created on creation of the disk or partition, IIRC at format, maybe without...?
A UUID is automatically assigned to a partition when this partition is created (formatting won't change the UUID). You can also use gparted to change the UUID of a partition, using an arbitrary name, e.g., mydisk001, etc. It would work just like using the lable function (for new Debian installations you don't even have to edit the fstab file), but most people like to have more than one option to use a partition.

Re: Is it possible to add a label on a fstab created by UUID?

Posted: 2023-09-13 20:01
by lospala
Aki wrote: 2023-09-13 17:15 Hello,
If you mean the device name (/dev/sda1, /dev/sdb1, etc), it's not possible (AFAIK).

If you mean to specify a different label for each file system, it is possible. For example, you may configure the label "sda1" for the file system in the partition /dev/sda1 . If the same device is recognized at boot as /dev/sdb1, you will find that its label is "sda1". I don't know if it's worth it.
Hello Aki

I tried to mean device name like /dev/sdx sorry for the misunderstanding of the label

Debian when mounting disks sometimes sda1 is recognized as sdb1 and vice versa.
I had bash commands working on the mechanical disks that firstly used "dev/sdbx" and when I noted this behavior I amended the commands using the mounting point (i.e. /media/XXXX instead of "dev/sdbx"
I realize it is not possible.
Thanks to you and to the other members who helped

Regards