Raspberry Pi Adventures

Join me on my fun ride

Mounting and UnMounting USB Drives on Raspberry Pi

6 Comments

Using OS : 2012-08-16-wheezy-raspbian

I wanted to hookup my NTFS formatted usbdrive to RPi this is how it worked for me.

 

Steps

1. Hooked up the usbdrive and booted my Pi

2. Now fired the command
$dmesg

This helps you find the name given by the system to usbdrive

It returns a lot of things but we have to find some thing similar which lists your usb drive
[ 215.537561] usb 1-1.2: new high speed USB device number 9 using dwc_otg
[ 215.639100] usb 1-1.2: New USB device found, idVendor=8564, idProduct=1000
[ 215.639135] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 215.639157] usb 1-1.2: Product: Mass Storage Device
[ 215.639185] usb 1-1.2: Manufacturer: JetFlash
[ 215.639203] usb 1-1.2: SerialNumber: 2979116540
[ 215.655004] scsi0 : usb-storage 1-1.2:1.0
[ 216.658513] scsi 0:0:0:0: Direct-Access JetFlash Transcend 16GB 1.00 PQ: 0 ANSI: 5
[ 216.660406] sd 0:0:0:0: [sda] 30871552 512-byte logical blocks: (15.8 GB/14.7 GiB)
[ 216.661158] sd 0:0:0:0: [sda] Write Protect is off
[ 216.661216] sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00
[ 216.661904] sd 0:0:0:0: [sda] No Caching mode page present
[ 216.661950] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 216.666012] sd 0:0:0:0: [sda] No Caching mode page present
[ 216.666045] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 216.670729] sda: unknown partition table
[ 216.676001] sd 0:0:0:0: [sda] No Caching mode page present
[ 216.676034] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 216.676069] sd 0:0:0:0: [sda] Attached SCSI removable disk

3. Now to Mount the USB Drive follow these steps

3.1 Create a directory in mnt
$sudo mkdir /mnt/usb

3.2 Now to mount the directory
$sudo mount /dev/sda /mnt/usb

3.3 To confirm run the following command
$df- f

This returns
Filesystem Size Used Avail Use% Mounted on
rootfs 7.3G 2.0G 5.0G 29% /
/dev/root 7.3G 2.0G 5.0G 29% /
tmpfs 19M 248K 19M 2% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 37M 0 37M 0% /tmp
tmpfs 10M 0 10M 0% /dev
tmpfs 37M 0 37M 0% /run/shm
/dev/mmcblk0p1 56M 36M 21M 64% /boot
/dev/sda 15G 8.1G 6.8G 55% /mnt/usb

Check the last line here.

3.4 Now you can access the content of your drive by traversing the following path
$ cd /mnt/usb

That should do it 🙂

Tip
Now some time drives are mounted as read-only
This problem for me was solved by installing the ntfs-3g package
$sudo apt-get install ntfs-3g

Read more : NTFS – Debian Wiki

Sometimes we need to specify the file system
$sudo mount /dev/sda /mnt/usb -t filesystem

where filesystem is replaced by the following
auto – this is a special one. It will try to guess the fs type when you use this.
ext4 – this is probably the most common Linux fs type of the last few years
ext3 – this is the most common Linux fs type from a couple years back
ntfs – this is the most common Windows fs type or larger external hard drives
vfat – this is the most common fs type used for smaller external hard drives

Read More: mount: you must specify the filesystem type – Ask Ubuntu

4. Now to Unmount the drive
$sudo umount /dev/sda

Run the $df -h  command to check if its removed.

Done 🙂

References
USB flash storage mounted as read-only filesystem (Page 1) / Newbie Corner / Arch Linux Forums

Advertisements

Author: Sanket Sonavane

Sanket Sonavane Software Developer, IoT Enthusiast, Photographer, Bike Rider, Chef, AndroidUser, MacOSXNewbie & 3x3x3 Cuber ;) Loves computers, programming, web developement, micro-controllers, gadgets, automation and many more such tech innovations that defines the way we live in the modern age and likes to explore what more can be done to help the human race :)

6 thoughts on “Mounting and UnMounting USB Drives on Raspberry Pi

  1. I find the best way to locate the drive and partition ID is:
    ls -l /dev/disk/by-id

    (^those are both lowercase L)

    Hope this helps.

  2. I find it much easier to use this to get the USB drive names..
    $ sudo blkid
    /dev/mmcblk0p1: SEC_TYPE=”msdos” LABEL=”boot” UUID=”2654-BFC0″ TYPE=”vfat”
    /dev/mmcblk0p2: UUID=”548da502-ebde-45c0-9ab2-de5e2431ee0b” TYPE=”ext4″
    /dev/sda1: LABEL=”New Volume” UUID=”CC98C19298C17B88″ TYPE=”ntfs”

  3. I could nowhere find the unmount command, and it is umount. Thanks 😉

  4. Thanks, really helpful 🙂

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