How To Use UUID To Mount Partitions / Volumes Under Ubuntu Linux

Q. Can you explain UUID concept related to Linux ext3 partitions and storage devices? How do I update /etc/fstab using UUID under Ubuntu Linux or any other Linux distro?

A. 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 coordination. Thus, anyone can create a UUID and use it to identify something with reasonable confidence that the identifier will never be unintentionally used by anyone for anything else. Information labeled with UUIDs can therefore be later combined into a single database without needing to resolve name conflicts.

UUID and Partitions

Linux’s ext2/ext3 filesystem uses UUID to identify partitions.

UUID benefits

As a sesonded UNIX admin I have to deal with various data storage technologies such as SAN, iSCSI, DAS, scsi disks volumes. Sometime you may need to move storage from one device to another and updating /etc/fstab can be pain in a$$. With UUID Linux kernel should automatically find and map (read as mount to exact location) volumes to storage device. This saves lots of time and avoid /etc/fstab breaks.

However, UUID may be not very useful for single desktop computer at home as you do not have enterprise grade storage and requirements.

How do I find out UUID for /dev/sdb2?

To probe filesystem type and read label and uuid for /dev/sdb2 (or any other device) use vol_id command:
# vol_id --uuid {/dev/device}
# vol_id --uuid /dev/sdb2
$ sudo vol_id --uuid /dev/sdb2

Sample output:


List all UUIDs

Use blkid command-line utility to locate/print block device attributes:
$ sudo blkid
Sample output:

/dev/sda1: TYPE="ntfs" UUID="A0F0582EF0580CC2" 
/dev/sda2: UUID="8c2da865-13f4-47a2-9c92-2f31738469e8" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sda3: TYPE="swap" UUID="5641913f-9bcc-4d8a-8bcb-ddfc3159e70f" 
/dev/sda5: UUID="FAB008D6B0089AF1" TYPE="ntfs" 
/dev/sdb1: UUID="32c61b65-f2f8-4041-a5d5-3d5ef4182723" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdb2: UUID="41c22818-fbad-4da6-8196-c816df0b7aa8" SEC_TYPE="ext2" TYPE="ext3" 

How do I use UUID to update /etc/fstab file?

Simply use following syntax:

UUID={YOUR-UID}    {/path/to/mount/point}               {file-system-type}    defaults,errors=remount-ro 0       1

Open /etc/fstab:
$ sudo vi /etc/fstab
Append line as follows:

UUID=41c22818-fbad-4da6-8196-c816df0b7aa8  /disk2p2      ext3    defaults,errors=remount-ro 0       1

Save and close the file. To mount new partition immediately using /etc/fstab type:
$ sudo mount -a

