Search This Blog

Sunday, April 24, 2011

How to clone a partition to a remote NFS server

Problem description.
You formatted and re-partitioned your hard drive.
You have a partition of the size about 100GB that you dedicated to your OS.
The installation of your OS went fine as well as the installation of all your necessary drivers.

After all you would like to have a copy of your partition data that can quickly restore in a case something wrong happens.

Solution:
Download the SystemRescueCd ISO img file [1]
Create bootable USB thumb drive [2]
Boot the system using your USB thumb drive. Once it is fully loaded you will get bash command line access.

Mount your remote NFS site image repository:

# mkdir /tmp/nfs
# mount -t nfs -o nolock 192.168.0.X:/your/path /tmp/nfs

Copy and compress the partition while coping it out for backup purposes [3]. Copy the partition schema as well.

# For test purposes you can shortly run the partclone.dd with '-d' option
# it will create a log file in /var/log directory.
# But don't run it like that otherwise it will quickly fill your log partition

# partclone.dd -c -d -s /dev/sda1 -o - | bzip2 -1 -c > /tmp/nfs/sda1.winXP.32bit.img

# Once tested run without -d option
#
# partclone.dd -c -s /dev/sda1 -o - | bzip2 -1 -c > /tmp/nfs/sda1.winXP.32bit.img
# parted -l > /tmp/nfs/log.parted.l.txt
# parted -l -m > /tmp/nfs/log.parted.lm.txt
#
# to backup the partition table from the MBR sector (don't use it on GPT partitioned system)
# sfdisk -d > /tmp/nfs/log.sfdisk.d.txt
#
# umount /tmp/nfs

At the end unmount the NFS partition and we are ready to reboot the system.

Later on, as a security precaution create md5sums and some level of par2 recovery files if the image should have ever get corrupted.

# md5sum -b sda1.winXP.32bit.img > sda1.winXP.32bit.img.md5
# par2create -r3 sda1.winXP.32bit.img


References:

[1] SystemRescueCd

[2] Sysresccd-manual-en How to install SystemRescueCd on an USB-stick

[3] partclone.dd

man 5 nfs

par2 home page
man par2

No comments:

Post a Comment