As a Raspberry Pi user, sooner or later you will stumble over the question of how to connect a USB stick, external hard drive or SD card to the Raspberry Pi and access it.
The process is similar for all drive types. Whether USB stick, external hard drive or SD card. After connecting to the Raspberry Pi, the corresponding drive must first be integrated or mounted.
I have described how you can do this in the following article.
I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/en/sicherheitshinweise/
Affiliate links / advertising links
The links to online stores listed here are so-called affiliate links. If you click on such an affiliate link and store via this link, Nerdiy.de receives a commission from the online store or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support Nerdiy.de in being able to offer further useful projects in the future. 🙂
Before you start this article, you should have prepared a Raspberry Pi so that it can be reached via the network and controlled via SSH.
The following articles describe what needs to be done to prepare the Raspberry Pi.
- RaspberryPi - Setup for nerdiys!
- RaspberryPi - The first configuration!
- RaspberryPi - Control the RaspberryPi via SSH
In the following lists you will find all the parts you need to implement this article.
|1x||Screwdriver set Buy at Amazon|
|1x||SD card reader Buy at Amazon|
|1x||Raspberry Pi Buy at Amazon|
|1x||Raspberry Pi power supply Buy at Amazon|
|1x||Raspberry Pi case Buy at Amazon|
|1x||Micro SD card 64GB Buy at Amazon|
Log in via SSH on the RaspberryPi
To get started, you first need to log in to RasPi with SSH on Putty. How to do it is described in the article
Show detected drives
Before you can mount your drive, you should check whether it has already been recognized. This way you can also find out the name of the partition which you will integrate later.
By entering the command
you can display the recognized drives.
There you can then see all connected drives (first red arrow next to "disk") and associated partitions (second red arrow next to "part").
At this point, remember the name of the partition you want to mount/include. In this example it would be "sda1".
For drives that are already mounted/integrated, you can see the corresponding path in the "Mountpoint" column.
Prepare mount path
Before you can mount your drive, you must first select a mount point. In principle, the mount point is a simple directory on your system drive (in the case of the Raspberry Pi, the system drive is the SD card on which you also installed the Raspberry Pi image). You can also simply create a specific directory or folder to create a mount point.
For example, you can create a directory in the temporary folder.
Using the following command
the folder "mountPoint" is then created in the temporary folder, for example. This temporary folder is emptied after every restart of the system. This also removes the mount point.
Now that you have created a mount point, you can mount the connected drive.
For this you need the information from the previous steps.
- partition name: sda1
- Mount Point: /tmp/MountPoint
Now you can mount your drive with the following command:
sudo mount /dev/sda1 /tmp/mountPoint/
It is important that you don't just specify "sda1", ie the partition name. Here you have to enter the complete absolute path (including /dev/).
Access the mounted drive
After you have integrated the drive as described above, you can of course also access it.
To check whether the drive was mounted correctly, you can use the command
This lists all drives including the mount point. You can find the entry for the example used here in the bottom line. The left column shows the partition path (/dev/sda1) and the right column shows the mount path (/tmp/MountPoint).
If you now switch to the mount path (/tmp/MountPoint) you can display the contents of the mounted drive.
For example, if you now want to copy a file to the integrated drive, you must select the MountPoint of your integrated drive as the target.
More articles on the topic
In the following category you will find further links on the subject of Rasperry PI.
Have fun with the project
I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂
P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate that I share this information with you, I would be happy about a small donation to the coffee box. 🙂