Mounting partitions by UUID

Mounting a partition consistently every time can be a problem when dealing with removable media or after adding or removing a partition on your drive.  These type of changes cause the device names to change on reboot as devices are rediscovered and renumbered.  These issues are solved by mounting partitions by UUID rather than by device name.  The UUID will stay the same for the lifetime of the partition.

A useful command to help you find the proper UUID is blkid.

$ sudo blkid
/dev/sda3: UUID="3868B51068B4CDBE" TYPE="ntfs"
/dev/sda5: UUID="65086436-bb2d-477a-ba83-46171f8091fe" TYPE="swap"
/dev/sda6: UUID="0f0b40d3-7bd8-4cee-8f7a-4ab7ee567b4e" TYPE="ext4"
/dev/sda7: UUID="98beaa74-34e5-4cee-94ac-234246d8ef33" TYPE="ext4"
/dev/sda9: UUID="d7ca81a4-6422-4b0b-812d-605679858cd2" TYPE="ext4"

After finding the UUID, add it to your fstab.  For example, to mount /dev/sda3 as /srv/ntfiles add the following line to your /etc/fstab.

UUID=3868B51068B4CDBE /srv/ntfiles    ntfs    defaults    0 0


One thought on “Mounting partitions by UUID

  1. Another similar way is using labels. They are much more convenient to remember comparing to UUIDs. Setting the label usually done via the “tune2fs -L” command.

Leave a Reply

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s