Safe backup/restore of Linux partitions in a Windows /Linux dual boot setup using a recovery partition

0

I have a dual-boot laptop (Windows 7/Kubuntu 12.04) with an IDE spinning-rust disk.

I'd like to reinstall Windows. The problem is that the only medium for that is a factory-installed recovery partition, and I'm concerned it might potentially damage the Linux partitions.

My current plan of attack is:

  1. Note down existing partition information (from e.g. parted).
  2. Back up the Linux partitions using dd.
  3. Use the Windows recovery to reinstall Windows.
  4. If the recovery process damages the Linux partitions or dual boot configuration, use a LiveCD to:
    1. Partition the disk as it was before the reinstall.
    2. Use dd to write the partition data into the newly created partitions.
    3. Restore the dual boot configuration (I have yet to research how I go about that).

The question I'd like to ask: is this the correct approach, and, if yes, what are the gaps and potential pitfalls I should be mindful about?

mikołak

Posted 2013-06-07T14:28:18.860

Reputation: 254

Answers

2

It probably will damage the linux partitions and any other partitions (so back up to an external, detachable disk), if it's anything like what I've dealt with before; good news is you do have a solid plan of attack. However, you might also want to back up your boot loader (probably GRUB), which is stored in the first 446 bytes of the drive:

dd of=/backup/bootloader.mbr if=/dev/sda bs=446 count=1

And then restore it after you replace the partitions

dd of=/dev/sda if=/backup/bootloader.mbr

Alternatively, I think you can use a live CD to boot the linux partition, and then

sudo update-grub

to re-write the bootloader.

Darth Android

Posted 2013-06-07T14:28:18.860

Reputation: 35 133

So I'm on the right track, then? Thanks for the GRUB instructions. One question 'though - why this specific byte buffer (466) in dd? – mikołak – 2013-06-07T16:51:53.463

OK, since this answer has gone unaccepted for too long, I'll assume this is just for convention's sake. – mikołak – 2013-06-18T15:21:41.643

@TheTerribleSwiftTomato Whoops, I missed the notification about your comment: The first 512 bytes of a DOS-formatted harddrive (as opposed to Apple or GPT) are the bootloader and partition table. Specifically, the first 466 are the boot loader, and then 467-512 are the partition table. Since we just want the boot loader, we set the block size to 466 and tell dd to copy 1 block. "Disk Convention" isn't the right word for it (though it is a convention I suppose); "Disk Format" better describes it. – Darth Android – 2013-06-18T16:30:25.843

heh, I also had a brainfart and missed the count=1 bit and hence the entire point of the command. Thanks for the clarification. I suggest it would be worthwhile to edit it into the answer. BTW, I think you might have probably meant 446 instead of 466: https://en.wikipedia.org/wiki/Master_Boot_Record#Sector_layout .

– mikołak – 2013-06-18T17:32:05.773

1Indeed I did; Fixed! – Darth Android – 2013-06-18T18:49:16.913