How To Mount a USB Drive On The Raspberry Pi (3 ways)

1. Using the Command Line:

Step 1: Plug in your USB drive to the Raspberry Pi.

Step 2: Open the terminal window and type “sudo fdisk -l” to list all the drives connected to the Raspberry Pi.

Step 3: Identify the USB drive from the list. It should be listed as “/dev/sda1” or similar.

Step 4: Create a mount point for the USB drive. Type “sudo mkdir /mnt/usbdrive”.

Step 5: Mount the USB drive. Type “sudo mount /dev/sda1 /mnt/usbdrive”.

Step 6: To unmount the USB drive, type “sudo umount /mnt/usbdrive”.

2. Using the GUI:

Step 1: Plug in your USB drive to the Raspberry Pi.

Step 2: Open the File Manager and select the USB drive from the list of drives.

Step 3: Right-click on the USB drive and select “Mount”.

Step 4: To unmount the USB drive, right-click on the USB drive and select “Unmount”.

3. Using the /etc/fstab File:

Step 1: Plug in your USB drive to the Raspberry Pi.

Step 2: Open the terminal window and type “sudo fdisk -l” to list all the drives connected to the Raspberry Pi.

Step 3: Identify the USB drive from the list. It should be listed as “/dev/sda1” or similar.

Step 4: Create a mount point for the USB drive. Type “sudo mkdir /mnt/usbdrive”.

Step 5: Open the /etc/fstab file. Type “sudo nano /etc/fstab”.

Step 6: Add the following line to the end of the file: “/dev/sda1 /mnt/usbdrive auto defaults 0 0”.

Step 7: Save the file and exit.

Step 8: Mount the USB drive. Type “sudo mount -a”.

Step 9: To unmount the USB drive, type “sudo umount /mnt/usbdrive”.

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

In most cases, the USB drive is mounted automatically on Raspberry Pi OS.
If needed, the USB drive can be mounted manually by using the following command: sudo mount /dev/sda1 /mnt/usb. The /etc/fstab file can also be edited for an automatic mount on startup.

Don’t worry, I’ll explain how to connect your USB key or drive without having to remember 50 parameters. We’ll learn the manual way (for temporary devices) and the automatic way for devices you want to use often on your Raspberry Pi (like your RetroPie ROMs, movies, or a backup storage drive).

If you’re looking to quickly progress on Raspberry Pi, you can check out my e-book here. It’s a 30-day challenge where you learn one new thing every day until you become a Raspberry Pi expert. The first third of the book teaches you the basics, but the following chapters include projects you can try on your own.

Hardware requirements

Here is the recommended hardware to follow this tutorial:

  • A Raspberry Pi 4: Or at least, try to pick a model with blue USB ports, it will be way faster than with older models.
  • A fast USB drive: This is my favorite. You can now get SSD in external drives as well, making everything faster. And it’s not even more expensive than traditional slow drives.

And as for most projects, adding these optional accessories can make your life easier:

  • A good keyboard and mouse: I use this one, but other options are available (I tested most of them in this comparison).
  • A decent monitor: always easier to follow the instructions when you can see what’s going on with the Raspberry Pi, not switching from your computer to the Pi all the time.
  • The best Raspberry Pi case: it’s the one I use all the time. It keeps my Pi protected and cool, a must-have (tested here).

Get information about the USB drive

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

Prepare your Raspberry Pi

You can follow this tutorial with any Raspberry Pi OS version, and nearly any Linux distribution. No prerequisites, just adjust the commands if you are not using a Debian-based distribution.

I’ll assume 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 it shouldn’t be that different.

Before doing anything on your system, start by updating it with:
sudo apt update
sudo apt upgrade

And if you plan to use NTFS drives (Windows file system), check that you have the required package installed (NTFS is mainly for Windows devices and may not be required in your case).
You can install the package with:
sudo apt install ntfs-3g

It will tell you if you already have it installed.

Are you a bit lost in the Linux command line? Check this article first for the most important commands to remember, and a free downloadable cheat sheet so you can have the commands at your fingertips.

Plug your device

You can then plug your device into a free USB port.
If you have a recent model, it’s better to plug the USB device into a blue port. USB 3 ports are faster overall.

Use the blue ports for USB drives when possible. Keyboard, mouse and other accessories can go on the black ports.

For big external drives, you will need extra power to run the drive correctly (or the message “Under-voltage detected!” may appear).

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 (unless it has its own power supply).

If you are using one, plug the hub into the Raspberry Pi and your hard drive directly on the hub.

And if you don’t have a USB drive yet, here are my two recommendations currently:

  • This USB flash drive from SanDisk: I use it all the time. I rarely use SD cards now and install my new distributions on this instead. I’m pleased with it, as it’s fast and robust.
  • This USB portable SSD: It’s perfect for the Raspberry Pi (almost the same size), it’s one of the fastest options, and I love SanDisk.

