Raspberry Pi Tutorials

Share this article:

(work in progress)

A. How to mount a USB hard drive

1. First, plugin and then locate the drive:

sudo fdisk -l

In this example output, I mounted a 256GB SD CARD with the help of a USB adapter:


2. Created a mounted location:

sudo mkdir /media/backup-drive

3. Prepare the SD CARD partition

Warning: this will wipe all data on card!

Identify the device name and run the following command:

sudo mkfs.ext4 /dev/sda

4. Mount the card

Change this command according to your device name and the folder that you created:

sudo mount /dev/sda /media/backup-drive

5. Change user ownership

Change user ownership to allow pi to access the drive:

sudo chown pi:pi backup-drive

6. Find the disk ID

Type the following command:


Expected output:

If your storage device uses an NTFS file system, you will have read-only access to it. If you want to write to the device, you can install the ntfs-3g driver:

sudo apt update
sudo apt install ntfs-3g

7. confirm the device name


sudo blkid

Expected result:

8. Setup automatic mounting

Once PI is restarted, you want the device to automatically get mounted. Open the fstab file:

sudo nano /etc/fstab

And add to it a line in the following format:

[Device] [Mount Point] [File System Type] [Options] [Dump] [Pass]

For our case, it is:

UUID=5f4bccbc-1fbe-4400-bd3e-a1473c65f501 /media/backup-drive ext4 defaults,auto,users,rw,nofail 0 0

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.

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. This will change the timeout to 30 seconds, meaning the system will only wait 30 seconds before giving up trying to mount the disk.

Share this article:



You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *