Mount a Labeled Drive Like Backup
Luke Hebert
- 2 minutes read - 401 wordsMounting a drive by its filesystem label instead of a device path like /dev/sdb1 keeps your /etc/fstab entries stable even when the kernel reassigns device names after a reboot or a hardware swap. This approach is especially handy for backup drives that you plug into different ports or controllers.
Setting a Label on Your Filesystem
Before you can reference a label, the filesystem needs one. For an ext3 or ext4 partition, use e2label:
sudo e2label /dev/sdb1 backup1For an XFS partition, use xfs_admin:
sudo xfs_admin -L backup1 /dev/sdb1Verify the label with blkid:
sudo blkid /dev/sdb1You should see output that includes LABEL="backup1".
Adding the fstab Entry
Create or edit /etc/fstab and add a line that references the label:
LABEL=backup1 /backup ext3 defaults 1 2| Field | Value | Meaning |
|---|---|---|
| 1 | LABEL=backup1 | Filesystem label to mount |
| 2 | /backup | Mount point on the local system |
| 3 | ext3 | Filesystem type |
| 4 | defaults | Standard mount options |
| 5 | 1 | Dump frequency (1 = yes) |
| 6 | 2 | fsck pass number |
Make sure the mount point directory exists before rebooting:
sudo mkdir -p /backupTesting the Entry
Always validate your fstab changes before a reboot to avoid a broken boot:
sudo mount -aIf that command returns without errors, your entry is good. You can then confirm the mount with:
df -h /backupWhy Labels Beat Device Paths
- Stable across reboots.
/dev/sdb1can become/dev/sdc1if you add or remove a disk. - Portable across ports. A USB drive plugged into a different controller gets a new device name but keeps its label.
- Readable.
LABEL=backup1tells the next admin exactly what the partition is for.
The label must be unique on the system. If two filesystems share the same label, mount -a will fail with an ambiguous reference error.
Quick Troubleshooting
mount: unknown filesystem type– Double-check the filesystem type in field 3 against whatblkidreports.mount: /backup: bad superblock– The label exists but the filesystem is corrupted. Runfsckon the underlying device.- Label not found – Confirm the label with
sudo blkidand make sure there are no trailing spaces in yourfstabline.
Using LABEL= in /etc/fstab is a small change that saves you from the classic “my backup drive is now /dev/sdc1” headache. Set the label once, write the entry, and your mount point stays put no matter what the kernel decides to call the device.