Mount a USB Drive to a Raspberry PI
This guide will show you how to Mount a USB Drive to a Raspberry PI for extra Storage For using on a Plex server or a NAS
PI OS will automatically mount a USB Drive which will be fine for most cases however for use on a plex server mounting it so you can access the directory to copy media is important
So first we need to find out which drives are attached and what they are called
In the terminal or from a SSH Session run
df -h
You will see above that we have 2 USB Drives
They are /dev/sda1 and /dev/sdb1 (the first USB drive is always sda1 and subsequent drives sbd1, sdc1 and so on
If i had an SD Card installed then it would show as /dev/mmcblk0p1, but as this guide is mainly for a plex server i will assume that going forward you already have the server set to boot from USB (sda1)
So from the List above we have the /dev/sdb1 mounted on /media/pi/Ashur DT2
Run
sudo blkid /dev/sdb1
this gives me
/dev/sdb1: LABEL=”Ashur DT2″ UUID=”B054-1193″ BLOCK_SIZE=”512″ TYPE=”exfat” PARTLABEL=”Basic data partition” PARTUUID=”98105283-2349-4596-bb2b-f5cd61a3e7e0″
Yours will be slightly different depending on the drive but all you need is the following (take a note of these)
UUID=”B054-1193
And
TYPE=”exfat”
If your drive type is exfat or NTFS then you will need to install the appropriate steps below if its not then you can skip to Mounting the Drive
exfat
to install exfat support install these 2 packages
sudo apt install exfat-fuse
sudo apt install exfat-utils
NTFS
sudo apt install ntfs-3g
Mounting the Drive
Create a folder , in this example we will use usb1 but you could name it anything
sudo mkdir -p /mnt/usb1
Give the user ownership of the folder , we will use the user pi as the example
sudo chown -R pi:pi /mnt/usb1
Now edit the fstab file
sudo nano /etc/fstab
add to the bottom of the fstab file you are editing
UUID=UUID /mnt/usb1 TYPE defaults,auto,users,rw,nofail,noatime 0 0
Bear in mind that the UUID and TYPE are what you listed down above
so using the above examples it would be
UUID=B054-1193 /mnt/usb1 exfat defaults,auto,users,rw,nofail,noatime 0 0
Now unmount the drive
sudo umount /dev/sdb1
you can then mount it again but now it will mount to what you chose earlier (/mnt/usb1)
sudo mount -a
Now if you reboot the PI the drive should mount automatically
sudo reboot
To check when rebooted run
df -h
this time the /dev/sdb1 drive should be mounted to /mnt/usb1
If the drive does not automatically mount then its possible the drive was not awake in time for it to be mounted
if that is the case then adding a small sleep time to the /etc/rc.local file
sudo nano /etc/rc.local
Add the lines below above the line exit 0
sleep 20
sudo mount -a
Of course if the line sudo mount -a is already there you dont need to add it a second time just add the sleep 20 above it