1

I have 2 sd cards, one with raspbian and one with debian builds. I need to replace the rootfs in my raspbian sd card with the one in my debian sd card.

How can I do this? And, what are the changes (if any) required to be made? I'm a newbie, please help.

  • In effect you are cloning the cards as the root file system is everything but the /boot partition. Is that your intention? – joan Dec 30 '14 at 13:52
  • @joan.. Yes, but I need to retain the kernel. – user3490458 Dec 30 '14 at 14:00
  • Are the kernels the same version number? uname -a should give the version. The kernel is Linux and as far as I know should be distribution agnostic (neither hard nor soft float). – joan Dec 30 '14 at 14:21
  • @joan. I had actually recompiled the kernel to add support for an additional i2c. – user3490458 Dec 30 '14 at 14:41
  • 1
    I don't know. It's not something I've done. Why not just copy the original SD card to the copy? Should work if they are the same size. Perhaps search for cloning SD cards. The size of the non-copied /boot is tiny compared to the rest. – joan Dec 30 '14 at 14:56
1

Terminology

We will refer to the debian sd card as the source and the rasbian sd card as the destination.

The following operations should be done on a linux machine other than your raspberry pi.

Instructions

Backup Destination SD Card

  1. Place your destination sd card into your sd card reader.
  2. sudo dd if=/dev/sdXN of=./destination-backup.iso

X should be a letter, and N should be the partition number. This will create destination-backup.iso in your current directory.

Create Source ISO

  1. Place your source sd card into your sd card reader.
  2. sudo dd if=/dev/sdXN of=./source-backup.iso
  3. Place your destination sd card into your sd card reader.
  4. sudo dd if=./source-backup.iso of=/dev/sdXN

X should be a letter, and N should be the partition number. This will create source-backup.iso in your current directory. After that is created, you will be placing that data onto the root partition of the destination sd card.

'Resize' partition

  1. sudo resize2fs /dev/sdXN

You should run this if your filesystem sizes are different (which they typically will be). This will automatically expand/contract your filesystem size.

Disclaimer

This assumes that what you're doing will work. For example, if you replace any root filesystem with another root filesystem, you could potentially run into issues with the operating system.

There is a potential for dataloss using these commands. Please be sure to make the backups (as recommended).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.