HowTo zip up a partition image

I’m developing an application that I want to put on a bootable CD. Sort of my free version of a Paragon’s Software for backing up partitions and/or whole drives, and restoring them. But I’ve got a lot to learn yet.

OK I want a command line command ATM to make an image of an unmounted partition sda5, zip it up and put it on a mounted partition sdb1 mounted at /sdb2. I think this will do that:

dd if=/dev/sda5 | gzip -c > /sdb1/sda5.img.gz

I think this will read the partition sda5 with “dd sda5”, zip it to standard output with “gzip -c”, and pipe that standard output to a storage file sda5.img.gz which will be located on the mount (sdb1) at /sdb1/sda5.img.gz by the pipe (?) thingy doing “> /sdb1/sda5.img.gz”.

OK I tried these commands:

  1. I do it unzipped with this:
    dd if=/dev/sda5 of=/sdb1/sda5.raw.img
    and get a file sized 6Gb for a windows ntfs partition

  2. I do it zipped with this:
    dd if=/dev/sda5 | gzip -c > /sdb1/sda5.img.gz
    and get a file sized 3.4Gb which is good reduction (if it’s a valid method)

  3. I do it zipped with this:
    dd if=/dev/sda5 | gzip > /sdb1/sda5.img.ver2.gz
    and get a file sized 3.4Gb (actually its exactly the same number of bytes) which is good reduction too (also if it’s a valid method)

You can see how I’m struggling here.

All well and good, but are the algorithms/commands even valid? And which is correct, the gzip version 2 using “-c” or the version 3 without “-c” ,or both (sheesh)?

You may want to look at Clonezilla.

Clonezilla

Oh I understand that. One of the reasons I’m doing it this way is to force myself to learn filesystem basics at a very in-there level. I like clonezilla and probably won’t be able to match it. but I’m coming from an angle where ultimately e.g. a Receptionist in a Doctor’s surgery, at close of day, will be able to put my CD into the server, boot off it and go home. The CD will copy the hard drive as an image, zip it up and move it over the network to a Network Attached Storage unit which stores backups. The CD will also verify that the server’s drive integrity is good and so on, other necessary disaster-prevention housekeeping, and then shut the server down for the Receptionist to turn on again in the morning. Something like that.

So while clonezilla and several others are really great, I need to be right in there at a more fundamental level in order to get the big picture to work.