Installingmultiplelinuxdistributions Onasinglebox

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Hentzenwerke Whitepaper Series

Installing Multiple Linux Distributions on a Single Machine


By Whil Hentzen

There are lots of places that tell you the general ideas on setting up a multiple boot, usually with Windows as being one of the OSs. But what is the philosophy behind it What about some of the war stories How many partitions What boot partitions While the doc says ! you can!, what are the ramifications of doing so How do you set up multiple "inu# installations What are the step by step instructions $n this whitepaper, we%re going to install &edora 'ore, and then put SuS( on the same bo#. When we%re done, we%ll ha)e a machine with a boot screen that pro)ides options to load either &edora 'ore or SuS(.

Hentzenwerke Publishing, Inc. books@hentzenwerke.com www.hentzenwerke.com

Installing Multiple Linux Distributions on a Single Machine

Page 2

*. +reface
*.* 'opyright
Copyright 2004 Whil Hentzen. Some rights reserved. This work is licensed under the Creative Commons ttri!ution" #onCommercial"#o$erivs %icense& which !asically means that you can copy& distri!ute& and display only unaltered copies o' this work& !ut in return& you must give the original author credit& you may not distri!ute the work 'or commercial gain& nor create derivative works !ased on it without 'irst licensing those rights 'rom the author. To view a copy o' this license& visit http())creativecommons.org)licenses)!y"nc"nd)2.0).

*., -e)isions
*.,.* History
.ersion
1.0.0

/ate
2004/1/1

Synopsis
!riginal

0uthor
"H

*.,., 1ew )ersion The newest version o' this document will !e 'ound at www.hentzenwerke.com. *.,.2 &eedback and corrections *' you have +uestions& comments& or corrections a!out this document& please 'eel 'ree to email me at ,!ooks-hentzenwerke.com,. * also welcome suggestions 'or passages you 'ind unclear.

*.2 -eferences and acknowledgments


Thanks to .%/0 mem!ers including 1oe 2rost& 3hil 0oem!el& 0lenn Holmer& 0eorge .oulton and .ark 3.

*.3 /isclaimer
#o warranty4 This material is provided as is& with no warranty o' 'itness 'or any particular purpose. /se the concepts& e5amples and other content at your own risk. There may !e errors and inaccuracies that in some con'igurations may !e damaging to your system. The author6s7 disavows all lia!ility 'or the contents o' this document. 8e'ore making any changes to your system& ensure that you have !ackups and other resources to restore the system to its state !e'ore making those changes. ll copyrights are held !y their respective owners& unless speci'ically noted otherwise. /se o' a term in this document should not !e regarded as a''ecting the validity o' any trademark or service mark. #aming o' particular products or !rands should not !e seen as endorsements.

