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

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 thatyou 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

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!

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

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.

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

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 managedisks 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 shouldget something like this:
How To Mount a USB Drive On The Raspberry Pi (3 ways) – RaspberryTips (3)

  • 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:
How To Mount a USB Drive On The Raspberry Pi (3 ways) – RaspberryTips (4)

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!

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 createa 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 drivequickly 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 USBkey, 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.

🖋 Love Raspberry Pi & writing?
Combine your passions and get paid. Write for RaspberryTips!

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.

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

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 vfatwith 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 willmount 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.

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now

Reminder: Remember that all the members of my community get access to this website without ads, exclusive courses and much more. You can become part of this community for as little as $5 per month & get all the benefits immediately.

You may also like:

  • 25 awesome Raspberry Pi project ideas at home
  • 15 best operating systems for Raspberry Pi (with pictures)
  • My book: Master your Raspberry Pi in 30 days

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:

  • Backup and Restore your Raspberry Pi
  • Installing Windows 11 on Raspberry Pi (An Illustrated Guide)
  • Getting Started with OpenMediaVault on Raspberry Pi (NAS interface)

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now

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.


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


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

FAQs

How do I mount a USB flash drive to my Raspberry Pi? ›

Mounting a USB Thumb Drive With the Raspberry Pi
  1. Step 1: Format the Thumb Drive. Using Disk Utility, format the thumb drive as an MS-DOS (FAT) volume, which is a format that the Pi can easily recognize.
  2. Step 3: Set Up a "mounting Point" for the USB Drive. Now, unplug your USB power cable. ...
  3. Step 4: Test It.

How do you mount a Raspberry drive? ›

Mounting manually
  1. sudo mkdir /mnt/exdisk. ...
  2. fdisk -l. ...
  3. sudo mount /dev/sdb2 /mnt/exdisk. ...
  4. sudo umount /mnt/mydisk. ...
  5. sudo blkid. ...
  6. sudo nano /etc/fstab. ...
  7. UUID=D632-BE5F /mnt/exdisk fstype defaults,auto,users,rw,nofail 0 0. ...
  8. //NASdrive.local/data /home/pi/NAS cifs -o username=pi,password=naspassword 0 0.

Can Raspberry Pi 3 run on USB? ›

The Raspberry Pi 3 B+ is able to boot from USB without any changes, but the Raspberry Pi 3 requires the USB boot bit to be set in the OTP (one-time programmmble). To enable the USB boot bit, the Raspberry Pi 3 needs to be booted from an SD card with a config option to enable USB boot mode.

What is the best format for a USB drive on a Raspberry Pi? ›

Most of the time you will use EXT4 to keep your USB drive on Linux / Raspberry Pi OS, and one of the others if you want to make it readable on another platform.

Can Raspberry Pi read USB drive? ›

Mount a USB Drive to the Raspberry Pi Automatically

In the latest version of Raspbian (Stretch), your USB drives should be automatically mounted when it is connected to the Pi.

How do I format a mounted USB? ›

Formatting Drives in Windows

Insert a USB drive into a USB port. Open File Explorer. Click on This PC from the left pane. Under the "Devices and drives" section, right-click the flash drive and select the Format option.

How to install a hard drive in a Raspberry Pi 3? ›

Assemble your chosen adapter and then plug it into the HDD port of your Raspberry Pi before powering on the SBC. Then, let the Pi boot up and ensure that the system runs as usual. Try using a different power supply if you notice the Pi crashing or rebooting.

Can I use a USB hub with Raspberry Pi? ›

We also stock micro-USB Hubs to connect to the Raspberry Pi Zero, as the Pi Zero only comes with a single micro-USB connection. For projects using lots of high-power USB devices, we also stock powered USB hubs allowing you to provide your USB devices with power from a separate supply to your Raspberry Pi.

How do I check my USB port on Raspberry Pi? ›

1: Getting the list of all attached USB devices on Raspberry Pi
  1. $ lsusb.
  2. $ lsblk.
  3. $ lsblk.
  4. $ ls /dev/mmcblk0*
  5. $ ls /dev/[hda_name]*

What voltage is the USB on a Raspberry Pi 3? ›

The Raspberry Pi 3 officially uses a 5.1 V micro USB power supply. In my experience you will probably be just fine with a standard 5 V rather than the 5.1 V.

What is the USB port on Raspberry Pi 3 called? ›

Raspberry Pi USB types

Power to the Raspberry Pi B+, 2B, 3B, and 3B+ is supplied using the Micro-B USB (aka Micro USB) port on the side of the board. This port has been replaced by a USB Type-C on the Raspberry Pi 4B.

What USB ports are on a Raspberry Pi 3? ›

Raspberry Pi boards like the Model A+, Model B+, 2, 3, and 3B+ have USB 2.0 ports. The Model A+ only has one, while all the others have four USB 2.0 ports. You can connect just about any device to a Raspberry Pi via the port, as long as the software or driver for it is available for Raspbian OS.

Can Raspberry Pi use USB instead of SD? ›

1. Setting up a USB for your Raspberry Pi is extremely simple to do, and it's just like installing Raspbian to an SD Card, instead of selecting your SD Card reader you will choose the USB storage device that you want to format.

Does Raspberry Pi use FAT32 or NTFS? ›

And most devices including Raspberry Pi do not recognize hard drives formatted to exFAT. The Raspberry Pi's bootloader, built into the GPU (Graphics Processing Unit) and non-updateable, only has support for reading from FAT file systems (both FAT16 and FAT32 included) and is unable to boot from an exFAT file system.

How do I mount an exFAT drive on my Raspberry Pi? ›

You can do it by either using the terminal on the Pi itself or over SSH.
  1. sudo apt-get update sudo apt-get upgrade.
  2. sudo apt-get install exfat-fuse sudo apt-get install exfat-utils.
  3. sudo mkdir /media/exfat.
  4. sudo mount -t exfat /dev/sdb1 /media/exfat.
  5. sudo nano /etc/fstab.
Jan 31, 2022

Can you use flash drive instead of SD card for Raspberry Pi? ›

It is possible to use USB instead of SD card to boot the Raspberry Pi operating system on Raspberry Pi device. Booting the Raspberry Pi system from USB is quite simple and straightforward if the user doesn't have an SD card.

How to auto mount USB drive in Ubuntu? ›

Auto Mount Drive in Ubuntu Server 22.04 at Startup
  1. Create the Mount Point. First, we need to create a directory which will be our mount point for a drive sudo mkdir /media/USB1.
  2. Get Drive UUID and Type. ...
  3. Edit fstab. ...
  4. Test fstab. ...
  5. Restart Ubuntu Server / Linux OS. ...
  6. Test the Mount Point.

References

Top Articles
Latest Posts
Article information

Author: Allyn Kozey

Last Updated:

Views: 6122

Rating: 4.2 / 5 (63 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Allyn Kozey

Birthday: 1993-12-21

Address: Suite 454 40343 Larson Union, Port Melia, TX 16164

Phone: +2456904400762

Job: Investor Administrator

Hobby: Sketching, Puzzles, Pet, Mountaineering, Skydiving, Dowsing, Sports

Introduction: My name is Allyn Kozey, I am a outstanding, colorful, adventurous, encouraging, zealous, tender, helpful person who loves writing and wants to share my knowledge and understanding with you.