Blogs: Linux

Journal of linux commands, tips and tricks


Building an ISO image of an SD card for Raspberry Pi. Used as a backup method. Should work for thumb drives or even hard drives!

Last edit: 12 May 2020

Sample commands:


sudo dd if=/dev/sdf of=/media/mugwhy/SATA-Drive/seafile-mugwhy/OSimages/workingSeafileISOiffy001.iso bs=1M
sudo dd if=/dev/sdg of=/media/mugwhy/SATA-Drive/seafile-mugwhy/OSimages/freshRasbian.iso bs=1M
  • [if=rahrah] will be the SD card or drive
  • [of=rahrah] will be the path and file name of the ISO image you want built!
  • [bs=1M] you might be able to get away with using this parameter. If not just add it also. Goole if you really need to know. Something to do with block sizes. This works for me!

Repairing a partition on a Raspberry Pi SD card. This was used to repair an install that would no longer boot.

Last edit: 12 May 2020

So I pulled the SD card from the Raspberry Pi and inserted it into a card reader that I had plugged into my desktop linux PC.

Using the DISK utility I identified the SD card to be /dev/sdf

There were two other partitions on the SD card identified as /dev/sdf1 and /dev/sdf2

Using the following command

sudo fsck -fv /dev/sdf2

I was able to repair partition 2 which turned out to be rootfs. Prior to repairing.... this partition was just showing up as Free Space! You want to see a boot partition and a partition called rootfs

The above command was the fix for me.

If you add the n parameter as shown below, you should be able to do a dry-run meaning it will report changes without actually making the changes. This way you can observe changes-to-be before potentially messing things up. I suggest you build an image of the SD card as a backup before catastrophic disaster occurs! Plus do a dry-run. If you're happy, go for the real thing and issue the repair command and good luck!

sudo fsck -fvn /dev/sdf2