Thursday, November 13, 2008

Backing up a new laptop

So I got a laptop, a Lenovo T500. But what to do with its funky Vista OS?

Well, wipe it out, of course! With Ubuntu perhaps. But nevertheless I'd like to keep a backup of what came in the hard drive. So, here is what I did.

1. Boot with Ubuntu Ibex. For that I had to get to the BIOS and force the Laptop to prefer to use the Intel card. Otherwise Ubuntu gets real confused about having two cards.

Once it booted I opened a terminal and got root.This assumess that networking works fine, the HDD works reliably, etc.

sudo -s


2. Mount a CIFS share to my desktop.

mount -t cifs -o user=my_username_there //mycomputer/my_username_there /mnt

cd /mnt


3. Backup the partition table

sfdisk -d /dev/sda > the-windows-partititon.dump


4. Backup the MBR

dd if=/dev/sda bs=512 count=1 of=the-windows-mbr


5. Now it is time to get to the main issue:

ntfsclone -s -o - /dev/sda1 | gzip | split -b 1000m - the-windows-sda1.img.gz_
ntfsclone -s -o - /dev/sda2 | gzip | split -b 1000m - the-windows-sda2.img.gz_
ntfsclone -s -o - /dev/sda3 | gzip | split -b 1000m - the-windows-sda3.img.gz_


To restore:

1. Boot with Ubuntu, open a terminal, get root

sudo -s


2. Mount a CIFS share to my desktop.

mount -t cifs -o user=my_username_there //mycomputer/my_username_there /mnt

cd /mnt


3. Restore the partition table

sfdisk /dev/sda < the-windows-partititon.dump


4. Restore the MBR

dd of=the-windows-mbr of=/dev/sda bs=512 count=1


5. Now Restore the partitions:

cat the-windows-sda1.img.gz_* | gunzip -c | ntfsclone --restore-image --overwrite /dev/sda1 -
cat the-windows-sda2.img.gz_* | gunzip -c | ntfsclone --restore-image --overwrite /dev/sda2 -
cat the-windows-sda3.img.gz_* | gunzip -c | ntfsclone --restore-image --overwrite /dev/sda3 -