developerWorks: Linux : Tip: Dual-booting Linux - La page d'accueil

Apr 22, 2002 - the Linux command window where you can configure your system. 1. Scroll down until you ... to list the label you used during installation. Now save the file ... Application server and DB2) on the different partitions. Resources.
65KB taille 1 téléchargements 232 vues
developerWorks: Linux : Tip: Dual-booting Linux .................

Advanced search IBM home | Products & services | Support & downloads | My account IBM developerWorks : Linux : Linux articles Tip: Dual-booting Linux How to build a dual-booting Linux system on a single hard drive Chuks Onwuneme ([email protected]), Programmer, IBM Farhan Khawaja ([email protected]), Software Specialist, IBM

Contents: Red Hat dual boot: Installation instructions Installation mark two

April 2002 Having multiple Linux installations to work with allows you to easily test different libraries with the same program, watch how your program interacts with others, or just tweak a parameter here or there to see what happens. This comes in handy for development and testing -- as well as for customer support. You say that you don't have oodles of boxes to work with? No worries -- installing multiple instances of Linux on a single box is a cinch, as you'll soon discover in this tip from IBM interns Chuks Onwuneme and Farhan Khawaja. As co-ops with IBM Developer Relations, our duties involve helping out the technical support staff to answer customer questions (in other words, we help the Help Desk). We work primarily with IBM WebSphere products -- and one situation we have encountered often is the need to tweak machines to re-create actual customer problems.

Editing lilo.conf Resources About the authors Rate this article Related content: Installing FreeBSD Setting up a multi-boot machine with Linux and other operating system Partition planning tips Compiling the Linux kernel

