Always Mount Drives Reliably with UUIDs or Labels.
Avoid relying on /dev/sdX. Use UUID or LABEL in /etc/fstab for stable mounts. Label drives, test mounts, and your drives will remain consistently accessible, preventing broken scripts and automount issues.
If your USB drive or disk partition keeps changing from /dev/sdc2 to /dev/sdd2 (or another device name), this guide explains why it happens and how to fix it properly.
Why /dev/sdX Keeps Changing
Linux assigns device names dynamically.
Relying on /dev/sdX is therefore unreliable.
Common causes include:
- Dynamic device enumeration
During boot, Linux scans drives and assigns letters based on detection order. Adding or removing drives can change the assignment. - Hotplugging USB devices
Unplugging and re-plugging a USB drive may assign it a new device node. - Multiple controllers or card readers
Different USB ports or hub configurations can cause the same drive to appear under a different name.
⚠️ Warning: Using /dev/sdX in scripts, automounts, or rules can lead to broken mounts.
Use Persistent Identifiers
Instead of /dev/sdX, use:
- UUID (Universally Unique Identifier): Unique per filesystem.
- LABEL: A human-readable name assigned to the filesystem (optional).
These identifiers are stable and do not change, regardless of which /dev/sdX is assigned.
Find the UUID or Label
Using lsblk
$ lsblk -f
Example output:
NAME FSTYPE LABEL UUID MOUNTPOINT
sdc2 ext4 DATA a1b2c3d4-5678-90ef-1234-567890abcdef
- UUID:
a1b2c3d4-5678-90ef-1234-567890abcdef - Label:
DATA(optional)
Using blkid
$ sudo blkid /dev/sdc2
Example output:
/dev/sdc2: UUID="a1b2c3d4-5678-90ef-1234-567890abcdef" TYPE="ext4" PARTUUID="12345678-02"
Create the Mount Point
Before mounting, create the directory where the drive will be attached:
$ sudo mkdir -p /mnt/data
- Replace
/mnt/datawith any directory you prefer. - Ensure the directory is empty; otherwise, files already in it may become inaccessible while the drive is mounted.
Edit /etc/fstab for Stable Automount
Instead of using /dev/sdX, use the UUID:
UUID=a1b2c3d4-5678-90ef-1234-567890abcdef /mnt/data ext4 defaults 0 2
Optional: Mount by label:
LABEL=DATA /mnt/data ext4 defaults 0 2
Notes:
defaultsuses standard mount options.0 2sets the filesystem check order at boot (usually fine for most drives).
Test the Mount
After editing /etc/fstab, test it:
$ sudo mount -a
- No output means success.
Verify the mount:
$ df -h | grep /mnt/data
If you see the drive mounted, everything is working as expected.
Extra Tips
- Label your drives for easier identification:
$ sudo e2label /dev/sdc2 DATA # For ext4
$ sudo dosfslabel /dev/sdc1 MYUSB # For FAT32
- Avoid
/dev/sdXin scripts — always use UUID or LABEL. - For hotplugged drives, consider using udev rules or systemd automount.
- Check active mounts with:
findmnt
df -h
Always use UUID or LABEL instead of /dev/sdX for stable, persistent mounts. Properly configuring /etc/fstab and labeling drives prevents broken mounts, ensures consistent access, and keeps scripts and automounts reliable.