I have never used Linux before about last Saturday, and I actually don't have that much programming experience, but I'm getting very good results and products with my limited Linux programming ability right now. So of course after having produced a something which I like, I want to now use my raspberry pi for something totally different. I don't have an infinite number of SD cards, in fact I only have a couple, so I want to now backup my fully functioning SD card with all of its modifications which I have made, and then wipe it and download a whole new type of package and try something else on my raspberry pi. But of course I want to be able to go back to what I have later if I want to continue with what I'm doing, or install it on another pi which I am sure I will buy in the not-too-distant future.
So, how do I save my pi settings onto another SD Card which I can then put onto a different pi?
For this procedure you will need a USB hub, an SD card reader, and an SD card equal or larger in size to the SD card that the RPI is using.
Being a newbie, and fighting my way through some forms, with a great deal of persistence necessary to get what I want, I am now able to tell you all that I have succeeded in finding what I believe is the easiest way imaginable to save your raspberry pi configuration on a chip, including all of its disk partitions, in such a way as to later be able to put it back on a different chip and reinstall your pi from it.
Basically what we're doing, for all you Windows users, is to copy the system drive to another drive and then boot up from it to test it.
I have also included an explanation which will basically show you what each part of the command does so that a total newbie can understand what you're telling the computer to do.
The first thing you want to do is to format the SD Card. Put it into any Windows PC and utilize the SDformatter program which you download from the raspberry pi foundation, and usually comes bundled in their extractable zips. Format the drive with quick formatting, and format size adjustment option off.
Next, boot up the Pi snd log in. Don't have the USB hub or SD cardreader in it, just the pi and it's System SD Card. Now you're going to display all of the file system devices in a human readable fashion. And the command for that is the following:
"df -all -h"
you will see a list of devices. You don't have to pay much attention to it yet.
Now put the formatted SD card into the pi with the SD card reader. Type in these 2 commands, one of which will give you an error message, and the other should work:
sudo mount /sda1 /usb
sudo mount /sdb1 /usb
which means "SuperUser Do - mount Serial Drive port A1 (or B1) - to the '/usb' directory." One of them, A1 or B1, will be the correct USB port, depending on where you have put your stick, and the other one gives you the error.
Wait a few seconds, then display the file system again (use the up arrow to redisplay the previously entered command, and press enter again)
"df -all -h"
And at the bottom of the list you will see something that was NOT THERE in the first listing. Something like '/dev/sda1 7.5G 32K 7.5G 1% /usb' which is telling you that your second SD Card is on device address 'SDA1', 7.5 GB size, 32 KB used, 7.5 GB available, one percent used, and is mounted on the /usb directory. Perfect.
So now that you have your system card working (which it obviously is because you're running Linux on the pi) and you have successfully inserted your second SD card, it's time to do the actual copy. So here goes. Enter the command, and here is exactly what I typed into my command line to make it do what I wanted it to do:
"sudo dd if=/dev/mmcblk0 of=/dev/sda1 bs=1M"
where the correct USB SD port must be specified as per what you found at the end of the "df -all -h" command listing.
Here is the explanation of that last command:
"SuperUser Do Disc Duplication - input file =/device/multimedia chip block zero - output file = device/serial drive A1 - block size equals 1 MB (copy across in 1 MB chunks)"
You will see the activity light on the pi go on to show there is something happening. And then wait for about 10 - 20 minutes depending on the size of your system SD card. At the end you will have all of the fully operational partitions on your other SD card.
Put your newest the card into the system slot on the RPI and rebooted using the command "sudo reboot". I prefer to use this command rather than just pulling the plug because this command will save all of the commands you have typed in in memory, so you can later cycle back through them using the up arrow from the commandline. It takes a few more seconds to reboot but is worth it. If the RPI boots successfully from the newly copied card, then you have done well. Go and have an ice cream, on me!
Of course you're probably going to want to get into the new system card now and copy files onto your PC. If you look at the new card on a PC computer it will show up as unformatted. That is because windows can't read the Linux file systems. But don't try to reformat it to read it, because obviously you will erase everything you just did. You will have to boot the PC up in Linux to read it or see it. And that's going to be somebody else's forum, not mine.




