How To Backup And Restore SD Card For Raspberry Pi
Table of Contents
After having successfully recorded a system for our Raspberry Pi on our SD card it is almost certain that we will carry out some tests of the new system, as well as make personalization settings on it.
But one thing I am sure of is that you have had to perform this process more than once, for the simple fact that there are several systems for this device you have done the task of testing them to see which is the one that fits your needs.
This process can generate that you can lose some configurations of some system that previously you used and that of losing them can later regret having made the change.
To avoid this type of regrets we can carry out a preventive backup of our SD card and be able to save those systems and configurations that we believe are convenient.
And not only that we must also consider that SD cards tend to have some time to live, so it is never necessary to carry out a preventive backup.
So if you think it is time to back up your SD card, I invite you to follow the instructions below.
One of the simplest ways to back up the information contained in our SD card is to make a full copy of its contents.
What we are going to do with this is to create an image of the SD card which we will be able to save to later be able to carry out the restoration.
Then to perform this task it is necessary that we extract the SD card from our Raspberry Pi, which we must disconnect from the power supply.
How to make a backup of our SD card?
Now we must place our card on our computer in our card reader or with the help of an adapter. Once this is done, we must open a terminal and execute the following command to know the mount point that our SD has.
sudo fdisk -l
With this command, we will see the mount point, as well as all the partitions that our card has. Almost default is usually the mount point / dev / sdb or / dev / sdc although if they have more storage devices connected this mount point can vary.
In my case it is the / dev / sdb , we are going to ignore the partitions / sdb / sdb1, sbd2, sdb3etc. Those do not interest us.Now on the terminal, we will execute the following command –
sudo dd bs=4M if=/dev/sdb of=imagenraspberrypi.img
You will notice that the command is similar to the one we use to record the disk images, only that we change the mount point and the path of the parameter image.
In the case of those who are Windows users, they can make use of the same tool that is recommended to record Win32DiskImager images.
Here the way to do it is by selecting the icon of the folder as if we were going to look for the disk image, but here we are going to create the name of our image.
We can position ourselves in the folder where we want to save the backup image of our SD. Now let’s select the path that the SD card has. And we will see that the only button enabled is “Read” which we will press to start the process to backup our SD card.
At the end of the process, we can verify that the image is in the route we indicate.
How to restore a backup of our SD?
An important point is that you should know that this backup can only be recorded on an SD card of the same capacity, never lower.
I have not tried it with higher capacity cards, but generally, this process can generate some conflict, since the partitions and sectors are a vile copy.
If you have another SD card or want to restore the backup that you created, you can do it by following the same instructions that you follow to record a system on the SD card of your device. So the process is the same and if you have an SD card of the same capacity you can perform the test on it.
LinuxAndUbuntu Newsletter
Join the newsletter to receive the latest updates in your inbox.