Mount external drive on linux
Writing this down so I don’t have to remember.
Find the drive
lsblk -f
Look for partition (usually sda1) with FSTYPE ext4, and note its UUID.
Create a mount point
sudo mkdir -p /mnt/sata
Mount it manually to test
sudo mount /dev/sda1 /mnt/sata
ls /mnt/sata
existing data should be listed. If you get an error about a bad superblock or “wrong fs type”, check lsblk -f again to make sure you’re using the right partition (not sda itself), and see dmesg | tail -20 for details.
Mount it automatically at boot
Get the UUID:
sudo blkid /dev/sda1
Edit fstab:
sudo nano /etc/fstab
Add this line at the bottom, using own UUID:
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /mnt/sata ext4 defaults,noatime,nofail 0 2
Save with Ctrl+O, Enter, then exit with Ctrl+X. The nofail option stops Raspberry Pi from dropping into emergency mode if the drive isn’t connected at boot.
Test the fstab entry
sudo umount /mnt/sata
sudo systemctl daemon-reload
sudo mount -a
df -h /mnt/sata
No errors and the drive listed means it’s working. Reboot once (sudo reboot) to confirm it mounts on its own.
Check permissions
Existing files keep the ownership they had on the drive’s original system. If user can’t read or write them, check with ls -l /mnt/sata. The drive’s files may belong to a user ID that differs from Pi user (check s with id). To take ownership of everything:
sudo chown -R $USER:$USER /mnt/sata
Only do this if you don’t need to preserve the original ownership (for example, if the drive came from another Linux machine with different users and you don’t plan to move it back).
Safely removing the drive
sudo umount /mnt/sata
If the drive disconnects randomly or is slow, the likely causes are insufficient USB power (use a powered hub) or a UAS quirk with the adapter.