Linux device names can change as disks are detected. A filesystem UUID keeps the intended volume attached to its mount point when those names change.
Each filesystem stores its own UUID in metadata on the device. blkid reads that identifier and the filesystem type, mount can resolve a UUID=… source, and the system mount table can save the same stable reference for future mounts.
An existing ext4 data filesystem can be tested with a temporary mount before its boot-time entry is saved in /etc/fstab. A malformed entry can delay boot or leave the volume unavailable; the filesystem type, mount options, and boot-time check setting must suit the target volume.
Steps to mount a disk partition by UUID in Linux:
- List the target block device before changing any mount configuration.
$ lsblk -o NAME,SIZE,TYPE,MOUNTPOINTS /dev/sdb1 NAME SIZE TYPE MOUNTPOINTS sdb1 2G part
The target is the filesystem device, usually a partition such as /dev/sdb1, /dev/vdb1, /dev/nvme1n1p1, or a logical volume under /dev/mapper. If MOUNTPOINTS already shows a path, the filesystem is already mounted.
- Read the filesystem metadata from the target device.
$ sudo blkid /dev/sdb1 /dev/sdb1: LABEL="data" UUID="fcc7979c-742b-43aa-9fe5-6a014e23496f" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="d3585d6f-1537-4265-9df1-2bcc2f5296bb"
The mount source uses UUID, the filesystem identifier, rather than PARTUUID, the partition-table identifier. For a different volume, substitute its device path, UUID, filesystem type, and mount point throughout.
- Create the mount point directory.
$ sudo mkdir -p /mnt/data
Files already present in the mount point directory stay hidden while another filesystem is mounted there.
- Test a direct mount by UUID before saving persistent configuration.
$ sudo mount UUID=fcc7979c-742b-43aa-9fe5-6a014e23496f /mnt/data
- Confirm the temporary filesystem mount at /mnt/data.
$ findmnt -M /mnt/data -o TARGET,SOURCE,FSTYPE,OPTIONS TARGET SOURCE FSTYPE OPTIONS /mnt/data /dev/sdb1 ext4 rw,relatime
The -M option checks the exact mount point instead of walking up parent directories. This confirms the temporary mount only; it does not configure future boots.
- Unmount the test mount before editing /etc/fstab.
$ sudo umount /mnt/data
- Back up the current /etc/fstab file.
$ sudo cp --archive /etc/fstab /etc/fstab.bak
A malformed /etc/fstab entry can delay boot or leave the filesystem unavailable until the file is corrected.
- Open /etc/fstab in an editor with root privileges.
$ sudoedit /etc/fstab
- Add a persistent mount line at the end of /etc/fstab for the data volume.
UUID=fcc7979c-742b-43aa-9fe5-6a014e23496f /mnt/data ext4 defaults 0 2
The fields are source, mount point, filesystem type, mount options, dump flag, and filesystem check order. Here, 0 disables dump backups and 2 enables boot-time fsck for this non-root ext4 filesystem. If a line already exists for this volume or mount point, replace it rather than adding a duplicate.
For an optional data disk that may be absent, defaults,nofail allows a systemd host to continue booting without waiting for the mount to succeed. Applications using /mnt/data must tolerate the volume being unavailable.
- Save the changes to /etc/fstab.
- Reload the saved mount configuration on hosts that use systemd.
$ sudo systemctl daemon-reload
This reruns the generators that turn /etc/fstab entries into mount units. On a host using another init system, this step does not apply.
- Verify the saved /etc/fstab entry before mounting from it.
$ sudo findmnt --verify --verbose /mnt/data /mnt/data [ ] target exists [ ] UUID=fcc7979c-742b-43aa-9fe5-6a014e23496f translated to /dev/sdb1 [ ] source /dev/sdb1 exists [ ] FS type is ext4 Success, no errors or warnings detected
Correct the /etc/fstab line before continuing if findmnt reports an error or warning.
- Mount the saved entry by its mount point.
$ sudo mount /mnt/data
- Confirm that the persistent entry mounted the expected filesystem.
$ findmnt -M /mnt/data -o TARGET,SOURCE,FSTYPE,OPTIONS TARGET SOURCE FSTYPE OPTIONS /mnt/data /dev/sdb1 ext4 rw,relatime
A reboot stops running applications and disconnects remote sessions. Boot-time verification belongs in a maintenance window with console or recovery access available.
- Reboot the host during a suitable maintenance window.
$ sudo reboot
- Log back in after the host starts.
- Confirm that the data volume mounted automatically with the same filesystem UUID.
$ findmnt -M /mnt/data -o TARGET,SOURCE,FSTYPE,UUID,OPTIONS TARGET SOURCE FSTYPE UUID OPTIONS /mnt/data /dev/sdb1 ext4 fcc7979c-742b-43aa-9fe5-6a014e23496f rw,relatime
A row for /mnt/data with the expected UUID proves the boot-time mount. The device name may differ after a storage change; the filesystem UUID should match the value read earlier. An empty result means this mount point is not mounted.