Add a hard disk to your Raspberry Pi


The RasPi usually boots from an SDCard which has limited storage capacity. The following describes how to add a USB hard disk or SSD drive to a Pi and prepare it to store data, using the command line.

It is possible to get a Raspberry Pi to boot from an external drive, but I'm not convinced of the advantages. I prefer to stick to booting from the SDCard, which is cheaper and easier to replace when it dies. This should also mean fewer read/writes to the external drive, theoretically making it last longer. I will also be formatting the drive with the native 'Nix ext4 file system, but drives already formatted as NTFS or FATxx should be readily accessible.

I am connecting the drive to a Pi with no keyboard, mouse or monitor and have already installed an operating system (I recommend Raspian) with SSH access to the Raspberry Pi.

USB3 Hard Disk

I have added 2.5" Samsung 500GB SATA hard disks and also SSD drives with no issues, exactly the same process. The Pi3 was able to power one drive from the USB port without the need for a powered USB hub. I used a USB3 lead for the hard disk and the USB C-type for the SSD drive. Both are backwardly compatible with the Pi's USB2 ports but the drives will transfer data slower compared to using the USB3 ports found on the Pi4.

If the drive is plugged in after boot and you are running a GUI, then the system should recognise and mount the drive automatically. On command-line only systems, use the mount command as shown below. I'm booting with the drive already in and using an FSTAB entry to make the system mount it on boot.

Always back up the data on the external drive. This is particularly true before attempting to put it into a new system.

Plugging the drive into the USB port should cause the operating system to recognise the drive and (quietly) add an entry into the /dev (devices) directory. To see the entry for the new hard disk, run the following command..

sudo  blkid

The new drive is usually listed at the bottom. Here's an example of my own results..

Note the Samsung drive (previously labelled by me and NTFS formatted) is listed as /dev/sda5 which is a typical notation. The other entries refer to the SDCard. These notations are needed to mount drives for use.

At this stage, if it has an existing partition, you can mount the drive to make it accessible. This involves creating a new directory and mounting the drive to make the data accessible through this directory. By convention drives are mounted to directories inside the /mnt directory, but this is not compulsory. I'm going to make my drive's NTFS partition accessible through a new directory called "samsung" (note Unix is case sensitive)..

sudo mkdir /mnt/samsung

Finally run the mount command to link the drive identifier to the new directory..

sudo mount /dev/sda5 /mnt/samsung

This assumes the operating system running on your Pi has support for accessing NTFS partitions. Recent versions of Raspbian have at least read support. Access the data on the drive by changing to its mounted partition..

cd /mnt/samsung

Formatting drives with a file system

If there is no existing filesystem or you wish to change to another, the mkfs command can be invoked. Note this must be done before mounting the drive (sudo umount /dev/sda5 - using your own device name - will unmount a drive).


EXT4Best performance is through using the 'Nix EXT4 filesystem, which is not natively supported by Windows, but I do not plan to remove the drive to plug into any other systems..

sudo mkfs.ext4 /dev/sda5 -L somename

- where somename can be some name of your choice.

This took 1 minute on a Toshiba 1GB external USB3 drive, and a few seconds on the SSD. Grin! If there are delays here then you may have a drive which has problems. This happened to me and the drive would not mount properly on boot. Use the fsck -y /dev/sda2 (using your own sda device name) command to check for boot errors.

To format the drive as NTFS, use..

sudo mkfs.ntfs /dev/sda1 -f -v -I -L somename

Other filesystems can be used but are not recommended.

Automatically mount a drive


At the moment the drive will need to be mounted manually when the system reboots. Editing the file system table fstab will mount the drive on startup. Take care with editing this file as errors may cause the system not to boot. Using the editor of choice..

sudo vi /etc/fstab

Add a new line to the end of the file, modifying the details to suit your system..

/dev/sda5 /mnt/samsung auto defaults,user,nofail 0 1


/dev/sda5 is the identifier of the drive to mount (yours may differ)..

/mnt/samsung is the mount point, the directory to access the content of the drive..

auto detects the file system type..

The entries defaults,user,nofail are mount options:
user enables write permission for all users; replacing this with ro would make the drive read-only
nofail tells Raspbian to ignore this entry if the USB drive is not plugged in.

Note the required use of non-spaced commas to separate multiple options

0 is a binary value used for debugging. It is best to keep this set at zero.
1 - pass number for a file system check at boot. 0 (zero) to disable or 2 to enable.

Double check your entry. Save the changes to fstab and exit the editor. Reboot..

AndyM | Updated Aug 2019