Converting Boot Loader from LILO to GRUB

Submitted by fabio on Mon, 2007-04-30 10:47.

When I installed Arch Linux on my notebook I choose to install LILO as Boot Loader.

Why? Because, as a long time Slackware user, I didn't use GRUB enough and I didn't have the time to learn it.

Unfortunately, maintaining an Arch Linux system with LILO as boot loader is quite tiring because every time the default kernel is changed lilo needs to be reinstalled.

What happens if you forget to install? Your system won't boot anymore and you have to boot using the installation CD.

As Arch Linux change it's kernel quite often and I always forget to run lilo to reinstall LILO my system become unusable often.

GRUB, the other Linux boot loader, don't need to be reinstalled at every kernel change. This is why I finally decided to convert my system to GRUB as boot loader.

The Process

This are the steps I followed to use GRUB on my Arch Linux / LILO system.

The first thing to do is install grub on the system. On Arch Linux you can use pacman, but before installing it's better to update the already installed packages on your system:

pacman -Syu

Now let's install grub:

pacman -S grub

You now have to edit the file /boot/grub/menu.lst to match your old /etc/lilo.conf. This is not a really complex step.

For your information I report here the content of my old /etc/lilo.conf:

#
# /etc/lilo.conf
#

boot=/dev/hda
# This line often fixes L40 errors on bootup
# disk=/dev/hda bios=0x80

default=arch
timeout=50
lba32
compact
prompt

image=/boot/vmlinuz26
        label=arch
        append="root=/dev/hda5 init 5"
initrd=/boot/kernel26.img
        read-only

image=/boot/vmlinuz26
        label=arch-text
        append="root=/dev/hda5"
initrd=/boot/kernel26.img
        read-only


image=/boot/vmlinuz26
        label=archfallback
        append="root=/dev/hda5"
initrd=/boot/kernel26-fallback.img
        read-only


other=/dev/hda1
        label=Windows

As you can see I have 4 entries:

  1. arch: boots the system using run level 5 (starts X server)
  2. arch-text: boots in text mode
  3. archfallback: use the kernel26-fallback.img initrd (used if something goes wrong with the regular kernel)
  4. Windows: to boot Win

Following the GRUB /boot/grub/menu.lst file to have the same boot entries:

# Config file for GRUB - The GNU GRand Unified Bootloader
# /boot/grub/menu.lst

# DEVICE NAME CONVERSIONS
#
#  Linux           Grub
# -------------------------
#  /dev/fd0        (fd0)
#  /dev/hda        (hd0)
#  /dev/hdb2       (hd1,1)
#  /dev/hda3       (hd0,2)
#

#  FRAMEBUFFER RESOLUTION SETTINGS
#     +-------------------------------------------------+
#          | 640x480    800x600    1024x768   1280x1024
#      ----+--------------------------------------------
#      256 | 0x301=769  0x303=771  0x305=773   0x307=775
#      32K | 0x310=784  0x313=787  0x316=790   0x319=793
#      64K | 0x311=785  0x314=788  0x317=791   0x31A=794
#      16M | 0x312=786  0x315=789  0x318=792   0x31B=795
#     +-------------------------------------------------+

# general configuration:
timeout   5
default   0
color light-blue/black light-cyan/blue

# boot sections follow
# each is implicitly numbered from 0 in the order of appearance below
#
# TIP: If you want a 1024x768 framebuffer, add "vga=773" to your kernel line.
#
#-*

# (0) Arch Linux
title  Arch Linux
root   (hd0,4)
kernel /boot/vmlinuz26 root=/dev/hda5 init 5 ro
initrd /boot/kernel26.img

title  Arch Linux  [text]
root   (hd0,4)
kernel /boot/vmlinuz26 root=/dev/hda5 ro
initrd /boot/kernel26.img

title  Arch Linux  [fallback]
root   (hd0,4)
kernel /boot/vmlinuz26 root=/dev/hda5 ro
initrd /boot/kernel26-fallback.img

# (1) Windows
title Windows
rootnoverify (hd0,0)
makeactive
chainloader +1

Once you have a correct /boot/grub/menu.lst file you can try it installing grub:

grub-install LOCATION

where LOCATION is where you want to install grub specified using GRUB naming convention:

grub-install (hd0)

or using standard Linux naming:

grub-install /dev/hda

The above commands will install GRUB on the MBR of your first PATA drive.

Help me I'm not able to boot!

Well.. this happens. If you have installed grub to boot but your configuration is wrong you will not be able to boot your system.

Fortunately you can still boot using your Arch Linux CD. Just insert the CD on your PC during the boot process. Once you are at the boot CD prompt use:

arch root=/dev/hda5 noinitrd

(replace /dev/hda5 with the partition containing your system root partition) and you should be able to boot again to fix your GRUB configuration.

Conclusion

Migrating from LILO to GRUB wasn't a complex task. If you already know Linux you will not have to much problems. If you still can't use it just ask for help on any of the linux forums available.

Read your bio, etc.

Submitted by dhave (not verified) on Thu, 2007-07-19 16:49.

Hi, again. I just read your bio and CV on your site. I wish you well with your various endeavors. Once again I'm amazed at the Internet, even after all these year -- a computer science grad student in Torino, Italy, helping a 51-year-old high school teacher in South Carolina, USA, all in a period of a few minutes.

I'm sure you have a bright future. Keep up the good work.

Thanks again.. hope to see

Submitted by fabio on Fri, 2007-07-20 18:29.

Thanks again!
You are right, Internet is incredible!

Hope to see you on my site again!

Thanks for lilo->grub info

Submitted by dhave (not verified) on Thu, 2007-07-19 15:26.

I really appreciate your posting this brief how-to. It corresponded exactly to my situation: long-time Slack (and Gentoo) user, never bothered to learn grub, now using Arch and getting tired of forgetting to re-run lilo after every kernel upgrade.

Your instructions were the clearest I found on the Web.

Now I'm a convinced grubber. Thanks again.

One other thing: I had

Submitted by dhave (not verified) on Thu, 2007-07-19 15:48.

One other thing: I had thought about changing from lilo to grub a few times in the past, but I had always assumed it would be a major undertaking. It wasn't at all. As you mentioned, it's not in the least complicated. I think the whole procedure took less than five minutes, and much of that time was waiting for the machine to reboot.

Thanks!

Submitted by fabio on Thu, 2007-07-19 16:07.

Thanks for your comments dhave! I'm really happy that you enjoyed this article and that you share my opinions.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <img> <h2> <h3> <h4> <b>
  • Lines and paragraphs break automatically.
  • Images can be added to this post.
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • You may insert videos with [video:URL]

More information about formatting options