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,
Now it's time to wait - the process will take a little while.
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!
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
To view the rpi-clone README file, go to:
Run the Script
- Put the blank SD card into your USB Card Reader, and plug it into one of the PI's USB ports.
- Open a Terminal window on the Pi
- Navigate to the folder where you stored the script file. (If you stored the file on the Pi's Desktop, simply type 'cd Desktop')
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.
- 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
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
- chmod +x rpi-clone.sh
- 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.
The script will ask you if you're sure you want to initialize the destination card. Type 'y', and hit the return key.
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.
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.
Now it's time to wait - the process will take a little while.
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:
...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:
In any case, issue the umount command for each mounted partition on your destination SD card:
- sudo umount /dev/sda1
Now try to run the script again!
Issue on some sdcard
Issue on some sdcard
How can I reclaim the full capacity of an SD Card ?
First, let’s take a peek at what the SD card looks like if you attempt to reclaim the space using Disk Manager as you did:
You can format the tiny 64M FAT32 partition, but the remainder of the SD card remains “Unallocated” after you dump the existing (and inaccessible) Linux partition. No amount of pushing or shoving in the Disk Manager application is going to fix this problem. Instead, we’re going to turn to the simple and effective DISKPART tool.
Open up the Start Menu and type “diskpart” in the run box. Press enter. You’ll be prompted by the Windows UAC to authorize admin access to the DISKPART tool.
A command-prompt-like window will open up, only the prompt will say “DISKPART”. At that prompt, type “list disk”.
In the list output on our machine you can see the computer’s hard drive (119GB) and the removable SD card (14GB). It is absolutely critical you note the proper disk number. DISKPART commands are immediate and without any warning. If you type in the wrong disk number, you’re going to have a really bad time.
After identifying your SD card’s disk number, enter the following command “select disk #” where # is the disk number of your SD card.
Whatever commands you execute after this point will only make changes to the selected disk; now would be a good time to double check you’ve selected the right disk just to be extra safe.
Next, now enter the command “clean”
The clean command zeroes out the sectors of the disk that contain the partition data. If you wished to zero out all data on the SD card you could use “clean all” instead, but unless you have a pressing privacy/security reason for overwriting the the entire SD card with zeros, it’s unwise to waste the read/write cycles of the flash media.
After cleaning the disk, enter the following command “create partition primary”
The command, as the syntax implies, creates a new partition on the disk and sets it to primary. After creating the primary partition, the entire storage capacity of the SD card should be available to Windows. If we peek back into Disk Manager, we no longer see a tiny partition with a huge hunk of unallocated space, but a large partition ready to be formatted:
That’s all there is to it! A little DISKPART wizardy and the SD card is factory fresh again.
No comments:
Post a Comment