4

first this question is not a dupe of:

https://superuser.com/questions/7739/windows-backup-by-imaging

I've used Norton Ghost extensively in the past (actually I was already using Ghost before Norton bought it) and one of the thing I liked is that it could compress the Windows partition so you could take relatively small snapshots/images of Windows systems.

I did a lot of imaging in the Windows 95/98/ME, XP and 2000 days.. But nowadays I tend to only run Windows in VMs (mostly under KVM). These virtual Windows, I've got no problem imaging and then duping/deleting/editing/etc. those images.

But my need now is different and here's the question for real superusers: I want to image and compress, from a Linux boot CD, a Windows NTFS partition of a Windows computer.

I don't mind creating myself the Linux boot CD with whatever application is needed... But which application would that be and how would I use it?

4 Answers 4

6

There are several options for taking images of partitions, including the absolutely basic cat and dd. These have the advantage of being present by default just about everywhere in the unix-a-like world, and both can be passed through gzip or similar like so:

cat /dev/sda1 | gzip -c > /some/directory/sda1.img.gz

or even a whole disk:

cat /dev/sda | gzip -c > /some/directory/sda.img.gz

These options are filesystem agnostic so will not ignore unused blocks (which may still contain old data), so to improve the compression rate you get, significantly in some cases, use the sdelete utility within Windows to zero all the partitions free space like so:

sdelete -v c:

Or you could mount the partition and run cat /dev/zero > /mnt/ntfs/zero.file ; rm zero.file if you trust the Linux NFTS setup that much (I prefer to be wary, as the NTFS format is not fully publicly documented so there could likely be things it doesn't know it doesn't handle well).

You can remove cat from the examples above like so:

gzip -c < /dev/sda1 > /some/directory/sda1.img.gz

and it would be a little more CPU efficient, but I doubt the efficiency difference will be significant unless you have a very low-power processor and I prefer the method with cat as the command "flows" better left-to-right.

You can also replace cat with pv (Pipe Viewer) if you have it installed, to get a useful progress display for the potentially long operation.

2
  • Spillet: I like all the answers but yours is definitely the kind of stuff I had in mind. I don't mind trying sdelete or the cat /dev/zero/ trick: I can check before and after that everything went smoothly: it's to image fresh installs once and for all for some machines and if worse comes to worse, I can re-install and retry.
    – Weezy
    Jun 10, 2011 at 0:38
  • ntfsclone (as in another answer) is the second thing that comes to mind for this task, and is much better in compression conceptually than dd as in this answer, which comes to mind as the first thing, of course. Why? Because the unused space can be filled with random stuff on disk, and compressing and saving it is a waste of CPU and space. It is significant, if you have a lot of unused space relative to the whole space. Nov 3, 2017 at 0:38
10

You can use ntfsclone, a Linux tool designed for exactly just that. You can pipe the output directly to stdout by passing a hyphen to the -o switch.

For example, if you want to image /dev/sda1 with gzip compression, you can use this command:

ntfsclone -s -o - /dev/sda1 | gzip -c > /output/location.img.gz

If you want more compression and have the time, I recommend using the xz method instead:

ntfsclone -s -o - /dev/sda1 | xz -cv > /output/location.img.xz

Both of these will image and compress your NTFS partition while ignoring unused disk space.

Cheers!


EDIT: ntfsclone can be easily installed on most net-enabled distros with their package manager if it's not included by default. If you can't find the utility in your particular distribution's software manager, it may be part of the ntfsprogs or ntfs-3g utility. You can also refer to this link for additional cloning information.

2

I recommend PING (Partimage Is Not Ghost).

It's a live Linux ISO, and it allows you to compress a partition with either gzip or bzip2.

1
  • excellent! I did Google but didn't find it. I did find Clonezilla that said.
    – Weezy
    Jun 10, 2011 at 0:39
1

You should take a look at Clonezilla. I know it allows the imaging of disks to file and i suspect with some tweaking you could make it compress them as well.

The clonezilla Live CD will step you through the imaging process and give you a command line when you are finished. You should be able to use that and modify the boot scripts to build it into the tool that you need.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .