How To Label ext4 And XFS File System In Linux

Shehu Awwal
Shehu Awwal
Published in
3 min readMay 5, 2020

Well, If you need to label one of your filesystem, may be when adding it to fstab, you don’t want to use the UUID, And prefer using the LABEL, Depending on your choice.

For me, I prefer naming my filesystem with label, Once I look at them in a single look, I already know what filesystem this belongs to without the need to start looking at the mountpoint.

Labeling An ext4 File System

There are other commands for labeling an ext4 file system, But I would go with tune2fs command, Somehow the command looks like xfs_admin command that’s used to label an XFS file system.

From this image, As you can see, I just did blkid device name. As you can see there’s no label in the device name, To add a label use tune2fs -L

root@shehuawwal.com:~# tune2fs -L home-filesys /dev/mapper/fedora_localhost- -live-home

It should create the file system label.
-L specifies it should create the label
home-filesys is the name of the label
/dev/mapper/fedora_localhost- -live-home
That’s the name of the device we are trying to label.

Now to view the label, You can make use of

[root@fedora31 ~]# tune2fs -l /dev/mapper/fedora_localhost — live-home | grep -i volume

which greps the output of the volume and shows the name or make use of blkid.

Use:

root@fedora31 ~]# blkid /dev/mapper/fedora_localhost — live-home

Note: When labeling with tune2fs, You can’t label more than 16 Characters Long, If you do that, It will truncate it.

Labeling A XFS File System And Changing The UUID Of An XFS File System

With xfs_admin, You can label the XFS File system, The command pretty looks like tune2fs except that this is used to manage the XFS File System.

As you can see from the above image, the file system is XFS, Now let’s label it.

[root@centos-7 ~]# xfs_admin -L cent-root /dev/xvda1

Just like the command above where -L specifies the name, But the one thing with xfs_admin the file system to be label has to be unmounted first.

Changing The UUID Of A XFS File System

Find a way to generate your UUID, After that then make use of -U options.

Example:

[root@centos-7 ~]# xfs_admin -U 0887b7f6-1bc3-4934-b0c8-8528dbc7be13 /dev/xvda1

From the command above, after the -U is the new UUID, I wanted for the File System.

--

--

Shehu Awwal
Shehu Awwal

Hacker — Passionate About InfoSec, Linux, Clouds, Containers, Virtualization, Distributed Systems And Architectures And New Trends.