Virgus Posted September 18, 2015 Posted September 18, 2015 I need to clone a bigger (almost empty) sd card to a smaller one. I use rpi-clone on RPIs but since armbian has a single partition rpi-clone (or its forks) doesn't seem to work :-/ https://github.com/billw2/rpi-clone.git https://github.com/KoljaWindeler/pi-clone https://github.com/wbphelps/rpi-clone-wm.git Has anybody used successfully rpi-clone or other similar scripts on armbian? What is the best way for creating the smallest img files possible? With my RPIs I clone SDs to smaller ones, then I "zerofree" the created card and I backup it to an image file. I'm currently using this software on Windows which creates compressed img files so that I have no need of zipping files, but there might be better options out there... Please share with me your experiences about efficient (and possibly fast) backups. Thanks, V.
Igor Posted September 19, 2015 Posted September 19, 2015 Check this: https://github.com/igorpecovnik/lib/blob/second/common.sh#L240 Input is RAW image, output minimal RAW image with 15% free space. Works with one or two partition.
Virgus Posted September 19, 2015 Author Posted September 19, 2015 That's great Igor, thank you so much, it will be really a useful script to use from now on. For the raw image, since the BPIs have the SATA drive, is it fine to simply use DD? sudo dd if=/dev/mmcblk0 of=/mnt/sda1/SD_Backups/BPiArmbian.raw I'm trying it for the first time, is there a way with dd to copy only the used part of the SD, to speed up the process? Thanks again, V.
Igor Posted September 19, 2015 Posted September 19, 2015 DD is direct copy and you can use it almost anywhere. If you want to speed up the process - shrink data partition on the drive, save only partitions (separate) and expand back. But in this case you are not saving the boot loader. You need to save it separate. 1
Virgus Posted September 21, 2015 Author Posted September 21, 2015 Hello Igor, I had problems trying to use your function shrinking_raw_image () directly on the Armbian release I'm using. So I tried copying the partition as you suggested but the "cloned" card did not boot. I used some instructions I found on the web to extract the bootloader from the MBR backup #Backup MBR dd if=/dev/mmcblk0 of=/usr/local/sbin/mbr_sdcard.img bs=512 count=1 #Restore Bootloader dd if=/usr/local/sbin/mbr_sdcard.img of=/dev/sdd bs=446 count=1 According to what I understood Armbian SD card consists only of bootloader MBR and the ext4 partition. Am I correct? Besides the former commands I did the following: created a single ext4 partition on an external sdcard, mounted it to /mnt/sdd1 and rsynced the contents from mmcblk0 to sdd1. This is more or less the sequence of actions used by rpi-clone scripts. Am I missing something?
Igor Posted September 21, 2015 Posted September 21, 2015 This scripts is designed to work with images. So it's only an example / idea , not for direct usage in your scenario. I am not sure that bs=512 is enough. It's different for each board architecture so double check. This is how we write it Allwinner: dd if=u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=1024 seek=8 Yes, armbian has only one ext4 partition.
Virgus Posted September 21, 2015 Author Posted September 21, 2015 Hello Igor I tried without success but at the end I found a solution (sort of). I restored a clean Armbian raw image to my sd and then zeroed it and used rsync to backup my original sd to the smaller one. Rsync took less than 2 minutes (2Gb of data on my SD) and I now have a compressed raw of 1.3GB! Not the ideal solution but it's a good compromise at least. Thanks and have a nice day,V. 1
Recommended Posts