backup of /boot partition

Hello all

I am using grub2 with openSUSE 12.2. Grub2 is installed in a /boot partition (in my case it lives on /sda1). I experienced a problem with my grub2 setup after a recent update (zypper patch - at the time, I had only the basic repos, as it was a fresh install to begin with) which caused me a few days worth of headaches to straighten out - my fix ended up being a re-format of my /boot and / partitions and a re-install, since I couldn’t get grub2 to re-install from the DVD, and I’ve just not done all the updates on this latest install, yet.

Anyway, to prevent this sort of fun in the future, I would like to make a backup of my /boot partition so that if something (me by accident or another software update) breaks my grub2 again, I can more easily roll it back.

Scanning the forums, I found this, although its for 11.3/11.4 and original grub:

http://forums.opensuse.org/opensuseforums/english/get-technical-help-here/install-boot-login/449400-backup-restore-grub-opensuse-11-3-x86-64-a.html

Would a solution like this work for grub2 as well? Is there a more obvious solution that I’m overlooking?

Could you explain what problem you had? The most bulletproof way to install grub2 is to have it embedded in post-MBR gap. In this case you have almost full functionality if anything goes wrong.

On 2012-10-18 19:16, dsteven1 wrote:

> Anyway, to prevent this sort of fun in the future, I would like to make
> a backup of my /boot partition so that if something (me by accident or
> another software update) breaks my grub2 again, I can more easily roll
> it back.

If grub is in a separate and small /boot partition, and the MBR is
generic, you can backup it simply with dd:


dd if=/dev/sda1 of=sda1_boot.img
dd if=/dev/sda of=sda_mbr.img count=1

(the second line backups the MBR and partition table)

It is what I do; although I don’t use grub2, it should work just as well.

Notice: be careful with dd, it is a wonderful command, but mistakes
impose heavy fines instantly.


Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)

I apologize in advance for this - I’m recounting this from memory, and my memory stinks - my system would not start into KDE - it would hang at “starting Firewall phase 2” - I had to use Alt-F2 to get a console login. I really figured this was no big deal, just a grub2 re-install and off I’d go. Maybe it doesn’t make any difference, but my system uses LVM for all partitions except the /boot partition - /boot is formatted as ext3. After booting the rescue DVD and getting my / and /home partitions mounted, I did a chroot and attempted to re-install grub2 - this failed with a message similar to “install failed - cannot write to read-only file system - aborting”. “mount” showed /sda mounted as “rw”.

Could you explain how to install grub2 into the post-MBR gap? I’m intrigued, and I can’t say I remember too many options on where grub2 will install when you are installing openSUSE and select grub2 as your boot loader. I thought a separate partition would be your best bet, but any thought of mine and a $1 will get you a coffee at White Castle too.

robin_listas

I have exactly as you describe - a small, separate /boot parition and generic MBR - I don’t boot any other OS’s on this box.

Would restoring my partition be as simple as:

dd -if=/dev/sd1_boot.img -of=/dev/hda1
dd -if=/dev/sda_mbr.img of=/dev/sda

On 2012-10-18 20:36, dsteven1 wrote:
>
> robin_listas
>
> I have exactly as you describe - a small, separate /boot parition and
> generic MBR - I don’t boot any other OS’s on this box.
>
> Would restoring my partition be as simple as:
>
> dd -if=/dev/sd1_boot.img -of=/dev/hda1

Yes. But no dashes, dd uses none. And hda? I think it should be sda.

> dd -if=/dev/sda_mbr.img of=/dev/sda

Don’t do this unless you also need to restore the mbr because it will
also replace the partition table.


Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)