Linux

UUID vs Device Names in Linux: How to Mount Disks Correctly

This guide explains the key differences between UUIDs and device names (like /dev/sdb1) in Linux. You'll learn why UUID is the standard for stable disk mounting, especially in fstab, and get step-by-step instructions for finding a disk's UUID and configuring mounting.

Updated at February 17, 2026
10-15 min
Easy
FixPedia Team
Применимо к:Ubuntu 22.04+Debian 11+CentOS 8+Fedora 36+Arch Linux

Introduction / Why This Is Needed

When working with disks in Linux, you encounter two primary identification methods: device names (e.g., /dev/sda1) and UUIDs (Universally Unique Identifier). Device names are convenient for manual operations but unreliable for automatic mounting—they can change when a new disk is added. A UUID, however, is a unique identifier "baked into" the filesystem when it's created. It remains unchanged regardless of how the system names the disk.

This guide explains why UUID is the standard for /etc/fstab and systemd units, and how to use it correctly to avoid boot errors or incorrect data mounting.

Requirements / Preparation

Before you begin, ensure:

  1. You have terminal access with sudo privileges.
  2. The disk or partition is already formatted (has a filesystem, e.g., ext4, xfs, ntfs).
  3. You know the mount point (e.g., /mnt/data or /home) where you want to attach the disk.

Step 1: How Device Names and UUIDs Work

Device Names (/dev/sdX, /dev/nvme0n1p1)

The system assigns disk names in the order they are detected. If you add a new SATA disk, existing ones may "shift":

  • You had /dev/sda (system) and /dev/sdb (data).
  • You plug in a USB drive → it becomes /dev/sdc, and /dev/sdb might stay in place or become /dev/sdc if the USB drive was detected first.
  • Problem: An /etc/fstab entry like /dev/sdb1 /mnt/data ext4 defaults 0 2 after a reboot might point to the wrong disk or cause a "not found" error.

UUID

A unique 128-bit identifier generated when the filesystem is created (mkfs). Example:

UUID=3e4f1a2b-5c6d-7e8f-9a0b-1c2d3e4f5a6b

This identifier is tied to the data, not the disk's "order." It stays the same even if you reconnect the disk to a different port or a different system.

💡 Tip: Always use UUID for entries in /etc/fstab. This guarantees your data will mount correctly after any hardware reconfiguration.

Step 2: Find the Disk or Partition's UUID

There are several ways. The most reliable is blkid (requires sudo to show all disks):

sudo blkid

Example output:

/dev/sda1: UUID="a1b2c3d4-e5f6-7890-abcd-ef1234567890" TYPE="ext4" PARTUUID="..."
/dev/sdb1: UUID="f1e2d3c4-b5a6-0987-cdef-0123456789ab" TYPE="xfs"
/dev/nvme0n1p1: UUID="12345678-90ab-cdef-1234-567890abcdef" TYPE="vfat"

Alternative without sudo (will show only mounted filesystems and those with read permissions):

lsblk -f

Output will be a table: NAME, FSTYPE, LABEL, UUID, MOUNTPOINT.

Which UUID to use?

  • If you are mounting an entire partition (e.g., /dev/sdb1), use that partition's UUID.
  • If you are mounting an LVM logical volume (/dev/mapper/vg0-lvdata), that volume also has its own UUID (find it via blkid /dev/mapper/vg0-lvdata).

Note down the required UUID (copy from the output, without the quotes).

Step 3: Configure Mounting by UUID in fstab

The /etc/fstab file (file systems table) defines how the system mounts disks at boot.

  1. Open the file in a text editor with sudo:
sudo nano /etc/fstab

(or sudo vim /etc/fstab, sudo vi /etc/fstab)

  1. Find the line corresponding to your disk. It might look like:
/dev/sdb1   /mnt/data   ext4   defaults   0   2
  1. Replace /dev/sdb1 with UUID=<your_uuid>. For example:
UUID=f1e2d3c4-b5a6-0987-cdef-0123456789ab   /mnt/data   ext4   defaults   0   2
  1. Save the file and exit.

