Copying a working SD card to a new one.

I want to copy an existing working SD card to a newer, larger one.

Background: Following the recent discussions on SD card reliability, and having had a couple of card failures on other Raspberry Pi systems, I have now purchased a 32 GB card for my Raspberry Shake:

formatting link

Currently the 'Shake has an 8 GB card so how would I go about transferring the existing 8 GB card to the new 32 GB one?

I don't have access to a Linux systems with multiple SD card slots.

On Windows I would use Paragon's Hard Disk manager to transfer from one HD to another and it would keep all the partitions intact but rescaled to fit the new HD capacity. I had considered using a Windows disk imager program to copy the 8 GB card to a .IMG file and then writing that image to the 32 GB card, but I don't know whether Linux would even recognise the card, or be able to use its greater capacity.

If I could add a couple of SD card readers to a (different) Raspberry Pi, is there a Linux command or program which do the equivalent of Paragon's "copy disk and expand partitions"? I'm not familiar enough with Linux to know how to do this.

--
Thanks, 
David 
 Click to see the full signature
Reply to
David Taylor
Loading thread data ...

As I understand it, if uyou - say - install a Raspian image on the new card, then extend the secoind partion , then copy the cintenst of yoir existing second partition to that, it should work.

Why not use a live CD to get a linux PC env?

--
"In our post-modern world, climate science is not powerful because it is  
true: it is true because it is powerful." 
 Click to see the full signature
Reply to
The Natural Philosopher

Seems likely this could work (assuming the Windows thingy doesn't panic if it sees a Linux file system) but you'll just have the file systems you had on the 8 GB card. Gparted would help with resizing the partition(s).

Reply to
Anssi Saari

How about a Linux system with one card slot, and some HDD space? You just use dd to create an image file on the HDD then write that back to the larger card, then stretch the partition with gparted to fill the card (although I think you could probably use raspi-config to stretch the partition automatically I've only ever done that with a fresh install - worth a try though).

See above, only you write the image straight to the larger card rather than a file on the HDD.

Reply to
Rob Morley

Looking at my Pi the card has two partitions. One is ext4 and is mounted on /

The other is on /boot, type vfat

Now, as I understand it, the PI has no boot sector, so all you need to do is partition a raw card with anbout 44M as VFAT, and the rest as ext 4.

Then copy your existing files from one to the other.

You will need to patch the /etc/fstab on the new card to reflect the blockids of the new partitions

Or make the new partition UUIDS the same as the old SD card

Linux command blkid is your friend here.

--
"And if the blind lead the blind, both shall fall into the ditch". 

Gospel of St. Mathew 15:14
Reply to
The Natural Philosopher

I use Rpi Clone to copy the card in the SD slot ofthe pi to a card in a USB card reader in the pi. Run RPI-CLONE and it copies the working card onto the USB card reader.

Reply to
4ctestsystems

On Thu, 28 Feb 2019 16:34:26 +0200, Anssi Saari declaimed the following:

This is pretty much the practice for the BeagleBone Black... Write an image (containing Linux partitions, not a FAT to be seen) to the SD card, boot said SD card, then run some utilities to expand the file system to use the full card size.

Script, probably Beaglebone specific:

formatting link

--
	Wulfraed                 Dennis Lee Bieber         AF6VN 
	wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/
Reply to
Dennis Lee Bieber

stick the card in a USB card reader then dd if=/dev/yourusb of=/home/yourname/somefile.img bs=4096 swap cards and dd if=/home/yourname/somefile.img of=/dev/yourusb bs=4096 no messing around with partitions required

Reply to
Rob Morley

Copy the old little image to the new bigger SD, boot with your RasPi, start raspi-config and use the command Advancde Options - Expand Filesystem, reboot and all is done.

Reply to
Uwe K.

except you will end up with a partition the same size you started with.

--
"In our post-modern world, climate science is not powerful because it is  
true: it is true because it is powerful." 
 Click to see the full signature
Reply to
The Natural Philosopher

If such a utility exists, yes, that is simplest.

--
If you tell a lie big enough and keep repeating it, people will  
eventually come to believe it. The lie can be maintained only for such  
 Click to see the full signature
Reply to
The Natural Philosopher

Then you use; resize2fs /dev/yourusb

---druck

Reply to
druck

Thanks for the suggestions!

In the end it proved as simple as I had hoped:

8 GB card => .IMG (using Win32DiskImager) .IMG => 32 GB high-endurance card sudo raspi-config => Expand file system Reboot

I also discovered rpi-clone which may be of interest:

formatting link

--
Cheers, 
David 
 Click to see the full signature
Reply to
David Taylor

raspi-config calls resize2fs, which is available on all Linux distros.

---druck

Reply to
druck

I use rpi-clone often to easily backup my work.

Reply to
4ctestsystems

Then its simples.

dd old car to new card, bott new and resize.

Only disadvnatage is the part-UUID are the same on both cards which might be 'intersting' if both are plugged into one machine.

--
Truth welcomes investigation because truth knows investigation will lead  
to converts. It is deception that uses all the other techniques.
Reply to
The Natural Philosopher

Easiest way I've found is - get a USB/microSD card adapter.

All done directly on the Pi. Put new card in adapter and plug in to USB. Note the /dev/sd? Unmount newly mounted partition(s)! Using fdisk, make new partitions - 1 = type c ~ 100M; 2 = type 83 = rest. Make filesystems: mkfs.vfat /dev/sd?1; mkfs.ext4 /dev/sd?2 Mount the new partitions - unplug and replug USB adapter. Use: rsync -avx /boot/ /media/{newpartition1} rsync -avx / /media/{newpartition2} sync; sync and check there is nothing in {newpartition2}/boot Check the file cmdline.txt in the {newpartition1}. If there is a ROOT=PARTUUID= or ROOT=UUID= make sure to change the {longhexnumber} to the UUID or PARTUUID of {newpartition2}. (blkid is your friend). Or change to ROOT=/dev/mmcblk0p2. If ROOT=/dev/mmcblk0p2, leave it alone. Make sure there is no mount line for / in {newpartition2}/etc/fstab.

Then unmount {newpartition1} and {newpartition2} Power down, swap the SD cards and boot.

Always worked for me (but YMMV). HIH.

--

Chris Elvidge, England
Reply to
Chris Elvidge

There's a command for that too:-

tune2fs -U $(uuidgen) /dev/sdX

Where sdX is the the device you want to change.

---druck

Reply to
druck

Who is going to post the tunefs(8) joke?

Reply to
mm0fmf
[Making a copy of an SD card using rsync]

More specifically, if the mount line for / contains the UUID= either update it to the new one, or change both copies to /dev/mmcblk0p2 to make it independent of the UUID.

---druck

Reply to
druck

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.