Friday, August 28, 2009

Installing GRUB2

On my last post I described how I hit a problem while trying to rescue files from a bricked Window$ Vista laptop, using my Live HDD (a complete Debian system that I boot from a USB hard disk). My problem: how does one run chkdsk on a corrupted NTFS partition, without a Window$ installation disk?

As I mentioned last time, if you have it installed, you may be able to start the Recovery Console and check the disk. But chances are that either you don't have it installed (Window$ XP) or that it too fails to start.

While searching for a stand alone disk checking utility I recalled that I've once used BartPE to attempt to rescue files from an old desktop PC that I've managed to fry. BartPE was a real wonder at the time: a Window$ Live CD (also known officially as a Windows Preinstallation Environment). You must have a legitimate copy of Windows XP in order to create the Live CD, but other than that it just works. And it includes chkdsk from the original Windows install disk.

(Later on, as I searched some more, I found WinBuilder and LiveXP, which are more versatile and rich in features, but I'll leave that to a future post).

Anyway, I also hit a blog post on how to boot an ISO image via GRUB2. This looked promising: all I had to do was create a Windows PE ISO image, place it on my Live HDD boot partition, and boot into it using GRUB2.

Let me tell you upfront: it doesn't work this way - I misinterpreted that article, and only much later realized that while GRUB2 can loop-mount an ISO image, this doesn't mean that it can boot it. The blog post about why GRUB2 cannot actually boot CDROM images clarifies what can and cannot be done with GRUB2.

So, misguided as I was, I went on to upgrade GRUB on my Live HDD, and replace it with GRUB2. Basically, all that needs to be done is run
aptitude install grub-pc
this will add GRUB2 as the first boot option in the GRUB boot menu ("Chainload into GRUB 2") , but will not replace GRUB on the MBR, so that you may revert to GRUB if you encounter any problem.

Which is pretty considerate.

Once you're happy with it, you should run upgrade-from-grub-legacy in order to finish the transition.

As easy as pie. Really. Unless it bricks your machine. Luckily, it didn't brick mine, which I find somewhat surprising...

I've been hit by some quirks though, most annoying of which is the fact that currently memtest86+ cannot be launched from GRUB2, unless you apply a patch to /etc/grub.d/20_memtest86+ and run update-grub (see Debian bug #540572).

After I verified that GRUB2 worked as advertised, it took a few failed attempts to boot a BartPE ISO image from GRUB2, before I did some more research and realized that I hit a dead end.

What a disappointment.

All in all, I find that there's no real reason to upgrade to GRUB2, unless you really need it. Sure, it's sexier than legacy GRUB (I liked the default Debian graphical background), its configuration is scriptable, it can loop-mount ISO images, it can boot from an Ext4 partition, and much more. But, if your machine works fine with legacy GRUB, I'd suggest you wait for it to be officially obsoleted before upgrading to GRUB 2.

[24 Sep 2009] UPDATE: It didn't take long - the package grub-pc is now the official upgrade path for grub, so I've upgraded to GRUB2 on my laptop too. Works just fine. Just the way I like it.

2 comments:

  1. There are some good reasons to use grub2 in preference to grub but they may not be compelling or relevant to everyone. In my case I upgraded to grub2 because the legacy grub can't boot a kernel on an ext4 filesystem. ext4 offers such big improvements over ext3, along with easy conversion from ext3 to 4, that it's well worth using, especially if you have large filesystems and/or very large files. Write performance is superior, fragmentation is much less due to use of extents so read performance is better too. And running e2fsck even on a very large filesystem i.e. 100s of GB now only takes a few seconds. So grub2 can have clear advantages.

    ReplyDelete
  2. I did mention Ext4 as a reason to switch to GRUB2, and you point out several significant advantages of Ext4 over Ext3. Thanks for that.

    Yet, Ext4 seems to still have some major quirks and bugs (see, for example the article about ext4 and data loss).

    It's bound to improve, but I guess it'll take me some time before I go this way.

    ReplyDelete