This site runs best with JavaScript enabled.

Automatically mount a drive on your Raspberry Pi

Post status

seedling

planted Jun 08, 2021


You should configure your Pi to automatically mount your drive on start-up. This avoids your data being missing after a reboot and having weird side effects.

The automount is handled in the fstabfile on your Pi.

You can modify the fstab file to define the location where the storage device will be automatically mounted when the Raspberry Pi starts up. In the fstab file, the disk partition is identified by the universally unique identifier (UUID).

  1. Get the UUID of the disk partition:
sudo blkid
  1. Find the disk partition from the list and note the UUID. For example, 6099-9F76.
  2. Open the fstab file using a command line editor such as nano:
sudo nano /etc/fstab
  1. Add the following line in the fstab file:
UUID=5C24-1453 /mnt/mydisk fstype defaults,auto,users,rw,nofail 0 0

Replace fstype with the type of your file system, which you found in step 2 of 'Mounting a storage device' above, for example: ntfs. 5. If the filesystem type is FAT or NTFS, add ,umask=000 immediately after nofail - this will allow all users full read/write access to every file on the storage device.

Now that you have set an entry in fstab, you can start up your Raspberry Pi with or without the storage device attached. Before you unplug the device you must either shut down the Pi, or manually unmount it using the steps in 'Unmounting a storage device' below.

Note: if you do not have the storage device attached when the Pi starts, the Pi will take an extra 90 seconds to start up. You can shorten this by adding ,x-systemd.device-timeout=30 immediately after nofail in step 4. This will change the timeout to 30 seconds, meaning the system will only wait 30 seconds before giving up trying to mount the disk.

Links to this post:

Use an external SSD for your PhotoPrism instance

You should add an external drive to your PhotoPrism instance, because otherwise it will put all data on the SD card. I… Read this post ›

Configure PhotoPrism to use an external drive

This post explains how to configure your own PhotoPrism instance to use an external hard drive. To use an external drive… Read this post ›

Sebastian Auner © 2023