Collect more information

Once the disk is plugged in, we need to know more about it before going further.

Fdisk

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 command output, you should get something like this:
fdisk command output

  • First, 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 an 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 disappears.
  • Then remember two things:
    • The file system 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.

If your USB drive is not formatted, or if you want to use another file system, you should check my other tutorial on this website: How to format and mount a USB drive on Raspberry Pi?.

UUID

Another piece of information that could help us later is the UUID.
When you format a disk, the system assigns an ID to the disk.
We call this the UUID. This allows us to know it is a known drive and to do something specific when you plug it into 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

We are almost ready.
On Linux systems, you need to create a new folder to mount the drive in later.
Generally, we create it in /mnt or /media (you can read my article to learn more about the Linux file system overall).

Create the directory:
sudo mkdir /mnt/usb

We are ready with prerequisites.

Now, there are two ways to mount your USB drive:

  • Manually: type a command line and get access to it quickly (perfect for temporary devices).
  • Automatically: this needs more configuration to start, but this will be accessible automatically after a reboot.

I’m explaining the two methods in the next parts, so you can pick the one you prefer.

Manually mount the USB drive

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

The mount command

The mount command allows us to mount a device to 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 it 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/usb-connect.sh
  • Paste these lines:
    #!/bin/bash
    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/usb-connect.sh

Create an alias

Creating an alias allows you to use a short command to run the script, instead of using the complete command we saw earlier, or the full path to the script.

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

Easy mount

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

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

Automatically mount the USB drive

You already know how to manually mount your drive each time you plug it in, or boot your Raspberry Pi.
But if you use it a lot, or even leave the drive plugged all the time, it’s not the best way to do it.
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 to 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 with your own UUID you get in the prerequisites.
    Replace vfat with your file system if needed (ntfs or ext4 for example).
    As you may notice, the options column with uid and gid plays 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 Raspberry Pi OS 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 it is the correct device.
When you use multiple USB keys, for example, the first connection 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, …).

Video

Related questions

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 Raspberry Pi OS Lite, use the mkfs command: sudo mkfs -t fat32 /dev/sda1. More information here.

Want to chat with other Raspberry Pi enthusiasts? Join the community, share your current projects and ask for help directly in the forums.

Conclusion

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

USB drives can then be used for multiple things, including:

Additional Resources

Not sure where to start?
Understand everything about the Raspberry Pi, stop searching for help all the time, and finally enjoy completing your projects.
Watch the Raspberry Pi Bootcamp course now.

Master your Raspberry Pi in 30 days
Don’t want the basic stuff only? If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiple projects with step-by-step guides.
Download the e-book.

VIP Community
If you just want to hang out with me and other Raspberry Pi fans, you can also join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.
More details here.

Need help building something with Python?
Create, understand, and improve any Python script for your Raspberry Pi.
Learn the essentials step-by-step without losing time understanding useless concepts.
Get the e-book now.

You can also find all my recommendations for tools and hardware on this page.

How To Mount a USB Drive On The Raspberry Pi (3 Ways)

Mounting a USB drive on the Raspberry Pi is a simple process that can be done in a few steps. With the right setup, you can easily access your USB drive from the Raspberry Pi and use it to store and access files. Here are three ways to mount a USB drive on the Raspberry Pi.

Method 1: Using the GUI

The easiest way to mount a USB drive on the Raspberry Pi is to use the graphical user interface (GUI). To do this, open the File Manager application and select the USB drive from the list of available drives. Once the drive is selected, click the “Mount” button to mount the drive. You should now be able to access the USB drive from the File Manager.

Method 2: Using the Command Line

If you prefer to use the command line, you can mount a USB drive on the Raspberry Pi by using the “mount” command. First, you need to find the device name of the USB drive. To do this, run the command “lsblk” and look for the device name of the USB drive. Once you have the device name, you can mount the drive by running the command “mount /dev/[device name] /mnt/usb”. This will mount the USB drive to the “/mnt/usb” directory.

Method 3: Using a Script

If you want to automate the process of mounting a USB drive on the Raspberry Pi, you can use a script. To do this, create a script file with the following contents:

#!/bin/bash

# Find the device name of the USB drive
DEVICE=$(lsblk | grep -m 1 -o 'sd[a-z][0-9]')

# Mount the USB drive
mount /dev/$DEVICE /mnt/usb

Save the script file and make it executable by running the command “chmod +x [script file]”. You can now run the script to mount the USB drive on the Raspberry Pi.

Mounting a USB drive on the Raspberry Pi is a simple process that can be done in a few steps. With the right setup, you can easily access your USB drive from the Raspberry Pi and use it to store and access files. Using the GUI, the command line, or a script, you can easily mount a USB drive on the Raspberry Pi.

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00
Open chat
Scan the code
Hello 👋
Can we help you?