mount and unmont a USB drive on Ubuntu / Linux
Step 1: Plug in the USB drive to usb port of yor computer system.
Step 2: Run the following command in your Terminal in order to check the available storage devices on your system and the file system they are using:
1 | sudo fdisk -l |
Output

It will display multiple disks connected to your system. Find out your usb drive by looking size of your pendrive. Take a note of your pendrive. For example here it will be /dev/sdb1 with FAT32 filesystem.
Step 3: Create mount point
1 | sudo mkdir /media/usbpen |
Now let’s make it available to all users:
1 | sudo chmod -R 777 /media/usbpen |
1 | sudo mount -t vfat /dev/sdc1 /media/usbpen |
Here we all done
Accessing USB Data
Now we can access our Pendrive data by navigating to /media/usbpen
1 | cd /media/usbpen |
now we are in pendrive
Permanent Mount
For permanently mounting your Pendrive or USB drive after reboot add the following line into your /etc/fstab config file
1 | sudo vi /etc/fstab |
Now add the following entry at the end of that file:
1 | /dev/sdb1 /media/usbpen vfat defaults 0 0 |
To make sure the drive mounted successfully issue the command:
1 | df |
it will show you pendrive mount point
NOTE: for Permanent Mount of pendrive i am using bash script with run on startup of computer system
Make a sh file and save it ( i am saving file name as mountPendrive in opt folder ot computer system )
1 2 | cd /opt/ sudo vi mountPendrive.sh |
Add below line then save and exit ( Esc :wq! )
1 2 | #!/bin/bash sudo mount /dev/sdb1 /media/usbpen |
Then add this file at crontab on rebbot of system ( whenever system reboot ot start it will mont your pen drive)
1 2 3 | sudo su export EDITOR=vi crontab -e |
now add below line in crontab and save and exit crontab
@reboot /opt/mountPendrive.sh
Unmount Pendrive
for nmounting pendrive first we have come out from pendrive may be in /tmp then run unmont command
1 2 | cd /tmp sudo umount /dev/sdb1 |
And also:
1 2 | cd /tmp sudo umount /media/usbpen |
or again mounting
1 | sudo mount /dev/sdb1 /media/usbpen |
You May Also Enjoy Reading This …