nadir
Posts: 112
Joined: Sun Jun 10, 2012 5:45 am

copy install to new SD-card

Fri Jul 06, 2012 4:02 pm

I want to copy my installation to a bigger SD-card. I read that i have to use the command dd, but am not sure how.
Someone can give the detailed steps (or a link to a how-to)?
Thanks

JeremyF
Posts: 515
Joined: Wed Jan 25, 2012 9:06 pm
Contact: Website

Re: copy install to new SD-card

Fri Jul 06, 2012 4:32 pm

Do you have a Windows box? Then it's even easier...

Download Win32DiskImager
Insert current SD card
Click read (it'll make a backup image)
Insert new SD card
Click write + select the backup image of old card
{sig} Setup: Original version Raspberry Pi (B, rev1, 256MB), Dell 2001FP monitor (1600x1200), 8GB Class 4 SD Card with Raspbian and XBMC, DD-WRT wireless bridge

User avatar
Mortimer
Posts: 885
Joined: Sun Jun 10, 2012 3:57 pm

Re: copy install to new SD-card

Fri Jul 06, 2012 4:36 pm

Won't there be a need to resize the partitions after using Win32DiskImager?

PaulCheffus
Posts: 381
Joined: Tue May 29, 2012 2:51 pm
Location: Lincolnshire UK

Re: copy install to new SD-card

Fri Jul 06, 2012 8:14 pm

Mortimer wrote:Won't there be a need to resize the partitions after using Win32DiskImager?
Hi

If you have expanded the partitions on the card you are copying it should be the same on the new card. When I copied mine the image was the size of the card ~8Gb in my case but I haven't got my new card to put it on so I can't be sure yet.

Cheers

Paul
Procrastination - The Thief of Time.

User avatar
Mortimer
Posts: 885
Joined: Sun Jun 10, 2012 3:57 pm

Re: copy install to new SD-card

Fri Jul 06, 2012 8:35 pm

The OP says he wants to copy the installation to a bigger SD-card, but no one is describing the full answer. The answers given so far will leave him with an working image the same as before, and the extra capacity of his new card unused. Is there a Windows solution for resizing the partitions as well. I am a Mac user myself, and use a Virtual Machine booting a live CD ISO of GParted.

Nadir, what other systems do you have available to you?

bredman
Posts: 1415
Joined: Tue Jan 17, 2012 2:38 pm

Re: copy install to new SD-card

Fri Jul 06, 2012 8:39 pm

Use a program such as Win32DiskImager to read from one card and then write to another.

If the new card is bigger than the old card, expand the partition as shown at the end of this page
http://elinux.org/RPi_Easy_SD_Card_Setup

nadir
Posts: 112
Joined: Sun Jun 10, 2012 5:45 am

Re: copy install to new SD-card

Fri Jul 06, 2012 8:52 pm

Thanks.
I ain't got Windows
(i got it in VirtualBox, perhaps on some old machines too, but i barely use it. If in desperate need i could install it though -depending what more this thread will offer. If i must i can create a Windows installation). Else i mainly use Debian.

What i tried was the following, and i think it worked:
1) I took the new SD-card and followed the usual guide:
http://elinux.org/RPi_Easy_SD_Card_Setup

2) I inserted it in the raspberry pi, to make sure it boots.

3) I put the old SD-card back in the raspberry and booted it

4) I mounted the new SD-cared at /media/disk

5) I edited /etc/ssh/sshd_config at the raspberry and made it to:
allow root login
allow password authentication
set the port to 22

6) I used rsync, to copy the old installation to the new SD-card:

Code: Select all

rsync -av  --delete-after \
--exclude="/proc/*" \
--exclude="/lost+found/*" \
--exclude="/dev/*" \
--exclude="/mnt/*" \
--exclude="/media/*"  \
--exclude="/sys/*" \
--exclude="/tmp/*" \
[email protected]:/ /media/disk
7) I plugged the new SD-card into the raspberry, booted it, and disabled root login and password authentication in /etc/ssh/sshd_config again.

