In Ubuntu Linux, traditional hard drive identifiers like /dev/sda1 or /dev/nvme0n1p2 are completely dynamic. This means if you unplug a USB drive, add a second hard drive, or simply reboot the computer, the operating system might assign the drive a completely different device name (for example, /dev/sdb1 might become /dev/sdc1). If you use these dynamic names in your /etc/fstab file to mount drives automatically on boot, your system could crash if the names change.
To solve this, Linux assigns every single formatted partition a Universally Unique Identifier (UUID) at the moment it is created. The UUID is a long string of letters and numbers that is physically written to the drive’s file system header. It never changes, no matter which SATA port or USB slot the drive is plugged into, making it the only safe way to permanently mount drives.
How to View Disk UUIDs in Ubuntu Linux
You can instantly view the UUID of every connected partition using the blkid command.
- Open your Terminal application (Ctrl + Alt + T).
- Because reading raw block device data requires elevated privileges, you must use
sudo. Type the following command and press Enter:sudo blkid - Enter your administrator password when prompted.
- The terminal will output a list of every active partition on your system. It will look something like this:
/dev/sda1: UUID="9a3b2c1d-4e5f-6g7h-8i9j-0k1l2m3n4o5p" TYPE="ext4" PARTUUID="1234abcd-01"
The critical information you need is the text inside the quotation marks immediately following UUID=. You can safely copy this long identifier string and paste it into your /etc/fstab file (using the format UUID=your-long-string-here) to ensure the drive is always mounted perfectly on every reboot, regardless of its physical device path.