mount and unmont a USB drive

mount and unmont a USB drive on Ubuntu / Linux

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:

sudo fdisk -l

Output

mount and unmont a USB drive

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

sudo mkdir /media/usbpen

Now let’s make it available to all users:

sudo chmod -R 777 /media/usbpen

Step 4: Mount the drive:

sudo mount -t vfat /dev/sdc1 /media/usbpen

Here -t is the filesystem type. 

Here we all done

Accessing USB Data

Now we can access our Pendrive data by navigating to  /media/usbpen

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

sudo vi /etc/fstab

Now add the following entry at the end of that file:

/dev/sdb1 /media/usbpen vfat defaults 0 0

To make sure the drive mounted successfully issue the command:

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 )

cd /opt/
sudo vi mountPendrive.sh

Add below line then save and exit ( Esc :wq! )

 

#!/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)

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

cd /tmp
sudo umount /dev/sdb1

And also:

cd /tmp
sudo umount /media/usbpen

or again mounting

sudo mount /dev/sdb1 /media/usbpen

You May Also Enjoy Reading This …

Leave a Reply

Your email address will not be published. Required fields are marked *