Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to setup mount / auto-mount USB Hard Drive on Raspberry Pi

How to setup mount / auto-mount USB Hard Drive on Raspberry Pi

Follow the simple steps in the order mentioned below to have your USB drive mounted on your Raspberry Pi every time you boot it.

These steps are required especially if your are setting up a Samba share, or a 24x7 torrent downloader, or alike where your Raspberry Pi must have your external storage already mounted and ready for access by the services / daemons.

Step 0. Plug in your USB HDD / Drive to Raspberry Pi If you are using a NTFS formatted drive, install the following

sudo apt-get install ntfs-3g

Step 1. Log on pi using ssh terminal and execute:

sudo blkid

You will see something like the following:

lrwxrwxrwx 1 root root 10 Jan 1 1970 0AC4D607C4D5F543 -> ../../sda1 Note down the value of the UUID --> 0AC4D607C4D5F543

Step 2. Create a location for mount point:

sudo mkdir /mnt/volume

Give proper permission:

sudo chmod 770 /mnt/volume

Step 3. Get the uid, gid for pi user and group with id command (usually 1000)

Step 4. Mount the USB Drive and then check if it is accessible at /mnt/volume

sudo mount -t ntfs-3g -o nofail,uid=1000,gid=1000,umask=007 /dev/sda1 /mnt/volume


sudo mount /dev/sda1 /mnt/volume

Note: ntfs-3g for NTFS Drives vfat for FAT32 Drives ext4 for ext4 Drives

Step 5. Now, we will configure RasPi to do this after every reboot: Take a backup of current fstab and then edit

sudo cp /etc/fstab /etc/fstab.backup
sudo nano /etc/fstab

Add the mount information in the fstab file (replace UUID with your own):

UUID=0AC4D607C4D5F543 /mnt/volume ntfs-3g async,big_writes,noatime,nodiratime,nofail,uid=1000,gid=1000,umask=007 0 0


/dev/sda1 /mnt/volume ntfs defaults 0 0

Step 6. Reboot

sudo reboot

Step 8. (Optional, required if using as data storage for owncloud) If you are configuring ownCloud's data directory on your NAS drive, it should be having a 770 permission for www-data user. You can simply add user www-data to pi group, since its already having 770 as permission as set above in fstab.

sudo usermod -a -G pi www-data

Alternative 2

This is a short guide on how to connect an External Hard Drive to the Raspberry Pi! Most external Hard Drives are quite juicy and will require a USB Hub to run in a stable manner, so please do check this before trying to install your drive!

First step is to plug it in, and then switch on your Pi! It should boot up as normal, so go ahead and log in to Raspian as usual.

Step 1. Is it there?!

If you want to check for the current storage devices attached to your Pi, simply run the command:

sudo blkid

This reveals that we currently have our “Seagate Expansion Drive” attached.

Step 2. Check the Partitions

We now need to check the boot name of our Seagate’s partition.

sudo fdisk –l

Reveals that our drive is located at /dev/sda1

Step 3. Mounting it.

Now we know where our drive is, we need to mount it:

sudo mount /dev/sda1 /mnt/volume

The folder “/mnt” is the standard location for mounting permanent media, but you can always create your own folder if required using the “mkdir” command.

That’s it! Our drive is mounted.

Step 4. Permissions.

As our drive is formatted in NTFS, we might need to change the /mnt drive permissions in order to enable proper access. Simply run the following command:

sudo chmod 775 /mnt/volume

This will change your permissions and allow you to access the drive.

To test this, let’s try to create a folder. . .

cd /mnt/volume
sudo mkdir /IMAFOLDER

Great! So we can read and write to our hardrive!

Step 5. Automounting our drive.

If you want your Hard Drive to mount from boot, we need to set this up!

First step is to edit our "fstab" file

sudo nano /etc/fstab

This will open up the file in nano text editor:

We need to add the following line to have our hard drive mount at boot!

/dev/sda1 /mnt/volume ntfs-3g uid=1000,gid==1000,umask=007,nofail,x-systemd.device-timeout=30 0 0

You can now reboot your Raspbery Pi, and your Hard Drive will automatically mount!

Step 5. How to unmount.

To unmount the drive, simply run the command:

sudo umount /mnt/volume

As long as you’re not currently accessing the drive, it should unmount successfully.


This comment has been minimized.

Copy link

astewartau commented Feb 7, 2018

After adding the line

UUID=CA74-83DD /mnt/usb vfat uid=1000,gid=1000,umask=007 0 0