Further readings:

  • man pages mount, fstab, vol_id

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 18 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
18 comments… add one
  • root Apr 23, 2009 @ 4:18

    man tune2fs

  • Willie May 18, 2009 @ 2:06

    I have been trying to figure out what happen to my UUID’s on my server, thanks a lot for the help. Now I can change everything to ext4 on my laptop.

  • SS Sep 14, 2009 @ 13:24

    Thats a good description.

  • unixadmin007 Mar 22, 2010 @ 0:47

    I have a UBUNTU server, recently i cloned the disk using dd and kept the second disk in box itself. yesterday i realized that because of UUID features it generated same UUID to my /dev/sdb partitions and it looks like it is using the mix of first disk and second disk.

  • Alex May 7, 2010 @ 9:59

    as of ubuntu 10.04 i found out that vol_id does not exist anymore
    ( ) .

    now “blkid” should be used instead.

  • niku Jun 6, 2011 @ 17:33

    ls -l /dev/disk/by-uuid/

  • paul Sep 6, 2011 @ 21:25

    Forgive my ignorance with the whole UUID thing. I understand it is superior in many ways, hence the switch.
    However does this mean that anything to do with hard-drives / flash drives / CD & DVD bays involving the terminal is going to be a complete pain in the arse?
    For instance, to write an image to disk, I can currently use something like:
    # dd if= of=sdb1
    But now I must type:
    # dd if= of=8c2da865-13f4-47a2-9c92-2**FNA**&%#$**34 ???
    Or is there something to this whole “upgrade” process that I’m not understanding?

  • Decaffienated46 Oct 1, 2011 @ 9:03

    The main importance of UUID is for mounting a specific device to a specific mount-point reliably. In a terminal to use your example you would still type: # dd if= of= where you mount sdb1.
    During the boot process, you have much more accurate mounting if you use:
    UUID=8c2da865-13f4-47a2-9c92-2**FNA**&%#$**34 ext4 /office-docs rw,defaults 0 2 .
    This will ALWAYS mount that device at /office-docs. If you use a line in etc/fstab like:
    /dev/sdd1 /office-docs ext4 /office-docs defaults,rw 0 2 there is a possibility that another hdd may be recognized as /dev/sdd1 and therefore be mounted at /office-docs.
    Once boot-up is complete, you will still use the same commands as always (always referencing mounted devices just like you have been doing).

  • Rick Feb 24, 2012 @ 2:09

    I didn’t understand the rational behind the change. However, I was recently given an old tablet that won’t boot off anything but its internal drive. I installed Linux by booting my desktop from install media, installed to the tablet’s drive connected as an external. Once tucked back into the target machine, it booted flawlessly, thanks to UUIDs. No mucking about with the fstab.

  • Doesntmatter May 14, 2012 @ 2:39

    I find it convenient to use UUID for drives at home. For instance if I set fstab mounts based on drive number such as /dev/sda1 it might break next time I add or remove a drive because drive numbers might change. however, this is solved by using uuids because they identify drives uniquely not their order on controller.

  • Matt Nov 7, 2012 @ 19:26

    dumpe2fs -h |grep UUID

  • Navin Jan 17, 2013 @ 18:19

    i’m trying to install RHEL 6.2 in VMware on an external Hard drive. I have tried a few times in no of ways 1. When creating the VM i tried custom and identified by EXT4 partition on my hard drive. When i wanted to an install, went past the boot screen but that’s it. 2. I thrashed the VM and created another on the Laptop hard drive. whilst installing RHEL, i tried the 2nd option besides basic storage devices. Can’t find the my external ext4 partition or my hard drive.
    Any help is welcome

  • Randy Kramer Apr 30, 2013 @ 19:53

    I suspect that UUIDs change if you repartition a drive? (I’m almost sure that has to be true, but I was looking for confirmation.)

  • Jitender Aug 4, 2013 @ 14:36

    I have created Ghost Image of my Server but when i installed that Image on another server in LAN, i am getting conflict of UUID at Central Server.
    Why it is so and how to get rid of this?
    Please help me

  • Arvind Aug 3, 2014 @ 23:28

    Duplicate UUIDs occur only in rare cases. In your case, you cloned the disk using some utility. (E.g. dd). This caused the conflict.

    The steps to solve this are:
    1) type “blkid” on the main server and the other server as root. And identify the partitions and their corresponding numbers in /dev E.g. /dev/sda1, dev/sda2 .. /dev/sdX etc.. Now we need to change only those partitions whose UUIDs match the UUIDs of partitions on the server.

    2) generate as many random UUIDs as needed for the partitions. Using the “uuidgen” command. Running “uuidgen” in terminal will generate a random UUID e.g. “4ae70274-5b0f-4384-a7fd-15fcbdbd0b58” do this twice or thrice or as many times as needed.

    4) Assign these randomly generate UUID’s to the partitions. This needs root privileges the command is “tune2fs /dev/sdX -U ”
    E.g.: sudo tune2fs /dev/sda2 -U 73c6756e-aad2-41f6-8dff-597fe076cd07

    • Arvind Aug 3, 2014 @ 23:30

      Hmm seems WordPress has issues with formatting. It bit off some of my wording.
      Correct “This needs root privileges the command is tune2fs /dev/sdX -U ” to
      “This needs root privileges the command is “tune2fs /dev/sdX -U UUID_Value”

      • Extra Jul 22, 2015 @ 11:50

        Thank you for your solution!

  • Maik Dec 19, 2015 @ 11:46

    Thanks for tut! Works fine!

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum