jump to navigation

Mount disks with UUID or LABEL on Linux December 29, 2010

Posted by Tournas Dimitrios in Linux.

When linux system starts, auto mounting partition will be done by referring to /etc/fstab. The file /etc/fstab will list down how you like the system to mount your partitions. Mounting with device path has problems when  :

  1. you have multiple hard disk, and the order of hard disk changed  ,may cause the file system failed to mount.
  2. Creating logical partitions on a disk , will assign to these partitions device names with increasing number schema ( /dev/hda5 , /dev/hda6 , /dev/hda7 , /dev/hda8  , /dev/hda9 etc…) . Now on a scenario that needs to delete two logical partitions , Linux will re-assign the number schema . For example , if we delete  /dev/hda6  and  /dev/hda7  ,  logical partition  /dev/hd8 will be renamed to /dev/hd6  and logical partition /dev/hd8 will be renamed to /dev/hd7  …. I hope you get the picture 🙂

From previous examples , it is evident that Linux on some cases , could produce inconsistency between the fstab-file and the device name schema . Therefore later days of fstab  ,  entries has been modified to identify by uuid or label  instead of device names  .

Mounting disks by uuid :

UUID stands for Universally Unique Identifier, it gives each filesystem a unique identifier. With uuid, you no need to worry about the reordering of hard disk anymore.

A Universally Unique Identifier (UUID) is an identifier standard used in software construction, standardized by the Open Software Foundation (OSF) as part of the Distributed Computing Environment (DCE). The intent of UUIDs is to enable distributed systems to uniquely identify information without significant central coördination.

Finding out UUID for your hard drive:
blkid /dev/hda1
/dev/hda1: LABEL=”/boot” UUID=”a52a29ab-14ff-46d5-a2f1-a47a3157d8f9″

alternatively use :

ls -l /dev/disk/by-uuid/ |grep hda1
lrwxrwxrwx 1 root root 10 Dec 29 06:21 a52a29ab-14ff-46d5-a2f1-a47a3157d8f9 -> ../../hda1

You can set the UUID for an Ext file system with tune2fs -U ” xxx” where ” xxx” is either a custom UUID, clear to clear/remove the UUID, random to generate a random UUID or time to generate a UUID based on the current time.
tune2fs -U 123-456 /dev/sdc 1
Now that we know the uuid number , the proper changes must be done on the fsatab file ( see an example later )

Mounting disks by Label :

Volume labels make it possible for partitions to retain a consistent name regardless of where they are connected, and regardless of whatever else is connected. Labels are not mandatory for a linux volume. Each can be a maximum of 16 characters long.

Note: don’t try this on the disks that have data. Labelling them can destroy it.

Use the one of the following commands to label a disk :

  • e2label   /dev/hdb1   newlabel
  • tune2fs -L newlabel /dev/hdb1
  • mke2fs -L newlabel /dev/hdb1
  • mkfs.ext3 -L newlabel  /dev/hdb1
  • mkswap -L  swaplabe  /dev/hdbxx

Of course, labeling with e2*-like tools only works for Ext file systems, but there are similar tools for other file systems. For example ntfslabel for NTFS (from package ntfsprogs) , dosfslabel for FAT (package dosfstools), xfs_admin -L (package xfsprogs) for XFS and many more.

Manually mounting filesystems can also be done via label :  mount -L  labelname  /mnt/point1

To display all partitions with they’re corresponding uuid’s and labels use : 

  • blkid
  • ls -l  /dev/disk/by-uuid/
  • tree   /dev/disk

The modified fstab file is :

LABEL=/boot    /boot     ext3    defaults   1 2


UUID=a52a29ab-14ff-46d5-a2f1-a47a3157d8f9        /boot   ext3    defaults        1 2

Graphical utility  gparted :

A graphical utility for partitioning / formating / labeling disks is gparted : yum install gparted

a nice tutorial how to use gparted to label your disks is here >>>>>



No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s