Sie sind auf Seite 1von 10

HentzenwerkeWhitepaperSeries

ReconfiguringtheMBR forMultipleBoot Installations


ByWhilHentzen

I've written a couple of articles on multiple boot configurations. Upon adding a third operating system to a dualboot machine, I managed to overwritethemachine'sMBR(masterbootrecord)sothatitpointedtothe wrongbootloader.Thispaperaddressesthesolution.

HentzenwerkePublishing,Inc.booksales@hentzenwerke.com www.hentzenwerke.com

ReconfiguringtheMBRforMultipleBootInstallations

Page2

1.Preface
1.1Copyright
Copyright2007WhilHentzen.Somerightsreserved.ThisworkislicensedundertheCreativeCommonsAttribution NonCommercialNoDerivsLicense,whichbasicallymeansthatyoucancopy,distribute,anddisplayonlyunalteredcopies ofthiswork,butinreturn,youmustgivetheoriginalauthorcredit,youmaynotdistributetheworkforcommercialgain, norcreatederivativeworksbasedonitwithoutfirstlicensingthoserightsfromtheauthor.Toviewacopyofthislicense, visithttp://creativecommons.org/licenses/byncnd/3.0/.

1.2Revisions
1.2.1History
Version
1.0.0

Date
2007/12/03

Synopsis
Original

Author
WH

1.2.2Newversion Thenewestversionofthisdocumentwillbefoundatwww.hentzenwerke.com. 1.2.3Feedbackandcorrections Ifyouhavequestions,comments,orcorrectionsaboutthisdocument,pleasefeelfreetoemailmeat 'booksales@hentzenwerke.com'.Ialsowelcomesuggestionsforpassagesyoufindunclear.

1.3Acknowledgments

ThankstoMLUGmembersRonBean,GlennHolmer,GaryKramlich,amongothers,forpointersandsuggestions,andto TedRoche,forpatientlyreviewingversion1.0andnitpickingeverymisplacedgit.

1.4Disclaimer

Nowarranty!Thismaterialisprovidedasis,withnowarrantyoffitnessforanyparticularpurpose.Usetheconcepts, examplesandothercontentatyourownrisk.Theremaybeerrorsandinaccuraciesthatinsomeconfigurationsmaybe damagingtoyoursystem.Theauthor(s)disavowsallliabilityforthecontentsofthisdocument. Beforemakinganychangestoyoursystem,ensurethatyouhavebackupsandotherresourcestorestorethesystemto itsstatebeforemakingthosechanges. Allcopyrightsareheldbytheirrespectiveowners,unlessspecificallynotedotherwise.Useofaterminthisdocument shouldnotberegardedasaffectingthevalidityofanytrademarkorservicemark.Namingofparticularproductsorbrands shouldnotbeseenasendorsements.

1.5Prerequisites

ThisdocumentwaswrittenusingWindowsXP,FedoraCore6.0,andFedora8,buttheconceptsdiscussedhereare distributionnonspecific.

HentzenwerkePublishing,Inc.booksales@hentzenwerke.com www.hentzenwerke.com

ReconfiguringtheMBRforMultipleBootInstallations

Page3