To my /etc/fstab file, my Raspberry Pi no longer boots. I will have to re-image it.


This comment has been minimized.

Copy link

simcha07 commented Feb 12, 2018

Same experience after adding this line
UUID=F43A-5DF2 /mnt/NASRPI exfat uid=1000,gid=1000,umask=007 0 0
sudo nano /etc/fstab

My Raspberry is not booting anymore.
New image of raspbian stretch was necessary


This comment has been minimized.

Copy link

KenaiFreex commented Feb 18, 2018

You need to add the nofail options if you want to automount external devices with fstab. You can use the ArchWiki like a Linux guide.


This comment has been minimized.

Copy link

Robert-Gustavsson commented Mar 2, 2018

@astewartau: That happened to me aswell. Luckily I had another Pi and an external SD card reader so I put the "dead" SD card into the other Pi and removed the offending fstab line. There is an option that can be added so the Pi continues the boot process after 90 seconds even if the mount can't be done.

UUID=CA74-83DD /mnt/usb vfat uid=1000,gid=1000,nofail,umask=007 0 0


This comment has been minimized.

Copy link

szymczaks0 commented May 13, 2018

This is such an irresponsible guide.


This comment has been minimized.

Copy link

kfrncs commented Jun 25, 2018

just chiming in:

using the following format in fstab I got it working successfully:

/dev/sda1 /mnt/volume ntfs defaults 0 0

I also added nofail and x-systemd.device-timeout=1 as per the Arch wiki.


This comment has been minimized.

Copy link

bernd-wechner commented Jul 14, 2018

Totally the same experience. Followed this Pi wouldn't boot. Used this in /etc/fstab instead:

/dev/sda1 /media/USBdrive ext4 defaults,nofail,x-systemd.device-timeout=1,noatime 0 0

and it works a charm. Note of course that I formatted my USB drive ext4, as it's a permanent fixture with my pi and I have no need or desire to move it, and even if I did, well my whole home LAN is Linux based and I got no probs with ext4 format drives.


This comment has been minimized.

Copy link

spoutnik16 commented Aug 7, 2018

this is an insanely stupid guide.
if you follow it, it doesn't work and your have to reinstall your raspberry from scratch.


This comment has been minimized.

Copy link

andi-rpi3 commented Aug 7, 2018

Hey guys!

Is there any tool/code to check the edit fstab before reboot (and in worst case, fail start)?



This comment has been minimized.

Copy link

helderc commented Aug 10, 2018

This tutorial works fine. It is not stupid as some are saying!
To avoid the boot fail you must to add the nofail parameter as I did below:

UUID=6C7A421A7A41E186 /mnt/HD_Ext ntfs async,big_writes,noatime,nodiratime,nofail,uid=1000,gid=1000,umask=007 0 0

Keep in mind that if its not working, or giving some errors, just restore the backup!


This comment has been minimized.

Copy link

benfleuty commented Oct 3, 2018

To those having issues: XXXX-XXXX is a partial UUID, not the full UUID. Use the full UUID.


This comment has been minimized.

Copy link

jrodriguez6 commented Oct 21, 2018

Trying to add a WD 1 TB Passport to Raspberry Pi 3B, Got to Step 4: Got Denied:
pi@jgrpi:~ $ sudo mount -t ntfs-3g -o uid=1000,gid=1000,umask=007 /dev/sda1 /mnt/volume
Mount is denied because the NTFS volume is already exclusively opened.
The volume may be already mounted, or another software may use it which
could be identified for example by the help of the 'fuser' command.
pi@jgrpi:~ $ sudo mount /dev/sda1 /mnt/volume
Mount is denied because the NTFS volume is already exclusively opened.
The volume may be already mounted, or another software may use it which
could be identified for example by the help of the 'fuser' command.

What do I do Next? Thanks
I'm trying to Create an FTP Sever to work with a WiFi Security Cam as a Cloud Drive.

Please Help I'm Lost I have no Idea how this works.


Retired USAF SMSgt


This comment has been minimized.

Copy link

jrodriguez6 commented Oct 21, 2018

Great News I think - I tried Alternative 2 -
pi@jgrpi:~ $ sudo blkid
/dev/mmcblk0p1: SEC_TYPE="msdos" LABEL="boot" UUID="0298-4814" TYPE="vfat" PARTUUID="0d6038a7-01"
/dev/mmcblk0p2: LABEL="rootfs" UUID="d4f0fd64-ad9d-4cfd-aa76-8d3541fbf008" TYPE="ext4" PARTUUID="0d6038a7-02"
/dev/mmcblk0: PTUUID="0d6038a7" PTTYPE="dos"
/dev/sda1: LABEL="My Passport - Joe III" UUID="14BA60A2BA6081DA" TYPE="ntfs" PARTUUID="d0a87c9b-01"

