Mount a USB drive persistently for all users
Table of Contents
I need to persistently permit all users read/write access to a USB drive
Create a mount point
mkdir /mnt/usb500
List devices
lsblk -o NAME,FSTYPE,LABEL
NAME FSTYPE LABEL
sda
└─sda1 ext4 usb500gb
mmcblk0
├─mmcblk0p1 vfat boot
└─mmcblk0p2 ext4 rootfs
Backup & print current fstab
cp /etc/fstab ~/fstab.bak
cat /etc/fstab
proc /proc proc defaults 0 0
PARTUUID=45eaad39-01 /boot vfat defaults 0 2
PARTUUID=45eaad39-02 / ext4 defaults,noatime 0 1
Add the device to fstab
Hint: nofail
do not report errors for this device if it does not exist. You
may boot without the drive.
echo "\n/dev/sda1 /mnt/usb500 ext4 user,rw,nofail" >> /etc/fstab
Change device’s permission
mount -a
sudo chmod 777 /mnt/usb500/
Test
Reboot
sudo reboot
Write into a temporary file
cd /mnt/usb500/
echo 'foo' > bar.txt
cat bar.txt
rm bar.txt
foo
Cleanup
After you thoroughly tested everything remove leftovers
rm ~/fstab.bak
Troubleshooting
You attached the drive after booting
sudo mount -a