2.Theoriginalconfiguration
IcreatedadualbootmachinewithXPandFedoraCore6awhileback.Seethearticles,DualBootwithFedoraCore6and WindowsXP,and,toalesserextent,InstallingMultipleLinuxDistributionsonaSingleBox,fordetails.Theendresultwas amachinewiththefollowingparticulars: InitialinstallationofWindowsXPusingafactoryrescueCD.Themachinehadthreepartitions.Partition1wastheXP operatingsystem.Partition2wasabitofspareroominahiddenpartition.Andthethirdpartitionwasahiddenpartitiontat theendofthediskwheretherescueCDtoolswereinstalled.Alargeamountofspacewasleftunpartitionedtoallowfor laterinstalls..Notethatitwas"partition3"onlyforashorttime;asotherpartitionswerecreatedoutoftheunpartitioned space,sothishiddenrescuepartitionwasnudgedtotheendofthelistandrenumbered. TheMBRwasinitializedtopointtoWindowsXPinstalledinpartition1andthatwasthat. Next,installationofFedoraCore6createdfivenewpartitions.SinceaPCBIOSpartitionschemecanonlyhandlea maximumoffourpartitionsonadisk,anextendedpartitionwascreatedtoholdthem.Theotherfourpartitionswere/boot, /,/home,andaLinuxswap. Importantherearethreenewpieces.Firstisthatthe/bootpartitioncontainedthebootloaderforLinux.(The bootloadercontainsthe/boot/grub/grub.confconfigurationfile.SecondisthattheLinuxinstallationprocesspointedthe MBRtotheLinuxbootloaderinpartition3.ThirdisthattheLinuxinstallationprocessaddedapointertotheWindows bootloader(identifiedas'other')sothatwhenthemachineboots,theuserwillseeachoiceofbothLinuxandWindows. Ithenmodifiedthe/boot/grub/grub.conffilesothatthedescriptionofthe"other"operatingsaidsomethingmore expressive,like"WindowsXP". ThebootmenulookedlikeFigure1.

HentzenwerkePublishing,Inc.booksales@hentzenwerke.com www.hentzenwerke.com

ReconfiguringtheMBRforMultipleBootInstallations

Page4

Figure1.TheoriginalbootmenuforFedoraCore6andWindowsXP. Ileftabout20GBforfutureuse.

3.Installingathirdoperatingsystem
That20GBwasjustburningaholeinmypocket,andwhenFedora8wasreleased,Ifigureditwashightimetostuffthat openspacewithit. PoppedabrandnewFedora8diskintothedrive,rebooted,andrantheinstallprocess.Atonepoint,theinstallation processgivesyouchoicesonhowtohandlethebootloaderforFedora8. Choice1:IftheexistingbootloaderwasinstalledbyaLinuxdistribution,theinstallationsystemcanmodifyittoload thenewFedorasystem.ToupdatetheexistingLinuxbootloader,selectUpdatebootloaderconfiguration.Thisisthe defaultbehaviorwhenyouupgradeanexistingFedoraorRedHatLinuxinstallation. Choice2:Ifyourmachineusesanotherbootloader,suchasBootMagic,SystemCommander,ortheloader installedbyMicrosoftWindows,thentheFedorainstallationsystemcannotupdateit.Inthiscase,selectSkipbootloader updating.Youwillneedtomanuallyupdateyourbootloader. Choice3:Installanewbootloaderaspartofanupgradeprocessonlyifyouarecertainyouwanttoreplacetheexisting bootloader.Ifyouinstallanewbootloader,youmaynotbeabletoboototheroperatingsystemsonthesamemachineuntil youhaveconfiguredthenewbootloader.SelectCreatenewbootloaderconfigurationtoremovetheexistingbootloader andinstallGRUB.

HentzenwerkePublishing,Inc.booksales@hentzenwerke.com www.hentzenwerke.com

ReconfiguringtheMBRforMultipleBootInstallations

Page5

EvidentlyImadethewrongchoice(probablythethirdone.)Theendresultwasabootloaderbeinginstalledinthe Fedora8/bootpartition,andtheMBRbeingrepointedtothisnewpartition.Iendeduptwomorepartitions:Partition8held the/bootpartitionforFedora8andpartition9heldtheFedora8/partition. ThefinalmachinepartitionlayoutisshowninFigure2.

Figure2.ThefinalpartitionlayoutwithXP,FedoraCore6andFedora8. Therewasonemorepartitioncreatedpartition10,likepartition2,consistedofabitofspareroomthatfilledupthe restofthecylindertopartition11.

4.Theproblemstherein
TheproblemthatshowedupaftertheinstallationofFedora8wasthattheMBRnowpointedtotheFedora8bootloader. Thisbootloader'sgrub.confheldentriesforFedora8andXPbutnotfortheFedoraCore6installationwhichwasa problem. Ihadtwopossiblesolutions.ThefirstwastoedittheFedora8grub.conffileandaddapointertotheFedora6kernel. AfterFedora8'sinstallation,grub.conflookedlikethis(nonessentiallineseditedout):
#grub.confgeneratedbyanaconda default=0 splashimage=(hd0,7)/grub/splash.xpm.gz titleFedora8(2.6.23.149.fc8) root(hd0,7) kernel/vmlinuz2.6.23.149.fc8roroot=LABEL=/1 initrd/initrd2.6.23.149.fc8.img titleWindowsXP rootnoverify(hd0,0) chainloader+1

Asyoucanseefromthe(hd0,7)identifier,thebootloaderislocatedinpartition8(partitionsarereferencedwithazero basedindex).

HentzenwerkePublishing,Inc.booksales@hentzenwerke.com www.hentzenwerke.com

ReconfiguringtheMBRforMultipleBootInstallations
Editingthegrub.confwouldresultinthis:
#grub.confgeneratedbyanaconda default=0 splashimage=(hd0,7)/grub/splash.xpm.gz titleFedora(2.6.23.863.fc8) root(hd0,7) kernel/vmlinuz2.6.23.863.fc8roroot=LABEL=/1 initrd/initrd2.6.23.863.fc8.img titleFedora(2.6.23.149.fc8) root(hd0,7) kernel/vmlinuz2.6.23.149.fc8roroot=LABEL=/1 initrd/initrd2.6.23.149.fc8.img titleFC6(2.6.201.2948.fc6) root(hd0,2) kernel/vmlinuz2.6.201.2948.fc6roroot=LABEL=/ initrd/initrd2.6.201.2948.fc6.img titleWindowsXP rootnoverify(hd0,0) chainloader+1

Page6

The(hd0,2)identifierfortheFedoraCore6installationcomesfromthe/bootpartitionwhich,aswesawearlier,wason hda3. Whilethistechnicallyworks,asshowninFigure3,itwasn'tsatisfactoryforme.

Figure3.TheresultingbootmenuaftereditingtheFedora8bootloader.

HentzenwerkePublishing,Inc.booksales@hentzenwerke.com www.hentzenwerke.com

ReconfiguringtheMBRforMultipleBootInstallations

Page7

ThereasonisthattheFedora8installwasatestbed,andIdidn'twanttohavethe/bootpartitionbeatriskwhenI startedmonkeyingwiththeinstall.IhadplanstouninstallandreinstallFedora8inavarietyofconfigurations,andIdidn't wanttohavethe/bootpartitionpossiblydamagedorerased. Mygoal,thenwastohavetheMBRpointtotheoriginalbootloaderinpartition3(forFedoraCore6)andthenadda referencetotheFedora8installinthegrub.conffileinpartition3.

5.ThesolutionreconfiguringtheMBR
TherearetwostepstoreconfiguringtheMBR.Thefirstistobackitup,justincaseanerrantkeystrokeorstrayelectrongot involvedwhereitoughtn't.

5.1BackuptheMBR
Openaterminalwindowasrootandissuethecommand
ddif=/dev/sdaof=/location/of/mbrbackupbs=512count=1

where'if'istheinputfileand'of'istheoutputfile.Theinputfileisthelocationofthemasterbootrecord.'/dev/sda'or '/dev/hda'aretypicalchoices;thefirstmorelikelyinmodernsystems.Theoutputfileiswhereyouwantthecopyofthe MBR.Putitsomeplaceyou'llbeabletogettoifyourmachinebecomesunbootablenatively.aUSBmemorystick,or/root or/home/yournamearepossibleplacesyoucanlaterbootthemachinewithaLiveCDandaccessthatfile.

5.2RewritetheMBR
Nowthatyou'vegotitbackedup,timetorewritetheMBRsothatitpointstotheFedoraCore6bootloaderthatislocated onpartition3.OpenaterminalwindowasrootandloaduptheGRUBeditor.Thenissuethefollowingcommands:
root>grub grub>root(hd0,2) grub>setup(hd0) grub>quit

Thebootloaderconsistsoftwopiecesstage1,whichiswhereGRUBstarts,andstage2,whichcontainsthepointers tothevariousoperatingsystemkernelsthatwillbeavailableinthemenu. ThefirstcommandloadstheGRUBeditor.Thesecondcommandsays"Lookhereforthestage2filethatwillloadthe bootmenu."hd0,2referstothebootrecordofthethirdpartition. Thethirdcommandsays"Putstage1herethisiswhereGRUBwillstart."hd0referstotheMBR.Andthefourth commandclosestheGRUBeditor.

6.AddthenewFedora8kerneltotheoriginalgrub.conffile
Finally,editgrub.confinpartition3toreflecttheFedora8entry.It'lllooksomethinglikethis:
#grub.confgeneratedbyanaconda # #Notethatyoudonothavetorerungrubaftermakingchangestothisfile #NOTICE:Youhavea/bootpartition.Thismeansthat #allkernelandinitrdpathsarerelativeto/boot/,eg. #root(hd0,2) #kernel/vmlinuzversionroroot=/dev/hda6 #initrd/initrdversion.img #boot=/dev/hda default=0 timeout=10

HentzenwerkePublishing,Inc.booksales@hentzenwerke.com www.hentzenwerke.com

ReconfiguringtheMBRforMultipleBootInstallations
splashimage=(hd0,2)/grub/splash.xpm.gz titleFedoraCore(2.6.201.2948.fc6) root(hd0,2) kernel/vmlinuz2.6.201.2948.fc6roroot=LABEL=/ initrd/initrd2.6.201.2948.fc6.img titleFedoraCore(2.6.191.2911.6.4.fc6) root(hd0,2) kernel/vmlinuz2.6.191.2911.6.4.fc6roroot=LABEL=/ initrd/initrd2.6.191.2911.6.4.fc6.img titleFedoraEIGHT(2.6.23.863.fc8) root(hd0,7) kernel/vmlinuz2.6.23.149.fc8roroot=LABEL=/1 initrd/initrd2.6.23.149.fc8.img titleFedoraEIGHT(2.6.23.149.fc8) root(hd0,7) kernel/vmlinuz2.6.23.149.fc8roroot=LABEL=/1 initrd/initrd2.6.23.149.fc8.img titleWindowseXtremelyPloated rootnoverify(hd0,0) chainloader+1

Page8

Thenexttimeyoureboot,you'llseethemenuasshowninFigure4.

Figure4.ThefinalbootmenufromtheFedora6bootloader. NotethatupdatestotheFedora6kernelwillbereflectedautomaticallyinthismenu,butupdatestotheFedora8kernel willneedtobeaddedtothismenumanually.

HentzenwerkePublishing,Inc.booksales@hentzenwerke.com www.hentzenwerke.com

ReconfiguringtheMBRforMultipleBootInstallations

Page9

7.Optionsforthefuture
Oneoptionoccasionallymentionedwhenthetopicofmultipleinstallationsonasinglemachinearisesisthatofhavinga dedicatedbootpartitionthat'sindependentofanysingleoperatingsysteminstall.First,you'dneedadedicatedpartition. Second,theGRUBstagefilesneedtobecopiedtothatpartition,and,finally,pointtheMBRtothisnewGRUBpartition. (Ofcourse,you'dalsohavetomodifythemenufileintheGRUBpartitiontoreflecttheavailableoperatingsystems.) ThedetailsondoingsowillbeforthcominginanotherpaperwhenIfeellikeexperimentingsomemore.

8.Wheretogoformoreinformation
GlennHolmerhasagreatarticleonhowthebootprocessworks,allthewayfromhardcodedbitsonIntelchipstoworking withavarietyofexotica.
http://lyonlabs.org/booting.html

TheendofGlenn'sarticlecontainsevenmoreusefullinks.

9.Abouttheauthor
WhilHentzenstartedoutlifeintheearly'80'sasacustomsoftwaredeveloperusingdBASEII(hestillhastheoriginal81/2 x11greybinderofdocumentation,muchtothechagrinofhiswife),andswitchedtoFoxProin1990.Besidesbilling15,000 hoursinthe90's,hepresentedmorethan70papersatconferencesthroughoutNorthAmericaandEurope,editedFoxTalk, PinnaclePublishing'shighendtechnicaljournalfor7years,hostedtheGreatLakesGreatDatabaseWorkshopsince1994. He'swritten8booksandpublished30moreonavarietyofsoftwaredevelopmenttopics.HewasaMicrosoftMostValuable Professionalfrom1995through2003forhiscontributionstotheFoxProdevelopmentcommunity,andreceivedthefirst MicrosoftLifetimeAchievementAwardforVisualFoxProin2001. WhilbeganusingLinuxonthedesktopwhenOpenOffice.orgbecameastandardinthemainstreamdistributions,asit spelledpotentialforcustomapplicationdevelopmentinthefuture,andhasbeenaLinuxuser,developer,andevangelist eversince.HisfirstbookonLinux,LinuxTransferforWindowsPowerUsers,waspublishedinearly2004. HeisavailablefornewandlegacyVisualFoxProapplicationdevelopmentaswellasWebanddesktopdevelopmenton Linux.

10.Awordfromoursponsor
ThisfreewhitepaperispublishedanddistributedbyHentzenwerkePublishing,Inc.WehavethelargestlistsofMovingto Linux,OpenOffice.org,andVisualFoxProbooksontheplanet. Wealsohaveoodlesoffreewhitepapersonourwebsiteandmorearebeingaddedregularly.OurPreferredCustomer mailinglistgetsbimonthlyannouncementsofnewwhitepapers(andgetsdiscountsonourbooks,firstcrackatspecial deals,andotherstuffaswethinkofit.) ClickonYourAccountatwww.hentzenwerke.comtogetonourPreferredCustomerlist.

Ifyoufoundthiswhitepaperhelpful,checkouttheseHentzenwerkePublishingbooksaswell: LinuxTransferforWindowsNetworkAdmins: AroadmapforbuildingaLinuxfileandprintserver MichaelJang LinuxTransferforWindowsPowerUsers:

HentzenwerkePublishing,Inc.booksales@hentzenwerke.com www.hentzenwerke.com

ReconfiguringtheMBRforMultipleBootInstallations 10
GettingstartedwithLinuxforthedesktop WhilHentzen

Page

HentzenwerkePublishing,Inc.booksales@hentzenwerke.com www.hentzenwerke.com

Das könnte Ihnen auch gefallen