With the Raspberry Pi, Mounting a USB Thumb Drive
The below lesson is another fundamental lesson on Raspberry Pi.
The below lesson will help you in setting up the Raspberry Pi to identify and automatically support USB thumb drive. Several uses of this functionality are that it is helpful while transferring files or taking back up of data or else you can use Raspberry Pi as Media storage device as well.
However, to implement you need to have a running Raspberry Pi at your disposal. To configure it, you can check lesson on Ultimate Raspberry Pi Configuration guide which can be found on internet.
For the below lesson, Mac OS is used, however, the operations can be carried out on other OS as well.
Raspberry Pi – How to format USB drive
Show All Items
Format you USB thumb drive with MS-DOS (FAT) as format type. The format can be carried out using disk utility. FAT format type helps create a format which is recognized by Raspberry Pi.
Raspberry Pi – Running updates
It’s better to connect Raspberry Pi and access it using SSH. The mentioned IP address is mine and you have to provide your own IP address here.
To access the Raspberry Pi run the below command in the terminal window:
However, if you are directly connected into the monitor, the above step can be ignored.
In order to run the latest package updates, wifi connectivity is required. To run the updates, kindly run the below line of code:
Sudo apt-get update
Sudo apt-get upgrade
The package update will take some time to get updated which you can see running on your screen.
Raspberry Pi – Configuring mounting point of thumb drive.
Show All Items
Connect the formatted USB drive with Raspberry Pi after unplugging the power cable. Switch on the Pi.
I generally like to connect wifi dongle to lower port and keep the upper port free for other things like keyboard, USB, etc. to connect.
After sometime, run the above ssh command again
Making sure you give your IP address. Run the below code:
This will map the directory to USB drive. It is essential to set up mount point.
Then type below line of code:
The USB drive information now can be seen on the screen, hence check the output.
/dev/sda1: LABEL=”GITPI” UUID=”6D34-1514″ TYPE=”vfat”
Your output should be similar to the above mentioned.
Next step is to make File drive system editable so as to map the USB drive map to usbdrv directory.
Type the below line of code:
In order to map the drive to the directory, run the below line of code directly:
/dev/sda1/home/pi/usbdrv vfat uid=pi,gid=pi,umask=0022,sync,auto,nosuid,rw,nouser 0 0
Please note that the above line is a single line.
The above code will convert the USB drive viz. /dev/sda1 map to usbdrv directory. The flag values were copied from Thomas Loughlin guide and they make the drive read-write and is accessible to all users.
To save it:
Cntl-X, Y, Return
To restart it:
Raspberry Pi – How to test it
Once, the pi is restarted using the reboot command and the ssh connection is established, one can traverse the usbdrv directory using:
to test, try creating a text file, by:
Type any message in the editor you want to have and save again using:
Switch off the power of Pi and take out the USB drive.
Check the data in the USB drive after connecting to computer and one can see the text entered into the text file.
Raspberry Pi – Mounting and Unmounting using commands
Many people just pull the USB out of the Pi and restart the Pi, however, many people would like to have an eject option similar to the Mac system. This can be done using below line of code to unmount the USB:
In order to mount a different USB, the line of code is:
Sudo mount /dev/sda1
Raspberry Pi – Finished
I hope this easy lesson was of help. It was quite short. Thanks