Make disk image with real-time compression over network on Linux

0

1

I have two Linux notebooks on a network and no additional storage. I want to backup the first notebook hard drive (make full HDD image), on the second notebook. How could I do that using real-time compression?

fifajan

Posted 2014-12-24T08:55:39.567

Reputation: 29

Answers

2

To make hdd partition copy which will be workable and locally mountable you need to act as following:

  • Connect 2 computers via network;
  • Run linux on both (LiveCD is great if any of those do not have linux installed);
  • Mount external fs (via network, f.e. ssh, samba, ftp, nfs etc) on computer holding hdd partition of interest;
  • Give needed permissions to access partition file in /dev (f.e. /dev/sda2);
  • Execute following:

    $ dd if=/dev/sda2 conv=fdatasync bs=8096 | gzip -cf > $PATH_IN_EXTERNAL_FS/sda2.img.gz
    $ dd if=/dev/sda2 bs=8096 | md5sum - > $PATH_IN_EXTERNAL_FS/sda2.orig.md5
    

    Note: You may execute those two in parallel;
    Note: This can take a LONG time (f.e. on wireless (G) connection it took 34 hours to process 150 gb NTFS image, and image was gzipped to 106 gb and md5 sum counting for it took about an hour); Note: You can observe dd's progress by executing following in another terminal window:

    $ watch -n30 "kill -USR1 $PID_OF_DD"
    
  • When it will be finished on the other computer (where image is now stored) execute following:

    $ gunzip -c sda2.img.gz | dd of=sda2.img bs=8096 && dd if=sda2.img bs=8096 | md5sum - > sda2.img.md5
    
  • Now compare original partition's and image's md5 sums:

    $ cat sda2.orig.md5 && cat sda2.img.md5
    

    Note: If strings are equal everything is fine;

  • Now you can mount sda2.img as you'd do with original partition but you must specify loop option to mount tool. Following should work:

    # mount -o loop sda2.img /mnt/sda2_img
    

    Note: maybe you'll need to specify some other mount tool options to make it work;

  • Have a nice day!

fifajan

Posted 2014-12-24T08:55:39.567

Reputation: 29

Can you add a couple of sentences to your answer to explain the loop option mentioned at the end (what is it, how do you add it to the mount tool)? – fixer1234 – 2014-12-24T17:10:36.587

@fixer1234 done! – fifajan – 2014-12-25T07:11:27.673