Linux System Administration: Using LILO, The Linux Loader
In general, the boot process on a microcomputer has three stages: the system's master boot record (MBR) contains the primary boot program which starts the boot process and loads a secondary boot program from the boot blocks of the active partition; this second boot program is what loads the actual kernel.
Linux provides LILO, the Linux Loader, which can function as either a master boot program or a secondary boot program. lilo is installed with a command like this one:
# lilo -C /etc/lilo.conf
The -C option specifies the location of LILO's configuration file. (The location in the preceding command is, in fact, the default location, and so the -C clause is redundant.)
The lilo.conf file specifies LILO's behavior for certain aspects of the boot process and also defines the kernels and operating systems that it can boot. The following excerpt from a lilo.config file lists the most important entries—and the ones that you are most likely to want or need to modify:
# Wait 10 seconds before autobooting 1st entry.timeout=100 # Allow user to enter a boot command. prompt # Where to install/configure LILO # (no partition #=MBR) [see below] boot=/dev/hda ... # Text file displayed before boot prompt. message = /boot/boot.message # # Default kernel is the first one listed. image = /vmlinuz # Boot prompt command to boot this kernel. label = linux # Fix for Sony CD-ROM (post 1.1.72) # Specifies parameters to pass to kernel, # changing CD-ROM's compiled-in I/O address. append = "cdu31a=0x340,0," # # An alternate Linux kernel image = /safe # Its boot command label = safe append = "cdu31a=0x340,0," ... # A different operating system (DOS) other = /dev/hdb1 # Use the D: drive boot loader. loader = /boot/any_d.b # Use this partition table. table = /dev/hdb # This is the corresponding boot command. label = ddog
[I tend to install LILO both in the MBR and the Linux partition for maximum flexibility, by running a second LILO command using its -b option (which replaces the boot entry in the configuration file):# lilo -b /dev/hda1 -C /etc/lilo.confThis way, if I decide to remove LILO from the MBR, I'll be all set to switch over to the Linux partition version.]
The final section (“stanza”) illustrates the format for booting a DOS partition on the second hard disk; it uses an alternate loader, any_d.b, which tricks DOS into thinking it's on the C: drive. There are also loaders provided for OS/2 on the D: drive and DOS on the B: drive (os2_d.b and any_b.d, respectively; chain.b is the default loader for other operating systems).
If the label for a stanza is omitted, it defaults to the final component of the image or other entry (for example, vmlinuz or hda1).
The entry for a DOS partition on the C: drive is simpler, looking something like this:
other = /dev/hda1 label = dos table = /dev/hda
This stanza is actually what you need for any foreign operating system on /dev/hda1. There is one additional trick needed if SCO Unix is the operating system you want to boot. In order for LILO to successfully boot a SCO Unix partition, that partition must be the only active partition on the C: drive. This means you will have to turn off the active (boot) flag on the Linux partition and turn it on for the SCO Unix partition, using the Linux fdisk or cfdisk, before trying to boot SCO Unix (in addition to running LILO to install the new configuration). Note that LILO must be the master boot loader in this case.
Note: You will need to rerun the LILO command to reinstall it every time you rebuild the kernel or change any relevant aspect of the disk partitioning scheme. If you forget to do this, the system will not boot and you'll have to boot from a floppy. You will also need to rerun LILO if you change the text of the boot.message file.
Booting a Linux partition on the second hard drive is also possible. For this to work, LILO must be installed in the MBR of the system's boot disk, as well as the secondary boot program in the Linux partition itself—this is usually taken care of when you install Linux on the hard disk and will be assumed in what follows. In this case, the best way to proceed is in two stages:
First, set up a lilo.conf like this one:
boot=/dev/hdaroot=current image=/vmlinuz label=linux other=/dev/hda1 unsafe other=/dev/hda2 unsafe ... other=/dev/hdb4 unsafe
Define all of the partitions on both hard disks in the same way; the unsafe keyword tells LILO not to read the boot blocks or the disk's partition table for that entry—it basically says, “Trust me and do what I tell you.” Install this LILO configuration, and make sure that Linux is bootable.
Then, modify the file, changing entries for any bootable partitions on /dev/hda to their correct form and removing ones you don't need, and rerun the LILO command.
It is also possible to boot a Linux partition on each of two disks. The procedure for doing so is the following:
Decide which one will be the usual Linux boot partition and set up LILO to boot it and any other non-Linux operating systems on both disks. Create an entry like the following for the second Linux partition:
other = /dev/hdb2 label=eviltwin unsafe
Create a boot.message file which tells you which Linux will be booted when you select the default option. Install this configuration into the MBR on the C: drive.
Create (or retain) another LILO configuration for the second Linux partition, this time including an unsafe entry for the first Linux partition if you want to (this again assumes that LILO is installed in that partition, which usually happens at upon installation of the OS). Make sure that this partition's boot.message file also lets you know where you are. Install this configuration into the Linux partition only—make sure that the boot entry specifies the partition and not the disk as a whole.
The boot sequence will then go something like this:
Welcome to gallant.Boot choices: linux (default; on C:), dos, eviltwin (Linux on D:), sco boot: eviltwin Welcome to goofus. Boot choices: test (default; on D:), goodtwin (Linux on C:) boot: [Return] Loading test...
Given these selections, Linux will boot from the D: drive. What happens is the LILO from the MBR on drive C: runs first, and it then starts the boot program on the Linux partition on the D: drive—which is again LILO. That (second) LILO then loads the kernel from the D: drive. (Note that if you wanted to, you could just keep popping back and forth between the LILO programs on C: and D: ad infinitum.)
If you think this is pretty silly, then omit the prompt keyword from the LILO configuration file for the D: drive (as well as its image section for the Linux partition on the C: drive), resulting in a simple lilo.conf file on the D: drive:
install=/boot/boot.bboot=/dev/hdb2 root=/dev/hdb2 map=/boot/map image=/vmlinuz label=linux
Once this is installed, selecting eviltwin at the initial boot prompt will immediately boot the Linux partition on the second hard disk.
|Designing Electronics with Linux||May 22, 2013|
|Dynamic DNS—an Object Lesson in Problem Solving||May 21, 2013|
|Using Salt Stack and Vagrant for Drupal Development||May 20, 2013|
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
- New Products
- Linux Systems Administrator
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Designing Electronics with Linux
- Dynamic DNS—an Object Lesson in Problem Solving
- Using Salt Stack and Vagrant for Drupal Development
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Nice article, thanks for the
2 hours 42 min ago
- I once had a better way I
8 hours 28 min ago
- Not only you I too assumed
8 hours 46 min ago
- another very interesting
10 hours 39 min ago
- Reply to comment | Linux Journal
12 hours 32 min ago
- Reply to comment | Linux Journal
19 hours 26 min ago
- Reply to comment | Linux Journal
19 hours 42 min ago
- Favorite (and easily brute-forced) pw's
21 hours 34 min ago
- Have you tried Boxen? It's a
1 day 3 hours ago
- seo services in india
1 day 7 hours ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi
It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?