I created an image of an NTFS partition using dd.

I wonder if I can unload/unpack the files and directories in the image to any partition whose size is larger than the image size, so that I can access the files and directories just in the same way as accessing the original partition?

If yes, how shall I do it?


Just found something useful from a link :

To restore a partition or a hard disk from an image file, just exchange the arguments "if" and "of". For example, restore the first partition of /dev/sda from the image file "disk2.img":

dd if=disk2.img of=/dev/sda1
  1. I wonder what will happen, if the partition for of is not the original partition from where the image is created?

    • Consider the cases when the partition for of is smaller or larger than the original partition.
    • Also consider the cases when the partition for of already has some data in it. Is it possible to restore from a particular position in the partition, so to avoid overwriting any existing data on the partition for of?
  2. Can the restoration from an image created by dd used by other similar applications, even by Windows software? In other words, does the image created by dd have some format specific to dd?


2 Answers 2


That's not exactly how to go about it.

What you'll want to do is mount the disk image as a loopback device:

mount -o ro,loop -t ntfs disk.image /mnt/test

The contents of the image will be available in /mnt/test (but you can choose to mount it anywhere you like). You can copy individual files (or entire directory trees) from it. Use umount /mnt/test1 to unmount it.

As far as restoring the image to a new disk, you need to restore it in the same way that you created it. I.e., if you created an image of an entire block device (e.g., sda) then restore to an entire block device. If you created it from a partition (e.g., sda1) then restore it only to a partition.

That being said, if you are doing partitions you'll need to create them on the destination device before restoring. The destination device also needs to be equal size or larger than the image you created.

If you're dealing with partitions then you can create the partition exactly the same size and you'll be fine. You can create other partitions out of any blocks not already allocated to a partition. If you're dealing with an entire block device restore first, then use gparted* to modify the partitions.

* I'm pretty sure gparted can resize partitions in the disk image directly, but I prefer to keep the disk images pristine.

  • Thanks! What does loopback device mean?
    – user23153
    Sep 10, 2012 at 21:49
  • Thanks, @don_crissti and bahamat! I just found that I can restore from an image to a partition. But I wonder what if the destination partition and the original partition from which the image was created are different? See my added part to my post. Thanks!
    – user23153
    Sep 10, 2012 at 23:11
  • I've updated my answer to include restoring the image.
    – bahamat
    Sep 11, 2012 at 0:04
  • If you prefer to keep the images pristine I'd use -r to mount read only.
    – Didi Kohen
    Sep 11, 2012 at 13:58
  • @DavidKohen: Good point. Ammended.
    – bahamat
    Sep 11, 2012 at 16:02

Bahamat's already given a good answer on how to extract files from a disk-image file (i.e. loopback mount it and then copy them), so i'll make a generic answer about cloning filesystems.

If your purpose is to backup and restore, or clone a filesystem from one computer to another then:

  1. For linux and unix, you're almost always better off doing file-based backups rather than disk or partition image backups. There are many tools you can use to do this, including cpio, tar, and (my favourite) rsync.

    If you're backing up the root filesystem then you'll need to reinstall the grub bootloader into the MBR when you restore. See the grub documentation for details, in particular the grub-install command.

  2. for NTFS, use a tool like ntfsclone from the ntfs-3g package. It can clone and resize NTFS partitions.

  3. Clonezilla is a great bootable CD for backup/restore and cloning of disk and partition images. It wraps tools like parted, dd, resize2fs, ntfsclone and many others with an easy-to-use text-mode dialog and menu system. E.g. it can clone a partition or disk to another partition or disk, or to a compressed image file on a network file share (e.g. NFS or samba), and restore from same.

  • Thanks, Craig! I would like to upvote your reply, but my reputation is too low to do that. I was motivated to ask a question about byte-level and file-level backups: unix.stackexchange.com/questions/47770/…
    – user23153
    Sep 11, 2012 at 1:07
  • My favorite is rsync too, but it has lots of memory management issues which makes it fill up the server memory when copying lots of files, keep that in mind.
    – Didi Kohen
    Sep 11, 2012 at 14:01
  • For some special device, e.g. a 32Gb sd card plus a cheap card-reader built several years ago, rsync and cp are not reliable, they can not retrieve all files from SD card (i don't know why). dd is the only choice.
    – Sherry869
    Feb 11, 2021 at 4:36

You must log in to answer this question.