So I want to take a disk image of my SSD/HDD, but I want my disk image to be exactly the same as every bits/information of my physical hard disk. (so that if there are files deleted but recoverable then if disk image gets recopied to HDD then this will be the same. - so fragmentation remains the same.)

Can this be done using dd? And is this related to dd block size?

  • One shouldn't expect ANY deleted file to be copied when trying to clone a hdd. You cannot be guaranteed you would get the entire file at least on traditional hdds. What you want is not realistic with traditional hdds. Even with SSD fragmentation still exists, which means part of a deleted file;s memory location, might have already been used for a new file. Fragmentation still exists on SSD, its just not an issue, because the access times are not effected by it. Furthermore doing a defrag on a SSD would lower the lifespan of the memory cells by a significant amount.
    – Ramhound
    May 22 '13 at 12:20

This is what dd does - copies whole hard drive bit by bit, so it will do exactly what you wish (block size has nothing to do with this)

However, SSDs with filesystems with TRIM support, might reuse deleted blocks for wear leveling, so the deleted files might not be recoverable even if not overwritten filesystem-wise, but the data in the dd image will be the same as the readable data on the ssd at the time of dd imaging.


Just add to what mulaz said:

While dd copies exactly the contents of the drive, including the deleted files, due to the different means of storing the data on HDDs and SSDs, the wear-leveler on the SSD is going to abstract away the actual positions of the bits on the memory chips from their representation to the user.

While that does not affect the user at all, it should be noted that an arbitrary address on the filesystem does not correspond with the actual physical address on the chip.

Also the HDD might not have its partition aligned, which could be a problem for recognizing it on the SSD, which again does not mean that the data isn't there and cannot be read back using dd.

Also (2), if your SSD is bigger than the HDD, you will have to manually expand the partitions afterwards to make use of the rest of the space.

Also (3), if your SSD is smaller than the HDD, not all of your data from the HDD will be written to it and when trying to access it, you will get read IO errors... but I guess you were aware of that and had it coming.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.