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

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
User avatar
lospala
Posts: 116
Joined: 2023-05-31 08:32
Location: Buenoa Aires, Argentina
Has thanked: 13 times
Been thanked: 4 times

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

#1 Post 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
Last edited by lospala on 2023-09-13 20:01, edited 1 time in total.
Disorder consists of arranging certain elements so that they do not suggest known geometric shapes to the observer.

Aki
Global Moderator
Global Moderator
Posts: 4101
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 118 times
Been thanked: 544 times

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

#2 Post 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.
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

pwzhangzz
User Project Contributor
User Project Contributor
Posts: 535
Joined: 2020-11-11 17:42
Has thanked: 12 times
Been thanked: 41 times

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

#3 Post 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.

CwF
Global Moderator
Global Moderator
Posts: 3163
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 63 times
Been thanked: 272 times

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

#4 Post 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.
Mottainai

pwzhangzz
User Project Contributor
User Project Contributor
Posts: 535
Joined: 2020-11-11 17:42
Has thanked: 12 times
Been thanked: 41 times

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

#5 Post 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.

User avatar
lospala
Posts: 116
Joined: 2023-05-31 08:32
Location: Buenoa Aires, Argentina
Has thanked: 13 times
Been thanked: 4 times

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

#6 Post 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
Disorder consists of arranging certain elements so that they do not suggest known geometric shapes to the observer.

Post Reply