╒══════╤══════╤═══════════╤═════════╕
 Home  Blog  Reference  Credits 
╘══════╧══════╧═══════════╧═════════╛


Mount a USB Drive on Start-Up on a Raspberry Pi

TAGS: usb, mount, raspberrypi

Excerpt

Add a USB drive to a Raspberry Pi that is mounted on start-up.

Pre-Requisites

Special Notes

Instructions

Step 1: Power on the Raspberry Pi

Step 2: Insert the USB Drive

Step 3: Find the USB Drive

lsblk

lsblk command to list connected block devices


Step 4: Get UUID of USB Drive

blkid /dev/sda1

blkid command to list information about usb device


Step 5: Create the Mount Folder

sudo mkdir /mnt/data1
sudo chmod 400 /mnt/data1
ls -ld /mnt/data1

Commands to create the mount folder


Step 6: Manually Mount the USB Drive to Test It

sudo mount /dev/sda1 /mnt/data1
sudo chmod 777 /mnt/data1
ls -ld /mnt/data1
touch /mnt/data1/test.txt
ls -l /mnt/data1/

Commands to manually mount the usb drive


Step 7: Mount USB Drive on Startup

Add the following line to /etc/fstab, replacing the UUID with the correct value found in step 4:

UUID=dc55cf20-4d5f-460a-991b-424a03934905  /mnt/data1  ext4  defaults,nofail,noatime  0  2


Step 7b: Add a Boot Delay if Needed

You can try to reboot your Raspberry Pi at this point, and it is very possible that your USB drive does not mount. This can be caused by the Raspberry Pi trying to mount the drive when the USB drive is not ready. We can solve this by putting a boot delay in.

Edit /boot/cmdline.txt and at the end of the line, append this text:

rootdelay=10

This causes a 10 second delay before booting, giving the USB drive time to power up and initialize.