Skip to content

Instantly share code, notes, and snippets.

@5a494d
Created January 3, 2019 22:41
Show Gist options
  • Save 5a494d/5cf59d812b1cf070457cfd5c99a70b05 to your computer and use it in GitHub Desktop.
Save 5a494d/5cf59d812b1cf070457cfd5c99a70b05 to your computer and use it in GitHub Desktop.
Deluged for RaspberryPI 2

Automounting USB Drives

Identify the drive, in this case it's /dev/sda1 with a UUID of E033-1109 and type FAT:

Input

$ sudo blkid

Output

# /dev/sda1: LABEL="ELEMENTS" UUID="E033-1109" TYPE="vfat"

Create a dir it will be mounted at:

sudo mkdir /mnt/usbel 

Own it:

sudo chown -R pi:pi /mnt/usbel  

You could manually mount it

sudo mount -o uid=pi -o gid=pi -t vfat /dev/sda1 /mnt/usbel  

But let's auto-mount it instead:

sudo vim /etc/fstab  

Add add the following line to the bottom, it should all be on one line:

UUID=E033-1109 /mnt/usbel vfat auto,users,rw,uid=1000,gid=100,umask=0002 0 0  

We're mounting the drive by its UUID to ensure we always get the correct drive. We're setting rw to allow read-write permissions, uid=1000 sets the user to "pi" (see the id command), gid=100 sets the group to "users" (again, see the id command) and umask=0002 sets rwxrwxr-x permissions on the mount.

For more details on the possible permissions, see What is umask and fstab permissions explained.

We can reapply our mounts with sudo mount -a before we sudo reboot.

I had issues where this just wouldn't mount on reboot. I'd have to sudo mount -a manually. I found a few different threads where Raspberry Pi 2 users were encountering the same issues, which seems to be caused by a bug in Linux/Debian. A permanent fix will apparently be in Debian's "Jessie" release, but until then adding a delay works to give the USB drive to initialise:

sudo vi /mount/cmdline.txt  

Add to the end (others report 5 works, but I needed to up it to 10):

rootdelay=10  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment