fstab - hdd/ssd auto mounting
Want to mount a USB drive on boot? here is how.
Generic helpers
Debug connected USB controllers with
lsusb
Get hard drive id with
blkid
Edit auto mount information in
sudo nano /etc/fstab
Create a backup of your fstab
with
sudo cp /etc/fstab /etc/fstab.backup
Auto drive mount ext4
Into /etc/fstab
UUID=d1724867-ce93-4656-90f3-1bdda6722371 /media/hdd ext4 defaults,nobootwait 0 0
DO NOT HAVE SPACES BETWEEN THE COMMAS!
❌ -> ✅ defaults, nobootwait
defaults,nobootwait
Auto drive mounting NTFS partition
sudo apt-get install ntfs-3g
sudo mkdir /mnt/disk15
sudo chmod 770 /mnt/disk15
# Test mounting
sudo mount -t ntfs-3g -o umask=777 /dev/sda1 /mnt/disk15
### Into /etc/fstab:
# ntfs 777 - not the best.
UUID=[BLK_ID] /mnt/disk15 ntfs-3g nobootwait,umask=777 0 0
# ntfs with proper masking
UUID=770bcbdc-01 /mnt/usbhdd ntfs-3g nobootwait,auto,exec,rw,user,dmask=002,fmask=113,uid=1000,gid=1000 0 0
Note: nobootwait
is there to prevent halting if mounting failed.
Drive idle spin-down
For mechanical disks rarely used e.g. for backup purposes, you may want to consider spinning them down while you are not using them. You can achieve this using hdparm
- default settings should work just fine.
sudo apt-get install hdparm
Fine tuning:
hdparm -S 120 /dev/sda
Get current status:
hdparm -C /dev/sdX
How to mount manually
### HDD list
lsblk
### userId (uid=1000)
id
### Run to target
sudo mount -o rw,exec,uid=1000,user /dev/nvme0n1p3 /media/symunona/t4
Test your mount with
sudo mount -a
This re-mounts everything in fstab
!
No uuid is needed, it's ok to just have the resource path:
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/nvme0n1p3 /media/user/data r rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,iocharset=utf8,errors=remount-ro,uhelper=udisks2 0 0
linux
raspberry pi
hard drive
fstab