Home > How To, Raspberry pi, Technology > How to mount a USB drive to your Raspberry Pi

How to mount a USB drive to your Raspberry Pi

September 23, 2012 Leave a comment Go to comments

Before we can start using our USB drive with the Raspberry PI we must first create a media mount point and then add our USB drive to that media mount point

First we need to find out where our system locates the device. With the USB device not plugged in, type…

tail -f /var/log/messages

This should display the following information seen below

pi@raspberrypi ~ $ tail -f /var/log/messages
Sep 22 16:56:03 raspberrypi kernel: [ 5313.827367] 465 pages in swap cache
Sep 22 16:56:03 raspberrypi kernel: [ 5313.827378] Swap cache stats: add 960, de        lete 495, find 404/419
Sep 22 16:56:03 raspberrypi kernel: [ 5313.827390] Free swap  = 99960kB
Sep 22 16:56:03 raspberrypi kernel: [ 5313.827398] Total swap = 102396kB
Sep 22 16:56:03 raspberrypi kernel: [ 5313.838708] 57344 pages of RAM
Sep 22 16:56:03 raspberrypi kernel: [ 5313.838718] 2745 free pages
Sep 22 16:56:03 raspberrypi kernel: [ 5313.838726] 1940 reserved pages
Sep 22 16:56:03 raspberrypi kernel: [ 5313.838735] 6666 slab pages
Sep 22 16:56:03 raspberrypi kernel: [ 5313.838743] 41974 pages shared
Sep 22 16:56:03 raspberrypi kernel: [ 5313.838752] 465 pages swap cached

Push CTRL+C to return to the command prompt

Plug in your USB drive and run the same command again and you should get the following

pi@raspberrypi ~ $ tail -f /var/log/messages
Sep 23 15:31:58 raspberrypi kernel: [86669.690603] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Sep 23 15:31:58 raspberrypi kernel: [86669.690620] usb 1-1.2: Product: Mass Storage
Sep 23 15:31:58 raspberrypi kernel: [86669.690632] usb 1-1.2: Manufacturer: Generic
Sep 23 15:31:58 raspberrypi kernel: [86669.690643] usb 1-1.2: SerialNumber: A17D7C6A
Sep 23 15:31:58 raspberrypi kernel: [86669.692950] scsi0 : usb-storage 1-1.2:1.0
Sep 23 15:31:59 raspberrypi kernel: [86670.688882] scsi 0:0:0:0: Direct-Access           8.07 PQ: 0 ANSI: 2
Sep 23 15:31:59 raspberrypi kernel: [86670.694385] sd 0:0:0:0: [sda] 3790848 512-byte logical blocks: (1.94 GB/1.80 GiB)
Sep 23 15:31:59 raspberrypi kernel: [86670.694973] sd 0:0:0:0: [sda] Write Protect is off
Sep 23 15:31:59 raspberrypi kernel: [86670.751906]  sda: sda1
Sep 23 15:31:59 raspberrypi kernel: [86670.755898] sd 0:0:0:0: [sda] Attached SCSI removable disk

You should notice new lines which appear, make a note of the ID – it will be something like sda1, sdb1, which means our usb drive is located in /dev/sda1 (highlighted in bold)

Push CTRL+C to return to the command prompt

Now we need to create a media mount point for our USB drive

sudo mkdir /media/(whatever you want to name it)

(we use sudo command for “run as admin” as the standard account is not a admin)

Example (sudo mkdir /media/USBdrive)

After making the media mount point we now need to add the USBdrive.

by running the following command

sudo mount -t vfat -o uid=pi,gid=pi /dev/(ID number) /media/(media mount point)/

(we use sudo command for “run as admin” as the standard account is not a admin)

Example (sudo mount -t vfat -o uid=pi,gid=pi /dev/sda1 /media/usbdrive)

You have now successfully added your USBdrive to your Raspberry Pi

To view the contents of your USB drive run the following command

cd /media/usbstick

(to change to the USBdrive now mounted on media mount point)

and then

ls -l

(to display the contents of USBdrive)

It is important to note that this example is based on a usb pen drive connect directly to raspberry pi, This may changed when using a usb hub.

If you are having issues getting your USB device to work it may require more power then the raspberry pi can give which in that case may require you to power the USB device from a separate power source.

Advertisements
  1. September 24, 2012 at 12:08 pm

    Reblogged this on Gigable – Tech Blog.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

raspberrypicloud

The University of Glasgow's Raspberry Pi Project

Tech-o-rama

Your all round solution for tech problems (and some others things...like spelling errors)

thedomesticfringe.com/

telling stories - making memories

Raspberry Pi Kid

A 14-year old's adventures with Raspberry Pi

Naked Security

Computer Security News, Advice and Research

Grumpy IT Girl

I'm not a very good writer

Dustin Software

Because programming is fun!

Pinoy Tekkie

USER-FRIENDLY TECHNOLOGIES FOR THE PINOY NOOBIES

petRockBlog

Fun stuff for technics enthusiasts

I Kissed My Date Goodnight

Embarking on motherhood through the miracle of adoption.

projectz

Tech, Gadgets, Photography, Social Media and Poor Spelling

Programming My Rasberry Pi

A brave fool's adventures into the unknown!

Chris Ainger's Blog

Where Fishing Meets Computing

PIPAL

Information wants to be free

ITtechExec: Protecting Tech Careers Since 2001

Technical Career Advancement: Transformed. Guaranteed.

CRUNCHEDD

Entertainment, Technology, Social Media Updates from in Between the Web…

StartupTunes

An Exclusive Web 2.0 Startups Review Blog

The Life of Me

Just another IT blog

NJrajgelani

The Best Place for Deziners

%d bloggers like this: