I want to convert a physical partition (Windows C:\ drive) into an image file with dd.

dd if=/dev/sda1 of=/path/to/W7.img (run from a live DVD which I start the original machine with)

is what I can come up with.

I guess throwing in some options to

  • preserve the 'bootable' property of the C:\ partition, as well as
  • adding some option about blocksize

... may be a good idea

... can anyone recommend those?

Furthermore, can I compress the image to be created in the dd operation?


You can't preserve a 'bootable' property by backing up a partition. The bootable properties would depend on details of the actual disk. The details would depend on the type of partition table and whether it's formatted to use boot partition or reserved sectors of the disk. A boot partition would be different from the actual OS partition. You would have to image the whole disk for that.

You can easily add a boot option to the destination drive:

Preserving the boot option shouldn't be such a problem since once you have the OS partition backed up, you can have your choice of the partition type of the new drive you will be restoring it to. If you restore it to a partition on your Ubuntu machine running sudo update-grub will add it to your boot menu.

As far as compression, yes you can. An example of how to use it is included below.

For Linux you can check the filesystem's block size with this command:

$ sudo blockdev --getbsz /dev/sda1

You can change the blocksize with this command:

$ mkfs -t ext4 -b 4096 /dev/sda1

You'll have to discuss a Windows block size details with a site such as http://superuser.com. Changing the blocksize could corrupt the integrity of the filesystem if it can't handle the different size. dd doesn't have an option to change a filesystem's block size on the fly.

This is a good dd commandline that may be an improvement to the one in your example:

$ sudo dd if=/dev/sda1 status=progress bs=32M | bzip2 > /path/to/W7.img

These are the parameters of the commandline:

  • bs = Bytes - Read and write up to # of bytes at a time.
  • status = Show a status of the progress. This is useful when the operation takes a long time, to realize it's not locked up, and still working. It can also give a perspective of how much time might be left.
  • | bzip2 > = Pipe through bzip2 for compression and output to the desired compressed image file.
  • thanks for the detail. I'll check the dd command mentioned – vrms Apr 19 '18 at 9:55

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.