Wednesday, April 6, 2016

Creating a disk image with dd


Intro  

       The dd command is a useful utility that allows someone to easily image a storage unit. You can use this command to backup your flash drive, sdcard, etc. It can also be useful for forensic work, e.g if you're trying to recover deleted files from a flash drive, you can image the drive then work on the image keeping the original safe.




Disclaimer


        This command if used improperly can result in destruction of data. Be very carefull and double check the command before executing it. I am not responsible for any damages.

How to use

Syntax :
sudo dd -if [Source] -of [Destination]
For more options see the man page :
man dd


Tutorial

       For this tutorial i will be creating an image of a 32MB sd card. For the fitst step we must identify where the sdcard is mounted to do this we must list all mounted drives running this command:
sudo fdisk -l


      After we have located the drive all we have to do is run the dd command, BE CAREFUL in this step because if you mix up the source with the destination you will loose all the data in the drive. And as you can see bellow the image file has been created.
sudo dd if=/dev/sdc of=image01.img

      After imaging the drive if you want to store the image it's best to compress it especially when its a large file, that way you save valuable HDD space. To compress it use the following command :
zip arch_image.zip image01.img
After compressing it you can delete the image file, to do that run the following command:
rm image01.img

Epilogue

   dd is a very usefull and effective utility, but if you are not carefull it could be dangerous to the data. So read the command twice before executing it.

No comments:

Post a Comment