Introduction: Using a USB External Hard Drive With Your Raspberry Pi

Picture of Using a USB External Hard Drive With Your Raspberry Pi

Experimental introduction:


In many cases SD capacity is not enough. Luckily Raspberry Pi can easily be connected to external USB hard drives. Follow the steps in this section, and you will soon have a lot more storage connected to your Raspberry Pi.

Step 1: Experimental Hardware Devices

Picture of Experimental Hardware Devices

Experimental hardware devices:

This experiment requires the following hardware:

  • Raspberry Pi board.
  • USB External hard drive.

This experiment requires the following software:

  • tightvncserver

It is recommended that any USB external hard drive that you choose should be powered by an external power supply rather being powered by the USB port. In the past I have had bad experiences trying to power USB external hard drives from the Raspberry Pi USB port. Sometimes the Raspberry Pi was not even able to find the hard drive.

Experiments Wiring:

  • Please plug the external hard drive into the Raspberry Pi USB connector.

Step 2: Make Sure That Your Raspberry Pi Software Is Up to Date

Execute the

following commands to make sure your Raspberry Pi has the latest software.

$sudo apt-get update

$sudo apt-get upgrade

This will update all the installed software on your Raspberry Pi.

Step 3: Verify That Your Raspberry Pi Is Able to Recognize the Hard Drive.

Picture of Verify That Your Raspberry Pi Is Able to Recognize the Hard Drive.

Execute the following command to confirm your

Raspberry Pi recognizes the hard drive that you plugged in.

$sudo fdisk -l

If you do not see it, you can fix it by following these procedures:

1. Reboot the Raspberry Pi

2. Make sure you are using an external power supply for your USB hard drive as the Raspberry PI USB port will probably not have enough power for it.

3. Do not use a USB Hub plug the hard drive directly into the Raspberry Pi.

4. Verify that your Hard drive, USB interface is using USB 2.0. My experience is that Raspberry Pi is unable to use USB 3.0 interfaces.

Step 4: NTFS Hard Drive Compatibility Software Driver Installation

Execute

the following command to install this software.

 $ sudo apt-get install ntfs-3g

Step 5: Specify the Location Path That You Want to Mount the USB Hard Drive

Picture of Specify the Location Path That You Want to Mount the USB Hard Drive

Execute the following command to create the path you

want to use to mount the hard drive. The name "usbhdd" is for example, it can be whatever you like following Linux naming standards.

$ sudo mkdir /media/usbhdd

Execute the following command to set up the user rights for your hard drive path.

$ sudo chown pi:pi /media/usbhdd

Execute the following command to mount the hard drive so that you can use it. Specify // media / usbhdd path, using the name that you set up previously.

$ sudo mount -t vfat -o uid=pi,gid=pi /dev/sda1
/media/usbhdd

If an error message appears as in figure 5-3 this means there is a problem is the file format, make sure your hard drive is using the FAT32 format. If you want to format the hard drive in the Raspberry Pi, you can see the next chapter "Format HDD" for instructions. You can also plug the external hard drive into your favorite Windows PC and format it with the FAT32 format as well.

Step 6: Hard Drive Confirm Access

Picture of  Hard Drive Confirm Access

Now that we have defined a path and mounted the hard

drive, you can use this path and access information on the USB hard drive.

$ cd  /media/usbhdd
$ ls

If you want to remove the USB hard drive execute the
same instructions but substitute the unmout command for the mount command as show below.

$ sudo umount /media/usbhdd

Step 7: Set to Automatically Mount When the System Starts

Picture of Set to Automatically Mount When the System Starts

It is a lot of trouble to have to mount the drive

Every time you want to use it so lets have the system automatically mount it when the system reboots.

As we are going to update one of the system Let's back up the file fstab configuration file before updating it by executing the following command.

$ sudo cp /etc/fstab /etc/fstab.backup

To accomplish what we need we have to obtain the UUID of the external hard drive. Executing the following command will this and a great deal more information as well.

$sudo blkid

So in my example you will see /dev/sda1: LABEL = "HD256G" UUID = "1599-18FA" TYPE = "vfat". The information that we need is UUID = "1599-18FA" and TYPE = "vfat". Your results will probably be different so you need to substitute your information when we edit the fstab file.

Step 8:

Picture of

So now lets edit the fstab file by executing the following command.

$ sudo nano /etc/fstab 

We will add a line in this file to describe the hard drive. Your UUID will be unique, so please update with your data. They of vfat probably will be same and everything else will be same.

UUID="1599-18FA" /media/usbhdd  vfat     rw,defaults 0 0

Additional information:

You can also use auto instead of vfat or ext3 to automatically have the system determine the hard disk format type. So then the line would like the following.

UUID="1599-18FA" /medusbia/hdd  auto    rw,defaults   0 0

Step 9: Test the Change for Auto Mount

Picture of Test the Change for Auto Mount

This change can be tested quickly by executing the

Following command. If the /etc/fstab file is incorrect you will see an error message as indicated below.

$ sudo mount -a

To fix this go back and verify all the instructions
Have been correctly following and the text you entered is correct. After everything has been fixed and you have tested successfully, you can reboot your Raspberry Pi by executing the following command.

$ sudo reboot

Step 10: Final Testing

Picture of Final Testing

After reboot and after you Login to your Raspberry

Pi, you can verify success by executing the following command and you test accessing the external hard drive.

$ cd /media/usbhdd

Comments

SamsMadhu (author)2016-10-04

Can anybody brief out,...what is happening with this project?

tecneeq (author)SamsMadhu2017-02-22

He usus a NTFS formatted disk via usb-adapter on a rasperry pi.

Oathkeeper (author)2015-12-29

FAT32? Too many limitations... For those that have an HFS Plus formatted drive, see tutorial (package) here: https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=60437

smooth_jamie (author)2015-10-18

Great project! just wanted to mention if anyone has problem when using IDE drives, make sure you remove the jumper pins from the back of the HDD before mounting in the caddy.

smooth_jamie (author)2015-10-18

Great project! just wanted to mention if anyone has problem when using IDE drives, make sure you remove the jumper pins from the back of the HDD before mounting in the caddy.

sail4sea (author)2015-09-06

Why mount it as a fat32 drive? That surely limits the size of drive you can use. It's better to format the drive ext4 if you are going to format it. I also recommend putting the root partition and a separate /home partition on the hard drive.

As I said, there is no reason to mount a fat32 drive on a Linux system.

Powen Ko (author)sail4sea2015-09-17

get your point, agree, depend user choice,
in face, My HD is setup Linux ext4 for the speed issue.

kooth (author)2015-09-01

Awesome! Just what I can use my old external hard drives for! Thanks so much for sharing!

Powen Ko (author)kooth2015-09-01

Sound's great~~

tomatoskins (author)2015-08-27

This is great! Thanks for sharing your knowledge!

Powen Ko (author)tomatoskins2015-08-27

thank you, that is my pleasure.

About This Instructable

29,310views

174favorites

License:

Bio: http://www.powenko.com https://www.facebook.com/app_scoped_user_id/866601820074742/
More by Powen Ko:IFrogLab LoRa Send and receive data between 9.9miles(15KM)Raspberry Pi cameraRaspberry Samba file server software
Add instructable to: