The connection of the hard drive is similar to the connection of the USB with Raspberry Pi. In this write-up, we will learn the procedure to mount the hard drive with Raspberry Pi.
How to mount the hard drive with Raspberry Pi
There are two ways to mount the hard drive with the Raspberry Pi either by manually or automatically, we will discuss both the methods in detail but before proceeding towards it, we will update the repository of the Raspberry Pi using the command:
How to mount the hard drive manually with the Raspberry Pi
To mount the hard drive with the Raspberry Pi, first we have to find out the UUID details and location of the device, for this purpose, we will run the following command:
The UUID of the hard drive which is labeled with the name “WD Unlocker” is “550e29b200000000” and the location of the hard drive is /dev/sr0. After this, we will make a directory of “MyHardDisk” in the media folder using the command:
The above directory is made to mount the hard drive in it, so we will change the access permissions of the newly created directory so that it can be accessed by the Pi user of the Raspberry Pi using the command:
Now we will mount the harddrive by using its location that is “/dev/sr0” and the directory path “/media/MyHardDisk” where it is supposed to be mounted:
We can see the mounted Hard drive on the desktop:
To unmount the Hard drive, we have to run the following command:
We can confirm from the desktop that the hard drive has been unmounted:
How to mount the hard drive automatically on the Raspberry Pi
In the above-discussed method, we have to mount the hard drive every time the Raspberry Pi has been started, so another way to mount the hard drive is by automatic method, it will mount automatically when the Hard Drive is inserted in the Raspberry Pi. For this purpose, we have to first open the file of fstab using a nano editor:
Type the following line in the file and change the UUID according to your unique UUID of the hard drive:
Save the file by using the shortcut key of CTRL+S, then exit the editor and reboot the Raspberry Pi using the command:
When the system is restarted, you can see the mounted hard drive on the desktop screen of Raspberry Pi.
Conclusion
The hard drive has a large storage capacity as compared to the USB so it is used to back up the data of the system as well as it has a longer life and high speed. By default, the hard drive can be mounted with the Raspberry Pi automatically but sometimes it does not mount automatically. In this write-up, we have explored the methods to mount the hard drive with the Raspberry Pi both manually as well as automatically.