Clone SD Card in Linux
- Published on
- 4 min read
- Authors

- Name
- Robin te Hofstee
- @Robin_teHofstee
Cloning an SD card in Linux involves creating an exact copy of the entire SD card, including its partitions and data. This can be done using tools like dd, gnome-disks, or Etcher. Below are the steps for each method:
Method 1: Using dd (Command Line)
dd is a powerful command-line tool for copying and converting data at a low level.
Steps:
Insert the SD Card:
- Insert the SD card into your computer's card reader.
Identify the SD Card:
- Run the following command to list all storage devices:
lsblk - Identify your SD card (e.g.,
/dev/sdXor/dev/mmcblk0). Be careful to choose the correct device, asddcan overwrite data irreversibly.
- Run the following command to list all storage devices:
Unmount the SD Card:
- Unmount all partitions on the SD card:Replace
sudo umount /dev/sdX1 sudo umount /dev/sdX2/dev/sdX1and/dev/sdX2with the actual partition names.
- Unmount all partitions on the SD card:
Clone the SD Card:
- Use
ddto clone the SD card to an image file or directly to another SD card.
Option 1: Clone to an Image File:
sudo dd if=/dev/sdX of=sd_card_backup.img bs=4M status=progressif=/dev/sdX: Input file (source SD card).of=sd_card_backup.img: Output file (image file).bs=4M: Block size (improves speed).status=progress: Shows progress.
Option 2: Clone Directly to Another SD Card:
sudo dd if=/dev/sdX of=/dev/sdY bs=4M status=progress- Replace
/dev/sdXwith the source SD card and/dev/sdYwith the target SD card.
- Use
Verify the Clone:
- After cloning, verify the data integrity:
sudo dd if=/dev/sdX bs=4M | sha256sum sudo dd if=/dev/sdY bs=4M | sha256sum - Compare the SHA256 checksums to ensure they match.
- After cloning, verify the data integrity:
Eject the SD Card:
- Safely eject the SD card:
sudo eject /dev/sdX
- Safely eject the SD card:
Method 2: Using gnome-disks (Graphical Interface)
gnome-disks is a user-friendly graphical tool for managing disks and partitions.
Steps:
Install
gnome-disks(if not already installed):sudo apt install gnome-disk-utilityOpen
gnome-disks:- Launch
gnome-disksfrom your application menu or by running:gnome-disks
- Launch
Select the Source SD Card:
- In the left panel, select the source SD card.
Create a Disk Image:
- Click the menu button (three horizontal lines) in the top-right corner and select Create Disk Image.
- Choose a location to save the image file (e.g.,
sd_card_backup.img).
Restore the Disk Image:
- Insert the target SD card.
- Select the target SD card in
gnome-disks. - Click the menu button and select Restore Disk Image.
- Choose the image file you created earlier and restore it to the target SD card.
Eject the SD Card:
- Safely eject the SD card after the process is complete.
Method 3: Using Etcher (Graphical Interface)
Etcher is a cross-platform tool for flashing and cloning SD cards.
Steps:
Install Etcher:
- Download and install Etcher from its official website: https://www.balena.io/etcher/.
Launch Etcher:
- Open Etcher from your application menu.
Select the Source SD Card:
- Click Flash from file and select the source SD card or an existing image file.
Select the Target SD Card:
- Insert the target SD card and select it in Etcher.
Start the Cloning Process:
- Click Flash to start cloning the SD card.
Eject the SD Card:
- Once the process is complete, safely eject the SD card.
Method 4: Using cat (Command Line)
cat can also be used to clone an SD card, though it lacks progress reporting.
Steps:
Identify the SD Card:
- Use
lsblkto identify the source and target SD cards.
- Use
Unmount the SD Card:
- Unmount all partitions on the SD card:
sudo umount /dev/sdX1 sudo umount /dev/sdX2
- Unmount all partitions on the SD card:
Clone the SD Card:
- Use
catto clone the SD card:sudo cat /dev/sdX > /dev/sdY - Replace
/dev/sdXwith the source SD card and/dev/sdYwith the target SD card.
- Use
Eject the SD Card:
- Safely eject the SD card:
sudo eject /dev/sdX
- Safely eject the SD card:
Tips:
- Backup Data: Always back up important data before cloning.
- Check SD Card Size: Ensure the target SD card is at least as large as the source SD card.
- Use a Fast Card Reader: For faster cloning, use a high-quality USB card reader.
By following these steps, you can easily clone an SD card in Linux using your preferred method.