To resize the partition to make use of all space i used gparted.
In short i did the following:
dd'ed a new Debian installation to the new SD-card, a usual "installation", described in the wiki
rsync'ed the old installation to the ext4-partition.

The bigger part of my headeaches comes from the fact that i don't fully understand arm and the need for a vfat partition yet:
/dev/mmcblk0p1 on /boot type vfat (rw)
If i use dd at all i usually copy commands from how-to's (like the how-to unzip and dd the debian image to a SD-card). That makes it two things i am not good with... :-)

kartofeln
Posts: 3
Joined: Sat Jul 07, 2012 8:57 pm

Re: copy install to new SD-card

Sat Jul 07, 2012 9:02 pm

yes, I would like to make some copies of SD cards.
I want to have multiples SD cards for various things (like xmbc, LAMP stack, etc.)
right now I have a "master" SD. I edited the keyboard layout (default to german), SSH pubkey, wifi driver, etc. based on this setup I would like to install xmbc or LAMP stack.

thanks for any hints

ARaspberry
Posts: 3
Joined: Fri Jul 29, 2016 10:01 am

Re: copy install to new SD-card

Tue Aug 02, 2016 3:40 pm

I want to do this directly from the Pi. I have connected the other sd card to it. How would I copy over my whole system.(8gb -> 32gb)

B.Goode
Posts: 6342
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: copy install to new SD-card

Tue Aug 02, 2016 3:47 pm

PiClone.

See here, under the heading SD card Copier: https://www.raspberrypi.org/blog/anothe ... -raspbian/

peterlite
Posts: 720
Joined: Sun Apr 17, 2016 4:00 am

Re: copy install to new SD-card

Wed Aug 03, 2016 1:48 am

For the latest Raspbian, there is an sd card to card backup program in the menu. You plug in any USB SD card adapter and copy. I have not used it.

For Linux, there is the disk utility named disks in Linux Mint. You copy the card to a disk image on your Linux PC then restore the disk image to the new card. The new card has to be the same size or larger.

You can use Gparted to resize the Ext4 partition. I use it to make the Ext4 partition smaller before backing up the card to an image. You can then trim the image and restore the image to a smaller card. I used that technique to move a system from my 16 GB card to one of my 8 GB cards.

The Raspbian admin utility will expand the Ext4 partition to fill the whole card. I do not have a Pi in front of me to find the name in the Raspbian menu. I have used that after copying an 8 GB card to 16 GB.

I perform these operations on my Linux desktop/notebooks because that is where I store the backups. I have performed the same operations on a Windows machine by booting a live Linux Mint from a USB stick. I also have a Raspbian with the same utilities installed and boot that occasionally. I am about to set up a Raspbian NAS with a couple of mirrored disks. I will put my Raspbian card backups there and perform all the card operations in Raspbian.

No need for Windows. :geek:

My one remaining use for Windows is Microsoft project and that is only because of a university stuck in a 1990s time warp. :oops:

User avatar
Kratos
Posts: 394
Joined: Sun Apr 12, 2015 12:41 pm

Re: copy install to new SD-card

Wed Aug 03, 2016 9:20 pm

peterlite wrote:For the latest Raspbian, there is an sd card to card backup program in the menu. You plug in any USB SD card adapter and copy. I have not used it.

For Linux, there is the disk utility named disks in Linux Mint. You copy the card to a disk image on your Linux PC then restore the disk image to the new card. The new card has to be the same size or larger.

You can use Gparted to resize the Ext4 partition. I use it to make the Ext4 partition smaller before backing up the card to an image. You can then trim the image and restore the image to a smaller card. I used that technique to move a system from my 16 GB card to one of my 8 GB cards.

