How to mount a USB drive on the Raspberry Pi?

Mounting a USB drive can become a real headache and maybe a waste of time, especially if you are new on Raspberry Pi and Linux commands.
Today, I’ll give you all the exact information you need to mount a USB drive quickly and easily.

How to mount a USB drive on the Raspberry Pi?
Use the “mount” command to do this manually: sudo mount /dev/sda1 /mnt/usb.
The /etc/fstab file can also be edited for an automatic mount on startup.

There are plenty of options for both cases.
So, in this post I’ll explain how to connect your USB key or drive without having to remember 50 parameters 🙂

We’ll see the manual way (for temporary devices) and the automatic way for devices you want to often use on your Raspberry Pi (like your Retropie ROMs, movies or backup storage drive).

I answer your questions - Raspberry...
I answer your questions - Raspberry Pi FAQ

Get information about the USB drive

Download the Pi Glossary!
If you are lost in all these new words and abbreviations, request my free Raspberry Pi glossary here (PDF format)!

Before going further, we need to collect information about your hard drive, like the identifier and the file system type used on it.
We’ll also create a new folder to mount the drive in it.

Prepare your Raspberry Pi

There are not many requirements.
You can follow this tutorial with any Raspberry Pi OS version, and nearly any Linux distributions.

I’ll suppose you’re on Raspberry Pi OS Lite. If you have a Desktop, maybe you’ll get the help of the interface for some steps, but no big change.

Start by updating your system:
sudo apt update
sudo apt upgrade

Raspberry Pi Bootcamp
Sale: 10% off today.
Take it to the next level.
I'm here to help you get started on Raspberry Pi.
Learn all the skills you need in the correct order.

And if you are working with NTFS drives, check that you have the required package installed (NTFS is mainly for Windows devices and may not be required in your case).

sudo apt install ntfs-3g

Plug your device

This step is easy 🙂
Plug your device to a free USB port.

For big external drives, you will need extra power to run the drive correctly (“Under-voltage detected!” will appear in the terminal).
Try to add a powered USB hub to the Raspberry Pi (check this one on Amazon for example if you don’t already have one). Your hard drive will not work without that (except if it has its power supply).
Plug the hub to the Raspberry Pi and your hard drive directly on the hub.

Collect more information

Once you plug the disk, we need to know more about this one before going further.


Fdisk is a tool to manage disks on Linux.
We’ll use it to display all disks and find your USB drive.

Start with this command:
sudo fdisk -l

At the end of the displaying lines, you should get something like this:
fdisk command output

  • First thing, be sure you’re checking the disk you want to mount
    Mainly check the size of the drive to know if this is the good one (in this case I plugged a 8Go USB key, so I’m sure it is this one)
    If not sure, unplug it and run the command again to see which one disappear 🙂
  • Then remember two things:
    • The filesystem format type: here it’s FAT32, it could be NTFS or EXT4 for example
    • The device name: here it’s /dev/sda1, we’ll need this later


Another information that could help us later is the UUID.
When you format a disk, the system assign an ID to the disk.
We call this the UUID. This allows us to know this a known drive and do something specific when you plug it on your Raspberry Pi.

To get this UUID, run this command:
sudo ls -l /dev/disk/by-uuid/

You’ll get something like this:
get disk uuid

Find the line corresponding to your drive name (sda1 for example).
Note the UUID just before the drive name (it could be longer depending on your disk).

Create the mount point

Master your Raspberry Pi in 30 days
Sale: 10% off today.
Download the eBook.
Uncover the secrets of the Raspberry Pi in a 30 days challenge.
Learn useful Linux skills and practice multiples projects.

We are almost ready.
On Linux systems you need to create a new folder to mount the drive in it later.
Generally, we create it in /mnt or /media.

Create the directory:
sudo mkdir /mnt/usb

We are ready with prerequisites.

Now, we can mount the USB drive with two methods:
– manually: for fast access on temporary devices
– automatically: need more configuration to start, but this will be automatic next times

Manually mount the USB drive

In this part, we’ll see how to mount a USB drive quickly on the Raspberry Pi.

The mount command

The mount command allows us to mount a device on a specific folder.
In my case, I want to mount /dev/sda1 to /mnt/usb.

The command syntax is this:
sudo mount <DEVICE> <FOLDER> -o <OPTIONS>

So in my case:
sudo mount /dev/sda1 /mnt/usb -o uid=pi,gid=pi

Adapt this value to your system.
The uid and gid options allow pi to read and write files on the USB key
And then check you can see your files and create a new one:
ls -latr /mnt/usb
touch /mnt/usb/test

You’re ready to use it.
If you want to remove the USB key, you can dismount it with:
sudo umount /mnt/usb

Create a small script to save your preferences

Even if this was the manual way to mount a USB drive, I recommend saving this in a script if you are not familiar with this kind of command.
This will save you searching this page next time 🙂

Create a small script

  • Create a new file
    sudo nano /usr/local/bin/
  • Paste these lines:
    sudo mount /dev/sda1 /mnt/usb -o uid=pi,gid=pi

    echo "USB drive mounted successfully"
    This is a basic script, adapt the values and add what you want
  • Save and exit (CTRL+O, CTRL+X)
  • Add execution permission:
    sudo chmod +x /usr/local/bin/

