Posts: 1
Joined: Tue Mar 24, 2015 10:00 am

cloning SD card

Tue Mar 24, 2015 10:11 am

Hi all
i'm having a lot of troubles trying to clone my 8gb SD card.

i bought 3 new 8 gb cards but the real space into them is 7.94.
my non compressed image is 7.96, so i can't copy my card.

i have been trying differents scripts and solution, but i couldn't get a positive result.
so i'm stuck.

i got 2 questions:
Do you have an easy solution for that? i mean, i'm not super competent, so i can't go thru serious big scripts, but if you know a SW that, under Mac os, could resize the image of the original card eliminating at least 2 mega of empty space, it should be for me very helpfull.

2) do you know what happens if i copy an image of an 8 giga SD card to a 16 giga sd card?
it's going to work anyway? i got three partitions in my orginal card and i don't understand what will happens to the 8 giga more the i would have in the new one.

thank you very much


Posts: 917
Joined: Sun Jul 29, 2012 9:06 pm

Re: cloning SD card

Tue Mar 24, 2015 12:46 pm

If you copy the 8 gig image to a 16 gig card, that one will have the same partitions and 8 gig of unused space after the last partition.

You can install gparted on the Pi to decrease the size of the last partition so that the system fits on a smaller 8 gig card. I can't remember if the program will be able to perform those actions on a partition that is mounted as rootfs. I use a virtual debian setup on my pc to perform this action. (running debian in virtualbox) Connecting the sd card to the Pi as a secundary storage device using an usb2sd cardreader should work as well. The image will still be to big as it's basically a binary copy of the sd card sectors, not knowing what the size of the partitions is. I use winhex (a windows program) for that purpose. It will give some errors at the end of it's copy transaction (when the target card is 2 small) but it will happily copy wathever it can. As the partition was made smaller previous, it will not corrupt data on the last partition.

Gparted can also be used to extend the last partition on a 16gig card so that it uses all 16gig.

In linux, you can use dd to copy only the first part of the sd image to another sd card. You can tell it how much blocks it's allowed to copy. Just be carefull with that command as it's nickname is "disk destroy"

User avatar
Posts: 10578
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: cloning SD card

Tue Mar 24, 2015 1:15 pm

take the new card
partition into 2 drives
a fat32 [type c under fdisk]
linux [type 83]

create a file system on both
mkfs.vfat /dev/sd?1
mkfs.ext4 /dev/sd?2

mount drives
mount /dev/sd?2 /mnt
mount /dev.sd?1 /mnt/boot

copy file systems
cp -ax / /dev/mnt
cp -ax /boot/ /mnt/boot

[or use rsync
rsync -avxHAWX --numeric-ids / /mnt/
rsync -avxHAWX --numeric-ids /boot /mnt/boot
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV


Return to “Troubleshooting”