Friday, August 21, 2015

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



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?


Answer



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.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...