BLL
Posts: 217
Joined: Fri Jun 07, 2013 2:30 pm

Cloning/copying SD card

Thu Sep 08, 2016 11:08 am

Hi,
Can anyone help? I have my RasPi model 3 image on a 16GB microSD card. It is considerably different from the initial install. I tried to clone the card to another card but I find that the new card is a few MB smaller! That means that I can't use Win32DiskImager either. In neither Ease-US Partition Master nor MiniTool Pro will it let me resize the ext4 partition (you can select the option but it won't let you resize it!). Considering that most of the ext4 partition is empty, we seem to have a ludicrous situation!

Is there any way round this problem please?

Thanks

Brian

User avatar
RaTTuS
Posts: 10484
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Cloning/copying SD card

Thu Sep 08, 2016 11:21 am

How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

BLL
Posts: 217
Joined: Fri Jun 07, 2013 2:30 pm

Re: Cloning/copying SD card

Thu Sep 08, 2016 12:23 pm

Hi, Thanks for the reply. rpi-clone is not installed under jessie, but I downloaded it from git-hub.
Interestingly, it says you can clone to an SD card, but none of mine show when plugged into the Pi via a USB converter.
I next tried a 16GB memory stick (both formatted and unformatted), but the Pi can't find that either! Therefore I am stuck!

Brian

User avatar
RaTTuS
Posts: 10484
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Cloning/copying SD card

Thu Sep 08, 2016 12:33 pm

plug in sdcard
sudo fdisk -l
it should show the new sdcard [possibly /dev/sda]
sudo fdisk /dev/sda #^ what was reported there
create a fat partition and an linux partition
from memory not tested :-
format them
sudo sh
mkfs.vfat /dev/sda1
mkfs.ext2 /dev/sda2
now copy files
mount /dev/sda1 /mnt
cp /boot /mnt
you may need to edit the new /mnt/cmdline.txt so its root is correct /dev/mmclk0p2
umount /mnt
mount /dev/sda1 /mnt
rsync -ax / /mnt
umount /mnt

shutdown
test sdcard
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
pi-anazazi
Posts: 555
Joined: Fri Feb 13, 2015 9:22 pm
Location: EU

Re: Cloning/copying SD card

Thu Sep 08, 2016 2:18 pm

viewtopic.php?f=91&t=150324&p=988162&hi ... zi#p988162

....if you have a root password in place, run from the CLI

Code: Select all

gksudo piclone
Kind regards

anazazi

User avatar
RaTTuS
Posts: 10484
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Cloning/copying SD card

Thu Sep 08, 2016 2:26 pm

aha yes piclone that was the thing
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

BLL
Posts: 217
Joined: Fri Jun 07, 2013 2:30 pm

Re: Cloning/copying SD card

Thu Sep 08, 2016 6:47 pm

Hi, Thanks for the detailed instructions, but I am getting stuck!

if I use sudo fdisk -l, I see an entry for sda1, which is a HD, currently not used.
I also see sdb, which is my SD unformatted card, but, there is no SDBx following it.
Next, I formatted the SD card as all ext2 on my PC, using MiniTool Partition Wizard.
Now I plugged it into the Pi again and this is what fdisk -l gave me:

Disk /dev/sdb: 14.9 GiB, 15931539456 bytes, 31116288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Again, no mention of sdb1 or anything after what you see above - just the same as when the card was unformatted.

I am lost!

Brian

User avatar
davidcoton
Posts: 4180
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Cloning/copying SD card

Thu Sep 08, 2016 7:16 pm

Did you try this bit?
RaTTuS wrote:create a fat partition and an linux partition
from memory not tested :-
format them
sudo sh
mkfs.vfat /dev/sda1
mkfs.ext2 /dev/sda2
Sorry I've not tried it myself, so I can't comment on any errors or omissions. :(
Signature retired

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5104
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: Cloning/copying SD card

Thu Sep 08, 2016 7:40 pm

@BLL Does the card you want to clone include the new "SD Card Copier"** tool? I've certainly used that without issues to clone a Jessie card to one of similar size (and, IIRC, it's meant to handle, to some extent, cloning to a "smaller" card):
https://www.cpmspectrepi.uk/raspberry_p ... _a_Pi_Zero
Trev.
**Originally described in the blog here:
https://www.raspberrypi.org/blog/anothe ... -raspbian/
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, B2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, A+ and a B2) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

User avatar
nl3prc
Posts: 160
Joined: Sun Jul 24, 2016 12:39 pm
Location: Den Helder the netherlands

Re: Cloning/copying SD card

Thu Sep 08, 2016 8:16 pm

piclone is not working in a ssh shell so you have to start xwindows first this is not alway's a option

User avatar
nl3prc
Posts: 160
Joined: Sun Jul 24, 2016 12:39 pm
Location: Den Helder the netherlands

Re: Cloning/copying SD card

Fri Sep 09, 2016 8:21 pm

when you insert your card in usb port what is df -h tels you

hhoanganh
Posts: 44
Joined: Thu Apr 24, 2014 8:38 am

Re: Cloning/copying SD card

Sat Sep 10, 2016 3:24 am

If you can, please try SD Card Copier application, it's the best one compares to other solutions using command or Win32DiskImager. I had an image that runs some apps at start up, before i meet SD Card Copier, other solutions just helped me make the cloned sd card runs for a few hours at best.

User avatar
nl3prc
Posts: 160
Joined: Sun Jul 24, 2016 12:39 pm
Location: Den Helder the netherlands

Re: Cloning/copying SD card

Sat Sep 10, 2016 9:33 am

I made a copy with rpi-clone from a 64gig to an 32gig and had no problems
The 32 gig is still running after a 30 days
so there must be something going on with your raspberry or sd card but i don't think it is rpi-clone

AlonOr
Posts: 2
Joined: Thu Jan 04, 2018 8:07 am

Re: Cloning/copying SD card

Thu Jan 04, 2018 2:15 pm

You can use PiShrink, it will shrink the size of your image then the first time you boot from this shrinked image it will autoexpand to the size of your new SD card, I would use it even if there is no need to use a smaller SD card because usually the backup image contains whitespace and they are unnecessarily the same size of your original SD card.

so just gi t-clone it to your distro:
git clone https://github.com/Drewsif/PiShrink.git

then run it against your big fat original image:
sudo ./PiShrink/pishrink.sh MyBigFatImage.img NewSlimImage.img

If you omit the new file name it will work directly on your original image without wasting space.

Once it finishes (very fast) it will inform how much it shrinked, in my test it went from 8gb to 2gb.

One nice feature of PiShrink is that once you boot for the first time of the compressed image the PI it will expand and take the whole SD card then auto-reboot in about a minute once it finishes expanding, so you have all the space available to use.
It`s very important to let it reboot before you start using your newly cloned PI.

If you want a more complete guide go to viewtopic.php?t=145712#p1254148

Return to “Advanced users”