How can I add a SATA hard drive to a Raspberry Pi 2?
The Raspberry Pi forums are great – and they are the obvious place for those new to the Raspberry Pi to seek help.
(click on image for larger version)
Frequently those new to the Pi want to add extra storage, and as they are not used to the limitations of the Raspberry Pi will ask how to add a SATA controller to the Raspberry Pi.
The good news:
It is easy to connect SATA hard drives to a Raspberry Pi – just use a USB drive enclosure, or get a USB to SATA adapter!
As USB3.0 USB to SATA bridge chips can fall back to USB2.0 if the host (in this case, a Raspberry Pi) does not support USB3.0, it does not matter if the adapter or enclosure is meant for USB3.0 or USB2.0.
The bad news:
You CANNOT add a SATA controller for hard drives using the GPIO connector as there is no PCIe or SATA interface available on the GPIO connector.
I understand that there is a SMI (Secondary Memory Interface) available on the GPIO pins of Raspberry Pi Model A+, Model B+ and Raspberry Pi 2 Model B, however Broadcom is keeping that information proprietary (secret) so there is no technical documentation available for it, leaving a potentially high speed interface unavailable.
Add an external USB hard drive enclosure of course!
If you use a 2.5″ laptop drive/enclosure that does not have external power, you may need to add
max_usb_current = 1
If you want to add a 3.5″ drive, you need to get a USB drive/enclosure with its own power supply, as a Raspberry Pi will not be able to supply enough current to such a drive.
After adding such a drive, you will see that the performance available from USB hard drives is fairly decent given the USB2.0 limitations.
Raspbian will automatically recognize the USB hard drive when you plug it in. If you just want it to store/retrieve files, the file manager will let you access the new drive easily.
If you want the drive to be mounted when your Pi boots, you will have to make a permanent mount point for it, for example:
sudo mkdir /pi/usbdrive
and then add a line to /etc/fstab (use sudo nano /etc/fstab)
/dev/sdb1 /pi/usbdrive ext4 errors=remount-ro 0 1
(the above assumes the USB drive is on /dev/sdb, with the partition you want to mount on /dev/sdb1, and is formatted with the ext4 file system. Change ext4 above to vfat if it is formatted to vfat)
A Raspberry Pi is a LOT Snappier when running off a USB hard drive.
If you want to add a large hard drive because you want to use your Raspberry Pi as a small server (NAS) you should realize that the Raspberry Pi is also limited by the 10/100Mbps Ethernet controller going through the same single USB2.0 channel as the rest of the USB ports.
Basically, you can think of the USB2.0 limitation as being a single lane bridge with a 48Mph (480Mbps USB2) speed limit, with five on-ramps feeding into it.
As long as there is little traffic coming from the on-ramps, the traffic can zip over the bridge at 48Mph.
If there is too much traffic coming, we have congestion at the bridge, and the bridge cannot even support 48Mph.
Short of building another bridge, and splitting the traffic, you are stuck.
If there is no room for another bridge (ie cannot add more bandwidth via GPIO) there is NO WAY to increase throughput.
If you need more speed than a Raspberry Pi can provide, there are plenty of other single board computers that are better for specific applications.
BUT NONE of them have the support of the Raspberry Pi forums!
If you need:
If you would like to learn more about the USB bottleneck, read:
If you would like to read about using a Raspberry Pi 2 as a NAS, read:
If you would like to see SATA and USB speed differences between a Raspberry Pi and a Banana, read:
If you would like to see the Ethernet performance differecnes between a Raspberry Pi, Bananas, and Odroid C1’s, read:
I hope this article has helped you understand more about the Raspberry Pi!