Mount USB Flash Disk On Raspberry Pi - ajumalp/rpi-nas GitHub Wiki

  • 1st we need to Identify The Devices Unique ID. In order to find the unique reference (UUID) for your drive run the following command in the terminal
ls -l /dev/disk/by-uuid/ 
  • The line will usually refer to /sda
  • Now we need to create a Mount Point. A mount point is a directory that will point to the contents of your flash drive. Create a suitable folder
  • Run this command to create a mount point for your usb
sudo chown -R pi:pi /media/usb
  • Manually Mount The Drive. To manually mount the drive use the following command
sudo mount /dev/sda1 /media/usb -o uid=pi,gid=pi
  • Un-mounting The Drive. You don’t need to manually un-mount if you shutdown your Pi but if you need to remove the drive at any other time you should un-mount it first. Only the user that mounted the drive can un-mount it.
  • Use this command to unmount drive
sudo umount /media/usb
  • Auto Mount. When you restart your Pi your mounts will be lost and you will need to repeat Step 4. If you want your USB drive to be mounted when the system starts you can edit the fstab file
sudo nano /etc/fstab
  • Then add the following line at the end
UUID=18A9-9943 /media/usb vfat auto,nofail,noatime,users,rw,uid=pi,gid=pi 0 0
  • where UUID is the ID of the drive you got from 1st step [by running ls -l /dev/disk/by-uuid/]
  • The “nofail” option allows the boot process to proceed if the drive is not plugged in. The “noatime” option stops the file access time being updated every time a file is read from the USB stick. This helps improve performance.
  • An Extra Note About File Systems. In the examples above I specified “vfat” as the file system of the device as it was formatted as FAT32. If you need to change the file system replace references of “vfat” with “ntfs-3g”, “ext3” or “ext4”.
  • If you are using NTFS you will also need to install the following package
sudo apt -y install ntfs-3g