The
fstab(file system table) file tells Linux which storage devices to mount at boot and where to place them in the directory tree. This guide walks you through mounting an external drive permanently using UUIDs, a robust method that survives reordering or renaming of device paths.
Page
Mounting an External Drive Using fstab
Prerequisites ๐
- A connected external hard drive (USB, SATA via enclosure, etc.)
- Root/sudo access to your Linux system
- Basic familiarity with the terminal and text editors (
nano,vim)
๐ก Tip: Always back up
/etc/fstabbefore editing. One typo can prevent booting.
Step 1: Identify Your Drive ๐
Find Available Drives
List all block devices and their current mount points:
lsblk -f
Look for your external drive (e.g., /dev/sdb, /dev/nvme0n1p2). Note the UUID, filesystem type, and partition name.
Alternative: Use `blkid`
For detailed UUIDs:
sudo blkid /dev/sdXN # Replace sdXN with your drive (e.g., sdb1)
Output example:
/dev/sdb1: UUID="a1b2c3d4-e5f6-7890-abcd-ef1234567890" TYPE="ext4"
Step 2: Create a Mount Point ๐
Create an empty directory where the drive will be accessible:
sudo mkdir -p /mnt/external-drive
The -p flag creates parent directories if needed.
โ Best Practice: Use descriptive names like
/mnt/data,/mnt/backups, or/mnt/media. Avoid spaces in paths.
Step 3: Test Mounting Manually ๐งช
Before editing fstab, test that the drive mounts correctly:
sudo mount /dev/sdXN /mnt/external-drive
Check if it works:
df -h | grep external-drive
lsblk
If successful, unmount to proceed:
sudo umount /mnt/external-drive
Step 4: Edit `/etc/fstab` โ๏ธ
Open the file with a text editor (use nano for simplicity):
sudo nano /etc/fstab
Add a new line at the end using this format:
UUID=a1b2c3d4-e5f6-7890-abcd-ef1234567890 /mnt/external-drive ext4 defaults,nosuid,nodev,noatime 0 2
Field Breakdown:
| Column | Description |
|---|---|
| UUID | Unique identifier for the partition (most reliable) |
| Mount Point | Directory where drive will be mounted (/mnt/external-drive) |
| Filesystem Type | ext4, ntfs-3g (for NTFS), vfat, etc. |
| Options | Comma-separated flags like defaults,nosuid,nodev,noatime |
| Dump | Usually 0 for non-root drives (1 rarely used) |
| Pass Order | Filesystem check order at boot; use 2 for data drives, 1 only for root |
Common Options:
defaults: Standard options (rw, suid, dev, exec, auto, nouser, async)noatime: Improves performance by skipping access time updatesnosuid,nodev: Prevents special permissions on the mount pointuser,noauto,rw,syncโ For removable drives mounted manually (not in fstab at boot)defaults,dmask=022,fmask=133,uid=1000,gid=1000โ NTFS-specific for ownership/permissions
โ ๏ธ NTFS Note: If mounting an NTFS drive (common with Windows dual-boot), use the filesystem type
ntfs-3g. Install it first if missing:
# Debian/Ubuntu
sudo apt install ntfs-3g
# Arch/Fedora
sudo pacman -S ntfs-3g
Step 5: Verify and Test โ
Reload fstab without rebooting:
sudo mount -a
If no errors appear, your entry is valid. Check the drive is mounted:
df -h | grep external-drive
mount | grep /mnt/external-drive
Step 6: Reboot and Confirm ๐
Reboot to ensure automatic mounting works at boot:
sudo reboot
After restart, verify the drive is mounted automatically.
Troubleshooting ๐ง
Issue: Boot Hangs in Emergency Mode โ
Cause: Typo or invalid UUID in /etc/fstab
Fix:
- Reboot and drop into emergency mode (or use a live USB)
- Remount root as read-write:
mount -o remount,rw / - Edit
fstab:nano /etc/fstab - Comment out the problematic line with
#or correct it - Reboot:
reboot
Issue: Drive Not Mounting After Boot ๐ซ
Check:
- Is UUID correct? Run
sudo blkidagain. - Are options valid for your filesystem?
- Does the mount point exist and have permissions:
ls -ld /mnt/external-drive sudo chown $USER:$USER /mnt/external-drive
Issue: NTFS Drive Shows Read-Only ๐
Cause: Windows "Fast Startup" leaves the drive in a dirty state.
Fix:
- Boot into Windows and perform a full shutdown (not restart)
- Or use
ntfsfixfrom Linux:sudo ntfsfix /dev/sdXN - Remount with proper options in fstab.
Quick Reference Table ๐
| Scenario | Filesystem Type | Example Options |
|---|---|---|
| Linux ext4 data drive | ext4 |
defaults,nosuid,nodev,noatime |
| NTFS Windows partition | ntfs-3g |
defaults,uid=1000,gid=1000,dmask=022,fmask=133 |
| FAT32 USB stick (removable) | vfat |
user,noauto,rw,sync,dmask=022,fmask=133 |
Final Checklist โ
- Drive identified with correct UUID via
blkid - Mount point created (
/mnt/...) - Manual mount tested successfully
-
/etc/fstabentry added and validated withmount -a - Rebooted to confirm automatic mounting
- Backup of original fstab saved (e.g.,
cp /etc/fstab /etc/fstab.bak)
With this setup, your external drive will mount automatically at boot, accessible without password prompts or manual intervention. ๐