Bobbbay
Bobbbay

Reputation: 335

Clone one MicroSD card to another

So, I have a Raspbian Lite booted from PINN, the bootloader, on my Raspberry Pi 2B v1.1. I have it all written on a 8.0GB micro SD Card. I just bought an upgrade - a 64.0GB micro SD. I have a lot of things on my original 8GB SD, so I don't want to have to manually re-install every little thing I have.

My question is this: Is there a way to clone my whole card, with every partition, using the terminal in Raspbian Lite to a new SD Card?

I have tried rpi-clone: it seems to only copy over two partitions.

I have the 64GB plugged in via a USB adapter, no problem there.

Here are my partitions on my 8.0GB card:

The partitions on my 8.0GB Card

Thanks, Bobbay

Upvotes: 1

Views: 879

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207415

It's best to duplicate your SD card on a computer where the operating system is not running from that SD card - mainly because the contents of the card could change while you are duplicating it in a live system.

So, I would boot a PC off a live distro, like Knoppix. Once booted, start a Terminal and check the names of the disk drives like this:

ls /dev/sd?

You'll probably just have /dev/sda, but check! Now attach your 8GB SD card, wait a couple of seconds and check what name that got allocated. It's likely to be /dev/sdb

ls /dev/sd?

If it's /dev/sdb save that as SRC (source), like this:

SRC=/dev/sdb

Now attach your 64GB SD card, wait a couple of seconds and check what name that got allocated. It's likely to be /dev/sdc

ls /dev/sd?

If it's /dev/sdc save that as DST (destination), like this:

DST=/dev/sdc

If, and only if, everything works as above, you can now clone SRC to DST with:

sudo dd if=$SRC of=$DST bs=65536

The command above will take a fair time to run. Once it is complete, you will have a clone of your original disk, as /dev/sdc However, this will have the same size partitions as your 8GB drive, so you will want to expand the partitions out to fill the available space. I don't know which one(s) you want to expand, or by how much, but you will want to use the resize2fs command on the new disk. You can get help on that with:

man resize2fs

Upvotes: 1

Related Questions