Linux for Radio Astronomy

How to save image from bootable SD card directly to USB pendrive in Linux Ubuntu


Instead of first saving the SD card image to your home directory, you can write it directly to the USB pendrive.

Here’s exactly how:


🧭 Step-by-Step: Clone boot SD card straight to USB pendrive

1. Identify the devices

Run:

lsblk
  • Your boot SD card will likely be /dev/mmcblk0 or /dev/sda (since you’re booted from it).
  • Your USB stick will likely be /dev/sdb or similar.

For example:

NAME         SIZE TYPE MOUNTPOINT
mmcblk0     29.7G disk
├─mmcblk0p1  256M part /boot
└─mmcblk0p2 29.4G part /
sdb         31.0G disk
└─sdb1      31.0G part /media/usb

👉 Here:

  • SD card = /dev/mmcblk0
  • USB stick = /dev/sdb

2. Unmount the USB stick

sudo umount /dev/sdb*

(Replace sdb with the correct USB device name.)

This is critical — dd can only write to an unmounted device.


3. Clone the SD card directly to USB

sudo dd if=/dev/mmcblk0 of=/dev/sdb bs=4M status=progress conv=fsync
  • if= → input file (the SD card you’re booted from)
  • of= → output file (the USB stick)
  • bs=4M → speeds up the copy
  • status=progress → shows how far along it is
  • conv=fsync → flushes writes correctly

🕑 This will take a while depending on the card size.


4. Ensure all data is written

sync

This ensures the OS has finished writing to the USB stick.


5. Test the USB

When it’s done, unplug the USB stick and plug it into your target machine to boot from it.
It should be a bit-for-bit clone of your SD card.


6. (Optional) Expand filesystem

If your USB is larger than the SD card:

sudo growpart /dev/sdb 2
sudo resize2fs /dev/sdb2

This resizes the root partition to use all space.


Summary of commands

lsblk                     # Find devices
sudo umount /dev/sdX*     # Unmount USB
sudo dd if=/dev/mmcblk0 of=/dev/sdX bs=4M status=progress conv=fsync
sync                      # Flush writes

(replace sdX with your actual USB device name!)


⚠️ Important Warning:
dd overwrites the entire USB stick without confirmation. Make absolutely sure you use the correct of= device (the USB, not your system disk).


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.