Skip to content

Instantly share code, notes, and snippets.

@DominikStyp
Last active February 20, 2025 15:53
Show Gist options
  • Select an option

  • Save DominikStyp/edabe21ab1cdab0e4bcfce1967f5a3d2 to your computer and use it in GitHub Desktop.

Select an option

Save DominikStyp/edabe21ab1cdab0e4bcfce1967f5a3d2 to your computer and use it in GitHub Desktop.
RasbperryPI clone SD Card

In Linux Ubuntu mount the card
Check which one is the mounted SD Card:

lsblk

Then go to the directory you want to have backup in and run:

sudo dd if=/dev/sdb of=./raspberry_backup.img bs=4M status=progress
sync  # Ensure all data is written before removing the card from the USB

Then swap the card to the new one and clone MAKING SURE that new card is mounted under /dev/sdb by lsblk :

sudo dd if=./raspberry_backup.img of=/dev/sdb bs=4M status=progress
sync  # Ensure all data is written before removing the card

Resize partition if needed (in Linux):

sudo apt install gparted
sudo gparted

The do the steps:

  • Select your new microSD card (e.g., /dev/sdc).
  • Find the root partition (ext4) – this is /dev/sdc2.
  • Resize it to fill the remaining space.
  • Apply changes and exit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment