How to mount A USB flash?

Hi Guys,

I am going to show on how to mount a usb flash when you connect it to your raspberry pi.

Please enjoyed it !!!

Step 1: Identify the flash/pendrive You want to Mount:

To do this, we will be making use of the “df” command.

df -h

The line will usually refer to “/sda” and in this example it is “sda1”.

Step 2: Retrieving the Disk UUID and Type

To do this command.

sudo blkid /dev/sda1

From this command, you should have retrieved a result as we have below.

Please make a note of the value for both the UUID and the TYPE.

Type is depending on your drive whether ntfs or exFAT.

If NTFS, you need to do following command.

sudo apt install ntfs-3g

If exFATTo add support for the exFAT filesystem, we will need to install two packages.

sudo apt install exfat-fuse
sudo apt install exfat-utils

Step 3: Mounting the Drive

1. Make a directory for the drive so that every time your drive connected, it will mount to this directory. To do this command.

sudo mkdir /media/usbtypec

2. Let’s now give our pi user ownership of this folder by running the command below.

sudo chown -R pi:pi /mnt/usbtypec

3. Finally, modify the fstab file by do command below.

sudo nano /etc/fstab

This file controls how drives are mounted to your Raspberry Pi.

4. Add lines below at the end of line:

UUID=50B87EECB87ED048 /media/usbtypec ntfs auto,nofail,noatime,users,rw,uid=pi,gid=pi 0 0

where you put your drives UUID ([UUID]) and TYPE ([TYPE]).

UUID=[UUID] /mnt/usb1 [TYPE] ntfs auto,nofail,noatime,users,rw,uid=pi,gid=pi 0 0

Step 4: Umount the Drive


If you used the fstab file to auto-mount it you will need to use :

sudo umount /media/usbtypec