Does this mean the Drive is Mounted???

I want to make sure the drive loads even after a Power Failure.




This comment has been minimized.

Copy link

xkdcc commented Dec 10, 2018

To revert the fstab withouth re-imaging or use another raspberry pi, if you are using NOOBS and have a monitor/kb connected to your pi, press shift to go to recovery mode at boot time:

  1. Edit cmdline.txt and add the following parameter at the end of the line:init=/bin/sh
    Then ESC, you will be dropped into a shell.
  2. Run mount -o remount,rw / and vi /etc/fstab and comment out the offending line and save it.
  3. Then run sync and do a reboot.
  4. Go to recovery mode to remove init=/bin/sh from cmdline.txt, press ESC once you're done.
  5. Now you should be able to boot your pi again.



This comment has been minimized.

Copy link

tamasbalassa commented Dec 27, 2018

Addig "nofail" worked for me. Thanks!


This comment has been minimized.

Copy link

leofuscaldi commented Jan 24, 2019

worked for me. you have to use FULL UUID, not only partial!


This comment has been minimized.

Copy link

filRocha commented Mar 9, 2019

It is indeed a good step-by-step. Thank you, it worked for me after trying many other tutorials.
The only thing to do is add nofail in the fstab command, just like other colleagues said.


This comment has been minimized.

Copy link

F1XM4J commented Mar 12, 2019

I had the same problem, I followed this and it would not boot anymore, but I managed to get it back doing the following

  1. Hold shift on you Pi bootscreen, it will bring you to NOOBS config screen
  2. Add init=/bin/sh to cmdline.txt (this line is a 1 line text file, DO NOT ADD A NEW LINE, simply write "init=/bin/sh" (without the quotes) somewhere in the file
  3. Reboot
  4. From there, the Pi is in read only since the file system has not been mounted properly, so run the command
    mount -o remount,rw /
  5. Now, you should be able to edit the fstab, so 'nano /etc/fstab'. Either you remove the line that caused your Pi to fail or you add 'nofail,x-systemd.device-timeout=1' in the mount options of your external drive (this worked for me)
  6. Reboot your Pi and hold Shift on the splashscreen again because you will want to remove that 'init=/bin/sh' line
  7. Reboot your Pi and enjoy the feeling of not loosing everything you had on there

This comment has been minimized.

Copy link

ricardolopes86 commented Mar 23, 2019

I had the same problem of Pi not booting anymore with another guide.
This answer helped me to prevent it once again:

If you're stuck and your Pi isn't booting. Just power off, put the microsd on an adapter and mount it on a Linux machine, then you'll be able to change the /etc/fstab file to add the nofail option to prevent not booting anymore.



This comment has been minimized.

Copy link

totial commented May 17, 2019

In case someone breakes the boot up ot the raspberry avoid reinstalling raspbian from scratch by placing the microSD card into another computer and changing the /etc/fstab by removing the added line to make it the default. I saw lots of ppl doing a reimage when its not necessary. Hope it saves your time ;)


This comment has been minimized.

Copy link

rockwotj commented Aug 4, 2019

sudo findmnt --verify --verbose is the best way I've found the verify fstab.


This comment has been minimized.

Copy link

wgranicki commented Oct 17, 2019

I need to point out, that
cd /mnt/volume
sudo mkdir /IMAFOLDER
does not do what you say it does.

It creates a folder in /, not in /mnt/volume.
What you're looking for is:
cd /mnt/volume
sudo mkdir IMAFOLDER
or just
sudo mkdir /mnt/volume/IMAFOLDER
ls -l /mnt/volume

EDIT: But, the whole "Step 4. Permissions." doesn't make much sense. As root (you're using sudo here), you will always have access to /mnt and underlying folders. If you want to be able to access it as standard user, you either need to allow it in full for all users, e.g.
sudo chmod 777 /mnt/volume
or change ownership to your user and then set correct permissions, e.g.
sudo chown your_username:your_groupname /mnt/volume
sudo chmod 750 /mnt/volume
(to find your_username and your_groupname, use id)

So, effectively, you should be able to do
mkdir /mnt/volume/IMAFOLDER
without sudo. That's when you know, you have the right permissions (confirm with ls -l /mnt/volume if you want).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.