Quantcast
Channel: vox populi vox dei
Viewing all articles
Browse latest Browse all 67

Backup raspberry pi accidently installed on big SD card to smaller SD card

$
0
0

You have a 32GB SD card.
You are using 1.8GB of space on it.
You want to back it up into an image that is 1.8GB big, not 32GB big.
Then you want to be able to put it on an SD card that is 2,4,8 or 16GB big.

Make a Backup Image of Raspberry pi SDCARD!

It took a while to get your SD card set up, didn't it? Bet you don't want to have to do that again, do you?

Well,

Back it up!

Forum user, Mac user, and Adafruit Customer phil.drummond took it upon himself to find the best way to back up his system image.

And he found a fast and easy way - a script which quickly creates a clone of your running Raspberry Pi system, ON THE PI ITSELF!

What You'll Need

  • USB SD Card Reader
  • Blank SD Card
  • Booted and Running Raspberry Pi

Get the Script File

First, get a copy of the script file onto your Pi. You can do that in any one of several ways:
  • First, download the file to your computer
If you are looking for rpi-clone, it is now on github and no longer
available from pastebin.

Get it with git:

    $git clone https://github.com/billw2/rpi-clone.git

or

wget https://raw.github.com/dweeber/rpiwiggle/master/rpi-wiggle

To view the rpi-clone README file, go to:

Run the Script

  1. Put the blank SD card into your USB Card Reader, and plug it into one of the PI's USB ports.
  2. Open a Terminal window on the Pi
  3. Navigate to the folder where you stored the script file. (If you stored the file on the Pi's Desktop, simply type 'cd Desktop')
learn_raspberry_pi_script_1.png
When you run the script, you will have to specify the name of your SD card. Raspbian and occidentalis assign the names 'sda', sdb', etc. to SD cards found on USB. If you only have one USB card reader attached, the name of your new SD card will be 'sda'.If you're not sure that sda is the right card, you can run this command to list the cards connected to your Pi. 


  1. sudo fdisk -l


The SD card slot with your running Pi system will show up as /dev/mmcblk0. Your blank card will be listed as /dev/sda1 (or possibly /dev/sdb1, if you have more than one USB card readers attached to the Pi).

Note that you don't enter the '1' - if your card is listed as '/dev/sda1', then you would still enter 'sda' when you run the script ('sda' is the name of the card, 'sda1' is the name of the first partition on the card).

Ok, so now you should be ready to run the commands

  1. chmod +x rpi-clone.sh

  2. sudo ./rpi_clone sda -f


As noted earlier, the first parameter passed to the script is is the name of the target SD card, in this case 'sda'. The -f tells the script to entirely re-format the card.

The script will ask you if you're sure you want to initialize the destination card. Type 'y', and hit the return key.
learn_raspberry_pi_script_2.png

Next, the script will ask you if you want to give your new backup a label. It's not necessary to do this - just hit the return key.
learn_raspberry_pi_script_3.png
Finally, the script will ask you if you're sure you really want to do this, before it begins creating the backup. Type 'y', and hit the return key.


learn_raspberry_pi_script_4.png

Now it's time to wait - the process will take a little while.
learn_raspberry_pi_script_5.png
When the process is complete, the script will ask if it should unmount the card with your new system clone/ Reply with 'y', and you're done!
Now you can shutdown the Pi, swap the clone into the Pi's SD Card Slot, and restart - Bingo! a fully-operational clone of your Raspberry Pi system!

Problems?

If you see an error message like this:
learn_raspberry_pi_script_error1.png
...it means that your SD card is mounted in the file system. You have to unmount it before you can proceed. In the picture, I'm writing over an earlier clone of my system, which has two partitions: /dev/sda2 and /dev/sda1. You might only have one partition.

In any case, issue the umount command for each mounted partition on your destination SD card:

  1. sudo umount /dev/sda1


learn_raspberry_pi_script_error2.png
Now try to run the script again!

Viewing all articles
Browse latest Browse all 67

Trending Articles