Daniel Bahl

How to label a disk in Linux

When using features like Ubuntus auto-mount, Ubuntu mounts USB-devices based on their label, and to avoid weird mount-points, like for example /media/[user]/c658e045-4bac-4d1b-8504-419ca6e72663 you can define a label for this volume, and make it auto-mount in /media/[user]/your-label.

Please note, this tools will work only on ext2/ext3/ext4 file systems.

To name a volume, you can use the built-in tool called e2label

e2label will display or change the filesystem label on the ext2, ext3, or ext4 filesystem located on device.

Quote: Man-pages

It’s pretty simple, just type e2label followed by your volume and then the new label.

e2label /dev/sde1 seagate_6tb_usb

Now, if auto mount is enabled on your Ubuntu, it will always be mounted as the label suggest.

Using fstab with labels

You can also use labels in /etc/fstab to mount it automatically using the disk label.

You can update the /etc/fstab file as follows:

LABEL=seagate_6tb_usb     /media/6tb/    ext4   defaults 0 0

Daniel Bahl

Creative nerd and developer from Denmark who loves to craft beautiful apps for servers, web and mobile. Fluent in PHP, Python and Swift. Linux-user since 1998, macOS-user since 2001. Co-owner and co-founder of Cloudportal.dk, v5.dk, Cloudnet.dk, WebReview.dk, ShareShortcuts.com, Appghost.com and several other awesome websites. You'll find links and more information about everything on this website including some snippets and notes from my worklife :)

Add comment

Follow me on Twitter