The Raspbian admin utility will expand the Ext4 partition to fill the whole card. I do not have a Pi in front of me to find the name in the Raspbian menu. I have used that after copying an 8 GB card to 16 GB.

I perform these operations on my Linux desktop/notebooks because that is where I store the backups. I have performed the same operations on a Windows machine by booting a live Linux Mint from a USB stick. I also have a Raspbian with the same utilities installed and boot that occasionally. I am about to set up a Raspbian NAS with a couple of mirrored disks. I will put my Raspbian card backups there and perform all the card operations in Raspbian.

No need for Windows. :geek:

My one remaining use for Windows is Microsoft project and that is only because of a university stuck in a 1990s time warp. :oops:

+1

I used to use this method all the time. Simple, fast and (most importantly) not on Windows.

Kratos
I have posted mostly with a Pi 2 running either Ubuntu MATE, or Raspbian.

teknopaul
Posts: 4
Joined: Sun Apr 26, 2015 1:51 am

Re: copy install to new SD-card

Sun May 06, 2018 5:43 pm

Assuming a Linux PC, the following should do it.

as root

Plugin the SD card to your PC, you should see 3 devices appear in /dev/mmcblk0* two have p0 & p1 suffixes these are the partitions, the dev without the p suffix is the whole SD card + partition tables.

To copy the whole PI install to /tmp us dd with if= (in file) and of= (out file)

Code: Select all

sudo dd bs=4M if=/dev/mmcblk0 of=/tmp/pi.img
Then plugin your new SD card and run the reverse

Code: Select all

sudo dd bs=4M if=/tmp/pi.img of=/dev/mmcblk0
The new SD card now has a copy of Linux on and will run when you plug it into a rpi.

To extend the partitions to the full size of the SD card use the pi itself.

Code: Select all

sudo raspi-config
- 7 Advanced Options
- A1 Expand filesystem

you will need to reboot after doing this, the next boot ix expands the FS / partition before mounting it.

wcndave
Posts: 3
Joined: Thu Nov 09, 2017 5:30 pm

Re: copy install to new SD-card

Fri Aug 17, 2018 4:05 pm

The best way 100% was mentioned before, however was not clearly described.

1. ssh to your pi
2. run "sudo raspi-config"
3. Choose "advanced options"
4. select "expand filesystem"


Done, easy!

LTolledo
Posts: 529
Joined: Sat Mar 17, 2018 7:29 am

Re: copy install to new SD-card

Sat Aug 18, 2018 11:01 am

copy install to bigger (or smaller) microSD card..

I always use SD Card Copier in Raspbian Desktop... much easier with just a few clicks of the mouse.

I haven't tried it yet but there is a CLI version that is also available (not the dreaded "dd")
https://github.com/billw2/rpi-clone
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

n67
Posts: 788
Joined: Mon Oct 30, 2017 4:55 pm

Re: copy install to new SD-card

Sat Aug 18, 2018 11:23 am

LTolledo wrote:
Sat Aug 18, 2018 11:01 am
copy install to bigger (or smaller) microSD card..

I always use SD Card Copier in Raspbian Desktop... much easier with just a few clicks of the mouse.

I haven't tried it yet but there is a CLI version that is also available (not the dreaded "dd")
https://github.com/billw2/rpi-clone
Yes. The now built-in SD Card Copier is a good thing.

But I think it is important to realize that what makes SD Card Copier a good thing is precisely the fact that it is doing a file-level copy (i.e., using file level commands like "cp") rather than an image-level copy (using commands like "dd").

I.e., SD Card Copier is just doing what sensible people have been recommending all along - namely, to do your backups via file-level copying rather than ditzing around with image level stuff.
"L'enfer, c'est les autres"

If a post offends you, just put that poster on your foes list, and be done with it (and with them).

To do otherwise, risks being banned.

Return to “Raspbian”

Who is online

Users browsing this forum: gennargiu, KlSchlitzohr and 30 guests