From 7774e7be933cc6498528d492a343083e1c4a14e1 Mon Sep 17 00:00:00 2001 From: Matěj Laitl Date: Tue, 11 Oct 2011 20:55:35 +0200 Subject: GRUB 2 Guide: add section about backing up a bootloader --- docs/grub-2-guide.xml | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/docs/grub-2-guide.xml b/docs/grub-2-guide.xml index 8b587d6..02fac52 100644 --- a/docs/grub-2-guide.xml +++ b/docs/grub-2-guide.xml @@ -27,7 +27,7 @@ This guide shows you how to install and configure the GRUB 2 bootloader. 1 -2011-10-10 +2011-10-11 About @@ -56,6 +56,65 @@ Some examples of new features: Installation + +
+Optional: Creating Backup of Existing GRUB Legacy Installation + + +

+Playing with bootloader always brings the danger of leaving your system in +unbootable state. Fortunately no data is lost in most cases and recovery is not +hard, but we recommend you to have a bootable CD, DVD or a USB flash disk with +Linux around (Gentoo +LiveDVD or System Rescue CD +will do) and to backup your current bootloader setup. If your current +bootloader is GRUB legacy, following code sample may help you backing it up. +

+ +
+# # copy grub modules and configuration
+# cp -a /boot/grub /path/to/backup/
+# # backup the MBR and GRUB stage 1.5
+# dd if=/dev/sda of=/path/to/backup/first-sectors count=63
+
+ + +Replace /dev/sda with device node of the disk you boot from (this is +usually and the whole disk like sda, not a partition like sda1) and +/path/to/backup with path to your favourite backup medium. + + +

+When something goes wrong, you can restore previous grub installation by +booting some Linux live media and issuing following commands. +

+ +
+# # move old grub files out of the way
+# mv /boot/grub /boot/grub.nonfunctional
+# # copy grub back to /boot
+# cp -a /path/to/backup/grub /boot/
+# # replace MBR and next 62 sectors of sda with backed up copy (DANGEROUS!)
+# dd if=/path/to/backup/first-sectors of=/dev/sda count=63
+
+ + +Replace /dev/sda with device node of the disk you boot from and +/path/to/backup with path to the place where you've stored your backup. + + + +Writing directly to disk sectors (even those that are outside of partitions +in typical setup) is risky operation and will make your data inaccessible +if you changed your parititon layout between backup and restore. Other slower +and safer option would be chrooting into your Gentoo installation and +re-installing bootloader - you can use Gentoo +Handbook for that task. + + + +
+
Setting Useflags -- cgit v1.2.3-65-gdbad