*.4 +rere5uisites
This document was written using 2edora Core 9.0 and assumes a !eginner,s 'amiliarity with use o' %inu5 via the 0/* and the Command Window.

,. Boot "oaders and +artitions


*n order to con'igure a machine with multiple distri!utions& you need to know something a!out !oot loaders and partitions and how %inu5 starts up.

,.* Hardware configuration


There are two parts o' a personal computer,s hardware that we,re going to !e interacting with during this process& so you have to know something a!out them !e'ore we !egin. These items are the .aster 8oot :ecord 6.8:7 and hard disk partitions. ll personal computers with a hard disk have a special area in the hard drive,s 'irst sector called a .aster 8oot :ecord that is used as part o' the !oot process. ll 3Cs have one and only one .8: " it doesn,t matter how many operating systems are installed on the computer. personal computer hard disk is divided into one to 'our areas called partitions. ;nly one ;S can !e installed in a partition& !ut an ;S can e5tend over more than one partition. However& with %inu5& multiple versions o' a distri!ution can !e contained in the same partition " they,re simply stored in di''erent directories. 2or e5ample& suppose 2edora Core 2.4.22 is

Hentzenwerke Publishing, Inc. books@hentzenwerke.com www.hentzenwerke.com

Installing Multiple Linux Distributions on a Single Machine

Page #

installed on a computer. Then& a while later& the kernel is updated to version 2.4.2<. The 'iles 'or this new version don,t have to !e contained in a separate partition. :ather& a new directory is created during the update process that contains the 'iles speci'ic to 2.4.2<. conse+uence o' this architecture is that the user can choose which version to load " they,re !oth availa!le during the !oot process. 6Why would you want more than one version o' a distro on a computer= *n order to use so'tware that ran well under a previous version !ut wasn,t working under the new one.7 Contrast this with the process used to update Windows. 'ter you update an installation o' Windows with a service pack or patch& you,re !asically stuck with that new updated version " depending on the speci'ic situation& the ease o' loading anything other than the current version ranges 'rom very di''icult to !asically impossi!le. *' you 'ind that the updated version doesn,t work satis'actorily& either due to its own !ugs or to incompati!ilities with other so'tware& your only choice o'ten is to reinstall the entire computer 'rom scratch. With %inu5& i' you 'ind !ugs or incompati!ilities& you can load an earlier version simply !y selecting it 'rom a menu that displays during startup.

,., How "inu# starts up


Since we,re installing multiple operating systems on a machine& how the machine starts up is really important in'ormation. ,.,.* 6eneric tests When a personal computer starts up& a 'ew things happen regardless o' what type o' operating system is !eing used. 2irst& the power supply checks itsel' to make sure it can do its own >o!. #e5t& the 3C looks to a :;. address to 'ind out where the 8*;S 6!asic input"output system7 is. The 8*;S is loaded& which runs a !atch o' diagnostic tests. *' they all pass& the 8*;S determines i' this start up was 'rom scratch 6power on7 or a re!oot 6the machine was already on.7 *' the machine was >ust turned on& the 3;ST 6power"on sel'"test7 is e5ecuted& which then runs another series o' tests& the results o' which are echoed to the screen. These include video and memory tests. *' the machine was re!ooted& the 3;ST is skipped. ,.,., /e)ice selection and boot loaders The ne5t step is 'or the 8*;S to +uery the C.;S 6a !it o' :;. powered !y a little watch !attery on the mother!oard7 to 'ind out which device the 8*;S is supposed to try to !oot 'rom " the 'loppy& the hard drive& or the C$":;.. The 8*;S will run a program called a !oot loader 'rom that device that continues the !ooting process. How the !oot loader program is constructed depends on which operating system is installed and which device is !eing used. $i''erent operating systems use di''erent !oot loader programs? there are a num!er o' !oot loaders availa!le in the %inu5 world& !ut most %inu5 distri!utions provide two 'rom you to choose 'rom during installation " %*%; 6%*nu5 %;ader7 and 0:/8 60:and /ni'ied 8ootloader7. %*%; is older !ut su''ers 'rom some limitations? 0:/8 is newer and has additional capa!ilities. The popular distri!utions such as :ed Hat& SuS@ and .andrake all use 0:/8 as their de'ault !oot loader. This discussion will cover 0:/8. ,.,.2 7aster Boot -ecord *' the C.;S indicates the 'irst !oot device is a hard disk& the !oot loader is divided into at least two parts. The 'irst part is contained in the hard drive,s .aster 8oot :ecord. 6How the !oot loader is constructed i' the !oot device is something other than a hard disk doesn,t concern us during this discussion.7 The .8: is a A92 !yte chunk o' 9,s and 0,s located in the sector at cylinder 0& head 0& sector 9 o' a hard disk. The .8: must per'orm the same 'unctions regardless o' what operating system is installed& !ut the speci'ic contents o' the .8: depends on what operating system6s7 are installed on the machine. $;S .8: is constructed di''erently than a Windows .8:& which is di''erent 'rom an ;S)2 .8:& which is di''erent than a %inu5 0:/8 .8:. ;n a machine using %inu5 and 0:/8& the .8: contains !oth a chunk o' code 6the 'irst part o' the !oot loader7 that e5ecutes when called 'rom the 8*;S and a partition ta!le that descri!es how many partitions are on the hard disk and where they are located. t least one o' the partitions identi'ied in the .8: is identi'ied as !eing the !oota!le partition& via a pointer in the .8:. The !oota!le partition contains the rest o' the !oot loader code. The code in the .8: directs it to load the !oota!le partition,s !oot loader code. ,.,.3 Stage * s mentioned& a !oot loader program is !roken into more than one part. With 0:/8& it,s !roken into three parts& called ,stages,. These stages are named Stage 9& Stage 9.A& and Stage 2. Stage 9 is the part contained in the .8:& and whose 'unction is to read the partition ta!le in the .8:. Stage 2 is called 'rom Stage 9& although in some special instances& a third stage& Stage 9.A inter>ects itsel' in !etween 9 and 2. Those instances involve the use o' a reserved area !y certain operating systems 6like 2ree8S$7 and so aren,t applica!le in this discussion.

Hentzenwerke Publishing, Inc. books@hentzenwerke.com www.hentzenwerke.com

Installing Multiple Linux Distributions on a Single Machine

Page 4

ll we care a!out is that Stage 9 runs 'rom the .8:& and calls Stage 2& which is located in the !oota!le partition,s !oot loader code. ,.,.4 Stage , Stage 2 reads a 'ile called )!oot)gru!)menu.lst that provides that data needed to display the !oot menu " the screen where multiple kernels o' the same or di''erent distri!utions are shown. Figure 1 shows a !oot menu that contains options 'or !oth !ooting either 2edora Core or SuS@.

Figure 1. A boot menu with two operating system choices. The contents o' the menu.lst 'ile that generates the !oot menu shown in 2igure 9 are shown in Listing 1. #ote that the line a'ter ,title SuS@ %inu5, starting with the word ,kernel, wrapped in this listing. Listing 1. Contents of menu.lst for the boot menu shown in Figure 1.
# grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a boot !artition. This means that # all kernel and initrd !aths are relative to boot " eg. # root #hd$"$% # kernel vmlinu&'version ro root( dev hda) # initrd initrd'version.img #boot( dev hda default($ timeout(*$ s!lashimage(#hd$"$% grub s!lash.+!m.g& title ,edora Core #).-.))'*.)**..n!tl% root #hd$"$% kernel vmlinu&').-.))'*.)**..n!tl ro root(/01E/( rhgb initrd initrd').-.))'*.)**..n!tl.img title 2u2E /inu+ kernel #hd$"3% vmlinu& root( dev hda3 vga($+3*- s!lash(silent deskto! hdc(ide'scsi hdclun($ sho4o!ts initrd #hd$"3% initrd

Figure 2 shows a !oot menu that contains multiple options 'or !ooting SuS@.

Hentzenwerke Publishing, Inc. books@hentzenwerke.com www.hentzenwerke.com

Installing Multiple Linux Distributions on a Single Machine

Page $

Figure 2. A boot menu with multiple options for booting SuS . The menu.lst 'ile 'or 2igure 2 is shown in Listing 2. #ote that the lines starting with the word ,kernel, have wrapped in this listing. Listing 2. Contents of menu.lst for the boot menu shown in Figure !.
# 5odified by Ya2T). /ast modification on ,ri Nov )* *.:*.:*- )$$3 color 4hite blue black light'gray default $ timeout 6 gf+menu #hd$"$% message ###7on8t change this comment ' Ya2T) identifier: Original name: linu+### title /inu+ kernel #hd$"$% vmlinu& root( dev hda3 vga($+3*- s!lash(silent deskto! hdc(ide'scsi hdclun($ sho4o!ts initrd #hd$"$% initrd ###7on8t change this comment ' Ya2T) identifier: Original name: flo!!y### title ,lo!!y root #fd$% chainloader 9* ###7on8t change this comment ' Ya2T) identifier: Original name: failsafe### title ,ailsafe kernel #hd$"$% vmlinu& root( dev hda3 sho4o!ts ide(nodma a!m(off ac!i(off vga(normal nosm! noa!ic ma+c!us($ 3 initrd #hd$"$% initrd

The !oot menu is placed on top o' a splash screen that is provided with a speci'ic distri!ution " you can see that the splash screen in 2igure 9 is 'rom the 2edora distri!ution while the splash screen in 2igure 2 is 'rom SuS@. Selecting one o' the items in the !oot menu starts up the operating system selected 'rom the !oot menu. 2rom there& the selected operating system takes over the rest o' the start up process. Stage 2 e5ecutes once you,ve made a choice 'rom menu.lst 6or& i' you don,t make a choice& a'ter a timeout period automatically makes one o' the choices 'or you7. *n the menu.lst 'ile 'or the multiple SuS@ options e5ample& the standard entry re'ers to kernel )vmlinuz with a ro!ust set o' options while the 2ailsa'e entry uses a di''erent 6less ro!ust& al!eit sa'er7 set o' options& Control is now handed over to )initrd. t this point& you are now running one o' the versions availa!le " the one you chose in 'rom the !oot menu. ,.,.8 Splash screens *' there are simply multiple options 'or !ooting the same operating system& either in various 'orms or updated versions o' the kernel& they can all !e placed in the same partition. *'& however& there are multiple operating systems availa!le to !oot into& each o' them must !e placed on a di''erent partition.

Hentzenwerke Publishing, Inc. books@hentzenwerke.com www.hentzenwerke.com

Installing Multiple Linux Distributions on a Single Machine

Page %

,.,.9 Summary *n summary& then& the .8: has a partition ta!le that identi'ies which partition on the hard disk is !oota!le. Then& the !oot loader code in the .8: points to !oot loader code in the !oota!le partition. The !oot loader code in the !oota!le partition displays the choices 'ound in menu.lst to the user. Selection o' one o' the choices in the !oot menu e5ecutes the rest o' the !oot loader code that loads the kernel and !egins start up o' the operating system. s a result& the user has the a!ility to have multiple operating systems on the same computer& and to !e a!le to !oot with any o' them. .ore details a!out !oot loaders and 0:/8 in particular can !e 'ound at 0lenn Holmer,s e5cellent writeup at http())www.ameritech.net)users)gholmer)!ooting.html.

2. How to install multiple operating systems


;B& so now you have an idea o' how the !oot process works& !oth with one and with multiple ;Ss. 8ut how do you get there= Suppose you have a C0 08 hard disk. 2irst& install the 'irst ;S& and have it install its own !ootloader in the .8:. %eave at least A 08 o' 'ree space on the hard disk. t this point& your C0 08 hard disk might look like this(
hda* !rimary hda) !rimary hda3 !rimary ,ree s!ace boot s4a! *$$ )-$$$ *$).$$$ 51 #,edora Core% 51 #,edora Core% 51 #,edora Core% 51

#e5t& install the second ;S in the 'ree space. However& during the installation& there will !e a step where you can speci'y whether or not to install that second ;S,s !ootloader in the .8:. $on,t do it. With 2edora Core& the step is through the DChange !oot loaderD command !utton on the 8oot %oader Con'iguration screen& as shown in Figure 3.

Figure 3. Control of the Fe"ora bootloa"er installation is foun" in the #oot Loa"er Configuration screen. Click on the !utton to !ring 'orward the Change !oot loader dialog& as shown in Figure 4.

Hentzenwerke Publishing, Inc. books@hentzenwerke.com www.hentzenwerke.com

Installing Multiple Linux Distributions on a Single Machine

Page

Figure 4. $he Change #oot Loa"er "ialog allows you to a%oi" installing the boot loa"er in the M#&. The description in the dialog isn,t completely straight'orward " there,s no mention o' the .8:. However& the choices are reasona!ly identi'ia!le " the second option !utton& D$o not install a !oot loaderD& pretty o!viously tells you that nothing will !e changed& which is much closer to what you are looking 'or. With SuS@& the step is availa!le through an option in the *nstallation Settings& as shown in Figure 5.

Figure 5. Control of the SuS bootloa"er installation is foun" in the Installation Settings screen. The actual location to make the changes isn,t as easy to 'ind as it was with 2edora Core " indeed& * missed it during my 'irst 'ew SuS@ installs. Click on the 8ooting hyperlink in the screen or select D8ootingD 'rom the menu that displays when you click the DChange...D !utton. @ither action will !ring 'orward the 8oot %oader Setup screen& as shown in Figure 6.

Hentzenwerke Publishing, Inc. books@hentzenwerke.com www.hentzenwerke.com

Installing Multiple Linux Distributions on a Single Machine

Page &

Figure 6. $he #oot Loa"er Setup screen allows you to e"it %arious boot loa"er options. Highlight the ,8oot %oader Type, line as shown in 2igure <& then click the @dit !utton to !ring 'orward the editing options shown in Figure 7.

Figure 7. "iting boot loa"er options in SuS . This step is much !etter e5plained than with 2edora Core " select the D:eplace Code in .8:D line and click the @dit !utton !rings 'orward the :eplace Code dialog as shown in Figure 8.

Hentzenwerke Publishing, Inc. books@hentzenwerke.com www.hentzenwerke.com

Installing Multiple Linux Distributions on a Single Machine

Page '

Figure 8. $he &eplace Co"e in M#& "ialog. /n'ortunately& the dialog !rought 'orward isn,t that clear. Click the Set check !o5 in order to e5ecute the command to replace the code. The result is shown in Figure 9.

Figure . After mo"ifying the &eplace Co"e in M#& option' the result is shown in the #oot Loa"er Setup screen. ;nce you,re done installing the second ;S& you,ll see that it has its own )!oot partition that contains its own !oot loader. *n other words& the second 6and su!se+uent7 operating systems will only have their !oot loader in their own )!oot partitions " they,ll all depend on the 'irst operating system,s !oot loader in the .8: to get things started. 3opular distri!utions o' %inu5 will see that there is already a version o' %inu5 installed& and will use the e5isting swap partition instead o' creating a second one. Eour C0 08 hard disk might look like this now(
hda* hda) hda3 hdahda. hda: !rimary !rimary !rimary e+tended logical logical boot s4a! boot *$$ 51 #,edora Core% )-$$$ 51 #,edora Core% *$)- 51 #,edora Core% *$$ 51 #2u2E% -;$$ 51 #2u2E%

Hentzenwerke Publishing, Inc. books@hentzenwerke.com www.hentzenwerke.com

Installing Multiple Linux Distributions on a Single Machine 10

Page

The last step is to manually modi'y the menu.lst 'or the 'irst operating system you installed to include an entry 'or the new ;S. See %isting 9 'or an e5ample o' what you might add to a standard 2edora Core menu.lst 'ile 'or SuS@. The e5act values will depend on how many partitions you created& in what order& and so on.

3. Summary
When you !oot the machine again& the .8: !oot loader code will display the !oot menu 'or the !oota!le partition on the hard disk " the 'irst ;S you installed. The !oot menu will display options 'or all o' the operating systems you,ve installed. Choosing any o' those options will run the !oot loader in the )!oot partition 'or that operating system& and that,s that.

4. :uestions
4.* $ hit the wrong button. 1ow my second OS%s boot loader is in the 7B-. How do $ get my first OS%s boot loader back into the 7BThe short answer is to use 0:/8 in interactive mode and manually issue commands that will rewrite the .8: the way you want it. #ote that this process is writing to your .aster 8oot :ecord. mistake will likely mean that you won,t !e a!le to !oot your machine. The long answer is as 'ollows( 9. See the D*nstallationD topic o' the 0:/8 in'o 'ile. Type Din'o gru!D in a terminal window. :ead it. Twice. 2. 8ack up your .8:
dd if=/dev/hda of=/some/file/name bs=512 count=1

C. .ake a !oot 'loppy as well. 4. %og in as root& open a terminal window& and type D0:/8D in that window. Eou,ll get a prompt like so(
grub<

A. @nter the commands similar to the 'ollowing " you,ll need to change the values inside the parens according to how your hard disk is set up.
grub< root #hd$"$% grub< setu! #hd$"$% grub< =uit

sample display o' what you,ll see in your terminal window is shown in Figure 10.

Figure 1!. (riting to the M#& through the interacti%e use of )&*#. <. 'ter the +uit command& you,ll !e !ack at a regular prompt in the terminal window. #e5t time you re!oot 6or restart7 your machine& the .8: should !e !ack where you wanted it.

Hentzenwerke Publishing, Inc. books@hentzenwerke.com www.hentzenwerke.com

Installing Multiple Linux Distributions on a Single Machine 11

Page

So& how do you know what values to use inside the parens= *' you have a copy o' the menu.lst 'ile 'or your 'irst ;S& you,ll 'ind the values there. 4., How do $ change the splash screen @ach distri!ution has its own splash screen& as shown in 2igures 9 and 2. There is a line in the menu.lst 'ile that 'ires up the !oot menu that controls the splash screen. *n 2edora Core& the line is
s!lashimage(#hd$"$% grub s!lash.+!m.g&

While in SuS@& the line is


gf+menu #hd$"$% message

Eou can modi'y this line to change the splash screen to something di''erent. 2or instance& * changed the SuS@ menu.lst 'ile to include the 2edora Core splash screen like so(
# 5odified by Ya2T). /ast modification on ,ri Nov )* *.:*.:*- )$$3 color 4hite blue black light'gray default $ timeout 6 ## gf+menu #hd$"$% message s!lashimage(#hd$"$% grub s!lash.+!m.g&

The F signs in 'ront o' the g'5menu line act to comment out the line. 4.2 The line in the boot menu for SuS( ;ust says !"inu#!. When $ add more distributions to my system, it%ll be confusing as to which distribution that refers to. How do $ change the te#t of the lines in the boot menu so they can be more descripti)e Eou can modi'y the DtitleD line to say anything you want to. 2or e5ample& the 'ollow menu.lst 'ile
title ,edora Core #).-.))'*.)**..n!tl% root #hd$"$% kernel vmlinu&').-.))'*.)**..n!tl ro root(/01E/( rhgb initrd initrd').-.))'*.)**..n!tl.img title 2u2E /inu+ kernel #hd$"3% vmlinu& root( dev hda3 vga($+3*- s!lash(silent initrd #hd$"3% initrd

could !e changed like so 6with apologies to DThe BnackD and 2rank Gappa7(
title 5y ,edora root #hd$"$% kernel vmlinu&').-.))'*.)**..n!tl ro root(/01E/( rhgb initrd initrd').-.))'*.)**..n!tl.img title 2u2E Creamcheese /inu+ kernel #hd$"3% vmlinu& root( dev hda3 vga($+3*- s!lash(silent initrd #hd$"3% initrd

4.3 $ need more than four partitions but there can only be four partitions on a hard disk. What do $ do 2our partitions& like <40B& seems like a ridiculously arti'icial limitation& yet at the time it was designed& it seemed like a reasona!le decision. 2ortunately& there is a mechanism that allows you to de'ine additional partitions within one o' the 'our partitions. The 'our partitions are called DprimaryD partitions& !ecause they are re'erenced in the partition ta!le in the .8:. primary partition can !e de'ined as an ,e5tended, partition& which means that it can hold more partitions. These additional partitions are called ,logical, partitions. The installation programs o' popular distri!utions all include a partitioning tool that allows you to create more than 'our partitions. ;nce you add a 'i'th partition& the tool will automatically create an e5tended partition in the 'ourth partition& and then !egin creating logical partitions in the e5tended partition. n e5ample o' the end result could look like this(
hda* !rimary hda) !rimary

Hentzenwerke Publishing, Inc. books@hentzenwerke.com www.hentzenwerke.com

Installing Multiple Linux Distributions on a Single Machine 12


hda3 hdahda. hda: !rimary !rimary #e+tended% logical logical

Page

8. Where to go for more information


This 'ree whitepaper is pu!lished and distri!uted !y Hentzenwerke 3u!lishing& *nc. We have the largest lists o' H.oving to %inu5I& ;pen;''ice.org& and Jisual 2o53ro !ooks on the planet. We also have oodles o' 'ree whitepapers on our we!site and more are !eing added regularly. ;ur 3re'erred Customer mailing list gets !i"monthly announcements o' new whitepapers 6and gets discounts on our !ooks& 'irst crack at special deals& and other stu'' as we think o' it.7 Click on HEour ccountI at www.hentzenwerke.com to get on our 3re'erred Customer list. If you found this whitepaper helpful !he!" out these #ent$enwer"e %u&lishing &oo"s as well' Linu( )ransfer for *indows+ ,etwor" -d.ins' - road.ap for &uilding a Linu( file and print ser/er 0i!hael 1ang Linu( )ransfer for *indows+ %ower 2sers' 3etting started with Linu( for the des"top *hil #ent$en

Hentzenwerke Publishing, Inc. books@hentzenwerke.com www.hentzenwerke.com

You might also like