Explanation of fstab fields:

  1. UUID=... — the device (or its stable identifier).
  2. /mnt/data — the mount point (must exist; create it via sudo mkdir -p /mnt/data).
  3. ext4 — filesystem type (you can specify auto, but explicit is better).
  4. defaults — mount options (rw, suid, dev, exec, auto, nouser, async). defaults is sufficient for most cases.
  5. 0 — dump (obsolete, set to 0).
  6. 2 — filesystem check order at boot (0 — don't check, 1 — only root, 2 — all others).

Step 4: Verify the Entry is Correct

Don't reboot immediately! Check the syntax and mountability:

sudo mount -a

This command attempts to mount all filesystems from /etc/fstab according to the settings.

Possible results:

  • No output — no errors; everything mounted (or was already mounted).
  • Error: mount: /mnt/data: special device UUID=... does not exist.
    • Cause: UUID is incorrect, disk is not connected, or filesystem is corrupted.
    • Solution: check the UUID via sudo blkid, ensure the disk is visible in lsblk.
  • Error: mount: /mnt/data: mount point does not exist.
    • Cause: the mount point /mnt/data does not exist.
    • Solution: sudo mkdir -p /mnt/data.

After a successful mount -a, verify the disk is mounted:

df -hT /mnt/data

The output will show the filesystem, size, used space, and mount point.

The system automatically creates stable symbolic links in /dev/disk/by-uuid/. For example:

/dev/disk/by-uuid/f1e2d3c4-b5a6-0987-cdef-0123456789ab -> ../../sdb1

You can use this path directly in fstab:

/dev/disk/by-uuid/f1e2d3c4-b5a6-0987-cdef-0123456789ab   /mnt/data   ext4   defaults   0   2

This is equivalent to the UUID=... entry, but some system utilities (e.g., systemd) prefer UUID=.

How does it work? The kernel creates these links upon detecting block devices. They always point to the current /dev/sdX or /dev/nvme..., even if the name changes.

Verify the Result

  1. Reboot the system:
sudo reboot
  1. After booting, check if the disk mounted:
mount | grep /mnt/data

or

df -hT | grep /mnt/data

You should see a line with your filesystem and mount point.

  1. Ensure the data is accessible:
ls /mnt/data

If the disk did not mount after reboot — see the "Potential Issues" section.

Potential Issues

1. Boot Error: "Waiting for /dev/disk/by-uuid/..."

  • Cause: The fstab specifies a UUID for a disk that is physically absent (e.g., an external disk is not connected).
  • Solution:
    • If the disk should always be present — check the connection and cables.
    • If the disk is optional — add the nofail option to the fstab options field:
      UUID=... /mnt/data ext4 defaults,nofail 0 2
      
      This allows the system to continue booting even if the disk is not found.

2. Error "wrong fs type, bad option, bad superblock"

  • Cause: Incorrect filesystem type specified (ext4 instead of xfs), corrupted superblock, or the disk is not formatted.
  • Solution:
    • Check the filesystem type via sudo blkid or lsblk -f.
    • If the filesystem is corrupted, try sudo fsck.<fs_type> /dev/sdX1 (e.g., fsck.ext4).
    • Ensure you are not trying to mount a swap partition (TYPE="swap").

3. Disk mounts to a different location after reboot

  • Cause: fstab uses a device name (/dev/sdb1) that has changed.
  • Solution: Replace the device name with UUID=... or /dev/disk/by-uuid/... and run sudo mount -a.

4. No access to files after mounting

  • Cause: Incorrect permissions on the mount point or the disk itself.
  • Solution:
    • Check permissions: ls -ld /mnt/data.
    • Change the owner (if it's your home partition): sudo chown -R $USER:$USER /mnt/data.
    • For NTFS partitions (via ntfs-3g), permissions can be problematic — configure mount options in fstab (e.g., uid=1000,gid=1000,umask=022).

5. blkid does not show a UUID

  • Cause: The filesystem does not support UUIDs (very old) or the disk is not formatted.
  • Solution: Format the disk (data will be erased!):
sudo mkfs.ext4 /dev/sdX1   # for ext4

After formatting, the UUID will be created automatically.

Advanced Option: systemd Mount Units

Instead of fstab, you can use individual systemd mount units. This provides more control (dependencies, timeouts). Create a file /etc/systemd/system/mnt-data.mount:

[Unit]
Description=Mount data disk
After=network.target

[Mount]
What=UUID=f1e2d3c4-b5a6-0987-cdef-0123456789ab
Where=/mnt/data
Type=ext4
Options=defaults

[Install]
WantedBy=multi-user.target

Enable and start it:

sudo systemctl enable --now mnt-data.mount

This method is particularly useful for disks that should mount later in the boot process or for complex dependencies.

Conclusion

Using UUIDs for disk mounting in Linux is a simple and reliable practice that protects against issues caused by changing device names. Key steps:

  1. Find the UUID via sudo blkid or lsblk -f.
  2. Write UUID=<value> in /etc/fstab instead of /dev/sdX1.
  3. Verify with sudo mount -a and a reboot.

Now your disks will mount stably, even if you add a new hard drive or rearrange SATA ports.

F.A.Q.

Why is UUID more reliable than /dev/sda1?
How do I mount a disk by UUID in fstab?
Can a UUID change? If so, what should I do?
What should I use for LVM or RAID arrays?

Hints

Understand the difference between UUID and device name
Find the UUID of the desired disk or partition
Configure mounting by UUID in fstab
Verify the fstab entry is correct
Use symbolic links in /dev/disk/by-uuid (optional)

Did this article help you solve the problem?

FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community