Create an alias

  • Edit your .bashrc file
    nano ~/.bashrc
  • Add this line at the end of the file
    alias usbmount='/usr/local/bin/'
  • Save and exit
  • Close the terminal or end your SSH connection

Easy mount

Master Python on Raspberry Pi
Sale: 10% off today.
Get the eBook.
Do more with your Raspberry Pi, learn the useful concepts and take the shortcuts.
You miss half of the fun of using a Raspberry Pi if you don’t know anything about Python.

Next time you come into the terminal and plug your USB key, just use:

And then it’s done 🙂
No more mount command to remember.

Automatically mount the USB drive

You already know how to mount manually your drive each time you plug it, or boot your Raspberry Pi.
But if you use it a lot, or even let the drive plugged all the time, this is not the best way to do this.
You can configure your Raspberry Pi to auto-mount it on boot.

The /etc/fstab file

/etc/fstab is a configuration file to configure a mount point for each device.
We’ll save in this file all information needed to mount our USB drive to /mnt/usb.

Follow this procedure to add your USB drive in this file:

  • Open /etc/fstab:
    sudo nano /etc/fstab
  • Add this line at the end:
    UUID=2014-3D52 /mnt/usb vfat uid=pi,gid=pi 0 0
    Replace the UUID by your own UUID you get in the prerequisites
    Replace vfat by your file system if needed (ntfs or ext4 for example)
    As you may notice, the options column with uid and gid play the same role as for the manual mount, we give access to the pi user with this
  • Save and exit
  • Reboot or try it directly with:
    sudo mount -a
    Your USB drive should now be available in the /mnt/usb folder
    And Raspbian will  mount it automatically at each boot
    If you want to add it after the boot, just run mount -a again, or mount /mnt/usb

Using the UUID rather than the device name (/dev/sda1) allows us to be sure this is the correct device.
When you use multiple USB key for example, the first connected will be sda1 but you can’t know which one it is physically.
With the UUID, you’re sure this is the good one.
You can create a mount point for each device if you want  (/mnt/big_drive, /mnt/kingston_key, …).

Reminder: Remember that all my Patreon supporters get access to this website without ads, early access to my videos and much more. You can become part of this community for as little as $3 per month & get all the benefits immediately.

Related questions

Get My Cheat Sheet!
Grab your free PDF file with all the commands you need to know on Raspberry Pi!

There is no partition on my USB key, so I’m not able to mount it, what should I do? The easiest way to create the first partition is to insert this key in a desktop OS (Windows or a Pi Desktop with Gparted for example). If you want to do this on a Raspbian Lite, use the mkfs command: sudo mkfs -t fat32 /dev/sda1. More information here.


You can now use USB drives on your Raspberry Pi, either manually (with mount) or automatically on the boot (with fstab).

This tutorial doesn't work anymore? Report the issue here, so that I can update it!

5 2 votes
Article Rating

Patrick Fromaget

I'm the lead author and owner of My goal is to help you with your Raspberry Pi problems using detailed guides and tutorials. In real life, I'm a Linux system administrator with a web developer experience.

Notify of
Newest Most Voted
Inline Feedbacks
View all comments
1 year ago

Thank you, You Rock Patrick. I’m starting to learn. It is never to late.

1 year ago

Thanks Patrick. Just added the automount mod to my Diet Pi’s /etc/fstab. Works quite well!

1 year ago

Thank you Mr. Fromaget for sharing this great post! Do you know how I could automatically mount a camera device using this method or something similar? because Raspberry recognizes it as / run / user / 1000 / gvfs / gphoto2 and can only get its ID using ‘lsusb’ and other commands with ‘usb-devices’ in terminal, I even tried it with an android device, but it was recognized as / run / user / 1000 / gvfs / mtp .. any ideas? I need to use these devices when starting startup with automatic console login, because those devices are only recognized on desktop after using startx.

1 year ago

Does this method allow you to add files to the USB drive?

2 months ago

Thanks, I was able to get this working with 2 external drives & a headless pi.
I found a problem in my situation : if either one of the USB drives is not connected at boot time, then the pi has some kind of error that stops it from joining the network (wifi)
So I had to remove the SD card, edit the fstab & comment out the absent drive.
I wonder if you have any ideas why this would be?

2 months ago

minor mistake in “Create a small script”
after hours for searching for the bug, i have realised that instead of:
Paste these lines:
sudo mount /dev/sda1 /mnt/usb -o uid=pi,gid=pi echo "USB drive mounted successfully"

it should have been;
Paste these lines:
sudo mount /dev/sda1 /mnt/usb -o uid=pi,gid=pi
echo "USB drive mounted successfully"

please correct this, so that others wont run into the same mistake
it was still a good way to learn bash scripting, maybe keep it

Last edited 2 months ago by Mostafa
Sergey Alekseev
Sergey Alekseev
2 months ago

I changed from defaults to uid=pi,gid=pi in order to make the mounted drive writable for the pi user and now my pi doesn’t start…

Recent Posts

Master your Raspberry Pi - 10% off