Re-creating each problem literally means having the exact same system as the Subscribe to the customer, and it is of course much more efficient to do this by partitioning and developerWorks newsletter running multiple systems on each drive, than to have a separate box for each system. And so, some many months ago, we converted from the one-box-per-system method Also in the Linux zone: to multiple systems on each box. Tutorials Now we can (for instance) run two different versions of IBM WebSphere Tools and products Application Server on the same OS. All that is needed is to partition a large drive Code and components (ours are generally 19G in the lab) into two halves, install the operating system on each partition, then install a version of Websphere Application Server on each Articles partition. Thus, we have have multiple copies of similar environments running on one machine. We work with various operating systems in the IBM lab, including several Microsoft Windows and NT flavors (Windows 2000 Server and Professional versions, NT Server and NT Professional), as well as AIX and Linux (Red Hat 6.2). The Microsoft systems include a utility for multiple OS installations, and the conversions were accomplished with little difficulty. However, as we were new to Linux, the Red Hat systems gave us some trouble, especially as we had difficulty finding easy, clear documentation to guide us. This tip, then, is offered in the hopes that others who may be new to Linux and who are facing the same challenge will find it easily, and will find it to be clear, concise and easy to use. Please do let us know if we succeeded (you'll find our email addresses at the top and the bottom of this article). Our tip covers the installation of multiple instances of the same Linux distribution on a single drive (we use Red Hat in the lab). But with a few tweaks (or with help from some of the documents listed in the Resources section) you should have no problems creating a machine which dual-boots different Linuxes, or combinations of Linux and non-Linux operating systems. In this tip, we used an older version of Red Hat because we were trying to build exactly the same system as the customer. Hence, the Red Hat version used here is a few years old, and uses the older 2.2 kernel. Newer Linux kernels handle multi-booting differently. It is advisable to upgrade to the newer version of the Linux 2.4(.x) kernel in any case, if you can, for security reasons. Moreover, most Linux installations today now offer GRUB instead of

http://www-106.ibm.com/developerworks/library/l-dboot.html (1 of 6) [4/22/2002 7:47:26 AM]

developerWorks: Linux : Tip: Dual-booting Linux

or in addition to LILO. This feature offers more advanced ways to handle the Linux multi-booting facility. Thus, the following tip might not be exactly useful if you are using a newer version that does not use LILO -- but it should be indespensible if you are! Red Hat dual boot: Installation instructions When you are ready to begin the process, first shut down your sytem and restart it. Then place the Red Hat Linux CD in the drive. The Red Hat Linux installation routine will take you through a very simple install process. You will have to do some basic system configuration such as choosing the default language, the type of keyboard, and so on. Enter the proper information until the "Partitions" screen comes up. When it does, click on the "add" button and select "Linux Native" as the type of operating system. For "size" type in 16 (megabytes), and choose /boot as the type of partition. The rest of the configuration is given below and can be achieved by repeating the instructions above for the particular partition: /boot / swap /var /tmp

sda1 sda5 sda6 sda7 sda8

16M 1024M 256M 200M 200M

Linux Linux Linux Linux Linux

native native swap native native

Note that these directory locations are for SCSI drives. For IDE drives, simply replace the s in sda1 with an h (to give you hda1 for the /boot drive, hda5 for the root drive, etc). Also note that the sizes used above were suitable for our hardware -- they are not mandatory. You have the flexibility to choose any size that suits yours, especially as these days newer hardware can support various configurations. However, you don't want to have too much space allocated to your "/boot" partition, as most of the space will end up being wasted -- on the newest hardware, you'll probably want an even smaller boot partition than we have. Other sizes could be used with the other partitions as well. Installation mark two Now you are ready to install your second instance of the Linux kernel. Follow these simple guidelines: ● Install lilo on the Master Boot Record (MBR) again ● Use linear mode (strictly needed for SCSI drives) ● Leave the kernel parameters blank The initial install partitions should remain labled as 'Not Set.' Leave them as Not Set and add the five new partitions by clicking on "add" and installing just as specified above. All you need to do is keep adding the new partitions without deleting or editing partitions from the previous install. The rest of the install remains the same. You can use any name you like (we used linux2). But if your label is more than one word, make sure to enclose it in quotation marks (i.e., "Linux 2" if you prefer to leave a space in). And of course, make sure to label the second install with a different name than the first. After installation, the system reboots and brings up a prompt. Press the Tab key: this should display the label of the second Linux install. Type in "linux2" (or whatever name you gave to the second image) and press Enter, this will bring up the second Linux system which you just installed. Editing lilo.conf Next, we will edit the LILO (Linux Loader) configuration file, lilo.conf, to add a record telling Linux about the first install that we did. To do this, go to the /etc directory and open the lilo.conf file in your favorite editor (you probably want to make a backup copy first, just in case). The lilo.conf code looks like this:

http://www-106.ibm.com/developerworks/library/l-dboot.html (2 of 6) [4/22/2002 7:47:26 AM]

developerWorks: Linux : Tip: Dual-booting Linux

boot=/dev/sda #this points to the boot device timeout=300 #if no activity in the specified time, load default image linear prompt Default="Linux2" #Linux1 will be displayed at the prompt Vga=normal #video mode read-only map=/boot/map Install=/boot/boot.b image=/boot/vmlinuz=2.2.14-5.0 Label="Linux2" initrd=/boot/initrd-2.2.14-5.0 Root=/dev/sda10

#location of boot image #label #location of root partition

Note that the comments (which are preceded by a #, or hash symbol), are ignored by the computer. They are included here so that you can see exactly what each line is used for -- it isn't necessary to include them in the lilo.conf file on your system unless you would like to have them there for your reference. And again, remember to replace sda with hda if you are using an IDE drive. Another way of configuring LILO Here is an alternative to editing the lilo.conf file. 1. Open up a terminal window, and go to the "/root" directory and type linuxconf. This should bring you to the Linux command window where you can configure your system. 2. Scroll down until you get to Boot mode Under "boot mode," you should see the options for configuring LILO. Select the second on the menu, "Configure LILO Linux configurations," then click on the "LILO Linux configurations" tab. 3. Click on "Add." You can then add the locations of the other Linux boot partitions and kernel files. If you're not sure about what to add in each field, look at those already listed before typing anything. Taking a look at the above lilo.conf file, you will notice that it belongs to the Linux install labeled linux2, the one we installed second during the install process. Now, to make LILO dual boot the first Linux instance installed on a the /sda5 (/hda5 for IDE drives) partition, add the following right after the last line: image=/boot/vmlinuz=2.2.14-5.0 label="Linux1" initrd=/boot/initrd-2.2.14-5.0 root=/dev/sda5 So after editing the code above, the final file should look like this: boot=/dev/sda timeout=300 linear prompt default="Linux2" vga=normal read-only map=/boot/map install=/boot/boot.b image=/boot/vmlinuz=2.2.14-5.0 label="Linux2" initrd=/boot/initrd-2.2.14-5.0 root=/dev/sda10 image=/boot/vmlinuz=2.2.14-5.0 label="Linux1" initrd=/boot/initrd-2.2.14-5.0

http://www-106.ibm.com/developerworks/library/l-dboot.html (3 of 6) [4/22/2002 7:47:26 AM]

developerWorks: Linux : Tip: Dual-booting Linux

root=/dev/sda5 Make sure to specify the root path just as it is done on the last line, above -- this is very important. Also make sure to list the label you used during installation. Now save the file and type the command lilo at the prompt. This will recompile the file, and save the updated configuration. Notice that the image/kernel remains the same for both installations (/boot/vmlinuz=2.2.14-5.0). Since we're doing a dual boot of the exact same system, we're installing from the same CD, therefore we have the same image file. If you are installing different distributions, these files will differ. Now we are nearly done. Next you'll want to issue the reboot command from the terminal: shutdown -r now. When the computer restarts, the LILO prompt appears. Press the Tab key and you should see: Linux2

Linux1

Boot:_ At the boot prompt, type Linux1 to boot into the first Linux install that we did. When it comes up, you will need to go into its lilo.conf file -- it will be very similar to the one we just edited for the second image, the only difference being that the default image is /sda5 (or /hda5 if you have an IDE drive), with a label of "linux1." We will edit this file just as we did the other, adding these lines to the end: image=/boot/vmlinuz=2.2.14-5.0 label="Linux2" initrd=/boot/initrd-2.2.14-5.0 root=/dev/sda10 Thus, the code for the entire file will look like this: boot=/dev/sda timeout=300 linear prompt default="Linux1" vga=normal read-only map=/boot/map install=/boot/boot.b image=/boot/vmlinuz=2.2.14-5.0 label="Linux1" initrd=/boot/initrd-2.2.14-5.0 root=/dev/sda5 image=/boot/vmlinuz=2.2.14-5.0 label="Linux2" initrd=/boot/initrd-2.2.14-5.0 root=/dev/sda10 Save the file and recompile it by typing lilo at the command prompt. Issue the reboot command once more; when the system comes up, you'll also be prompted to select the LINUX boot. When you hit the Tab key this time, you'll be presented with the following list: LINUX BOOT: Linux1

Linux2

Boot:_

http://www-106.ibm.com/developerworks/library/l-dboot.html (4 of 6) [4/22/2002 7:47:26 AM]

developerWorks: Linux : Tip: Dual-booting Linux

And that's it! You have just built a dual-boot Red Hat Linux system. It should now prove trivial for you to install as many images as you'd like, or to install different versions of application software (as we did with WebSphere Application server and DB2) on the different partitions. Resources ● Partitioning a drive for the first time can be nerve-racking. PowerQuest offers a product called Partition Magic to make the process easier. ●

VCOM offers a rival product called System Commander 2000, which does more or less the same thing.



The examples in this tip use LILO. You might also want to try the GNU GRUB Multiboot boot loader, a newer utility that does much the same thing but with more functionality. If you've never installed Linux before, you'll find the The Linux Installation HOWTO by Eric Raymond to be an invaluable aid. For troubleshooting or a quick look at installation help, see Part 6 of the HOWTO, Installation In Detail.





Installing Linux and Windows together is what LILO was made for. The LInux LOader (hence, LILO) has excellent documentation. But for a preview (or a quick version) of how to do this, see item 3 (The Simple Configuration) of the LILO mini-HOWTO.



For advice on setting up a multi-boot machine with Linux and other operating system, read Operating system flexibility (developerWorks, December 2000).



The Win95 + WinNT + Linux multiboot using LILO mini-HOWTO details how you can use LILO instead of using NT's OS loader to multiboot mixed Windows and Linux environments. The article Dual booting Win2K and Linux outlines one strategy for showing Linux how to recognize NTFS partitions as bootable. You say it isn't multiple Linuxes that are giving you problems, but multiple disks (with or without multiple Linuxes on them)? Then you probably want to take a look at the Multi Disk System Tuning HOWTO.









Don't want to have to reboot all of the time to switch from one Linux image to another? No worries! The Development for Multiple Linux Distributions mini-HOWTO outlines a neat chroot trick that may save you the trouble. A high-end product that lets you run multiple operating systems simultaneously -- so that you can, say, run Windows applications under Linux (!) -- is VMware.

Finally, why stop at two or three or ten measly installations of Linux on one box? Read how IBM programmers in Germany got 41,400 copies of Linux running on a mainframe from Earthweb's developer.com. About the authors Chuks Onwuneme currently attends the University of Texas at Arlington, studying for a B.S. in Computer Science and Engineering. He expects to complete his degree in May 2002. Chuks joined IBM in June 2000, first as a intern with e-Business Operating System Solutions at the Austin site, and then as a co-op with Developer Relations, Internet and Network Computing in Dallas. You can contact Chuks at [email protected] or external e-mail [email protected]. ●

Farhan Khawaja is a Computer Science and Engineering Intern at IBM Dallas and is currently working toward a B.S. in Computer Science and Engineering at the University of Texas at Arlington. He has worked as a programmer developing in Java, C++, ASP, and Visual Basic. His interests include Linux, playing sports, and listening to music. You can contact Farhan at [email protected].

http://www-106.ibm.com/developerworks/library/l-dboot.html (5 of 6) [4/22/2002 7:47:26 AM]

developerWorks: Linux : Tip: Dual-booting Linux

What do you think of this article? Killer! (5)

Good stuff (4)

So-so; not bad (3)

Needs work (2)

Comments?

Submit feedback

IBM developerWorks : Linux : Linux articles About IBM | Privacy | Legal | Contact

http://www-106.ibm.com/developerworks/library/l-dboot.html (6 of 6) [4/22/2002 7:47:26 AM]

Lame! (1)