磁盘启动VMLite VBoot.docx
《磁盘启动VMLite VBoot.docx》由会员分享,可在线阅读,更多相关《磁盘启动VMLite VBoot.docx(13页珍藏版)》请在冰点文库上搜索。
磁盘启动VMLiteVBoot
VMLiteVBoot-LinuxVHDBoot
点击转到译文
Copyright©2010,VMLiteInc.
1Overview
1.1LinuxasRealAppliance
WithVBootforLinux,youcanpre-installandpre-configureLinuxOSanditsapplications,thendistributetheresultingvirtualdiskfileinVHDformat.Thevhdcanbootarealcomputer,withconfigurationandappsinstantlyavailable.Thisway,operatingsystemsaretrulymanageable,assimpleasfiles.WecallsuchaLinuxVHDtobearealappliance,inthesensethatitbootsphysicalcomputers.
It'sveryeasytosetupandbootacomputerwithavhdfile.Youdownloadthevhdfile,dropittoWindowsorLinuxfilesystem,thenconfigurethebootloader,andrebootthecomputer.
1.2LinuxasVirtualAppliance
Theexactsamevhdfilealsorunsasavirtualmachineusingvirtualizationsoftware,suchasVMLiteWorkstation,VirtualBox,XenandVirtualPCandHyper-V,etc.Bydefault,it'soptimizedforVMLiteWorkstation.
IfVMLiteWorkstationisinstalled,youcansimplydoubleclicktheubuntu-1004-desktop-i386.mopfiletolaunchthevhdasavirtualmachinewithVMLiteWorkstation.
1.3USBBootMadeEas
Youjustneedtostorethevhdfiletousbdrive,thenhooktheUSBtodifferentcomputerstoboot.IfyourcomputerBIOSdoesnotsupportUSBboot,youneedtoconfigureGRUB2tosupportUSB.
1.4ThesampleUbuntuVHD
Thesample ubuntu-1004-desktop-i386.vhdisapre-installed32-bitUbuntu9.10desktopversioninEnglish.
∙selfgrowingdiskwithdiskcapacityof100G,withinitialsizeabout3G
∙rootusername/password:
user/welcome
2SystemRequirements
∙Windows2000andLater,32-and64-bit,NTFSfilesystemGRUB2orothercompatiblebootloaders,32-and64-bit
∙Mac-tobesupportedsoon
∙4Gdiskspace
3DownloadandExtract
ThesampleUbuntu9.10packageisafewhundredMB,soitwilltakequitesometimetodownload,andit'srecommendedtouseadownloadmanager,suchasFlashGet.
Oncedownloadiscomplete,firstyouneedtoextractthefile,whichisin.7zformat.Moreinfocanbefoundathttp:
//www.7-zip.org/download.html.OnWindows,youcanuseWinRaror7Ziptoextractthefile.OnLinux,youcanusethefollowingcommandstoinstall7zip,andunzipthefile:
sudoapt-getinstallp7zip
p7zip-dubuntu-1004.7z
Inordertobootacomputerusingthevhdfile,makesurethatit'snotextractedtoanetworkdrive,ortoanothervirtualdisk.Thevhdfilemustresideinabasicvolumeoninternalorexternalharddisks(e.g.,USBdrives),otherwise,itwon'tboot.
4InstallonWindows
IfyourcurrenthostisWindows,youneedtoinstallVBootloader,andaddabootentrytoWindowsbootmanager.Inaddition,youneedtotellVBootwheretofindthevhdfile.
4.1AutomaticSetupbyrunningsetup.exe
It'shighlyrecommendthatyouusethismethodtosetupVBootonWindows,sinceit'sextremelysimpleandautomateseverything.Yousimplydoubleclicksetup.exeon32-bitWindows,orsetup64.exeon64-bitWindows.ThesetuputilitywillinstallVBootLoader,andconfiguretheWindowsbootloadertocontainanentrytoboottheLinuxVHD.
Aftersetup.exeissuccessfullyrun,yourebootthecomputer,andyoushouldseea"VBoot-UbuntuVHDBoot"entryasthelastone,selectthisentrytoboottoLinux.
4.2ManualSetup
Ifsomehowtheautomaticsetupdoesn'twork,thenyoucanperformthefollowingmanualsteps:
4.2.1CopyVBootLoaderFiles
TheVBootloaderisbasedonGNUGRUB2,anditsfilesarelocatedinvbootsubdirectory.
∙vbootldr.mbrandvbootldrarethetwocriticalbootloaderfilesthatmustbecopiedtotherootdirectoryofadrive,typicalC:
\.
∙Thefontsdirectorycontainsfontfilestobeusedbyourbootloader.
∙Thegrubdirectorycontainsgrub2modules,andtheveryimportgrub.cfgconfigurationfile.
Forexample,ifyouwanttocopythefilestoC:
\,youneedtocopythevbootdirectorytoc:
\,soyouwillhavec:
\vbootdirectory.Thenyoumustcopyvbootldr.mbrandvbootldrtoc:
\.
Thefollowingcommandscanbeusedtocopythefiles.Makesuretorunfromtheextracteddir.
mdc:
\vboot
xcopy/svbootc:
\vboot
copyvboot\vbootldrc:
\
copyvboot\vbootldr.mbrc:
\
4.2.2Configuregrub.cfg
Asamplegrub.cfgfileisplacedinc:
\vboot\grubdirectory(ord:
\vboot\grubdependingonwhereyouhavecopiedthefiles).ThisistheGRUB2configuratrionfiletoloadoperatingsystems.Insidethisfile,thevhdfilepathishardcoded,andthusyouhavetomodifyit.
grub.cfgisatextfilethatyoucanusenotepadtoopenandmodify.Therelevantportionisshownbelow:
menuentry"VHDUbuntu,Linux2.6.32-21-generic"{
insmodvhd
vhdvhd0(hd0,1)/ubuntu-1004/ubuntu-1004-desktop-i386.vhd--partitions
linux(vhd0,1)/boot/vmlinuz-2.6.32-21-genericroot=/dev/sda1vloop=/ubuntu-1004/ubuntu-1004-desktop-i386.vhdquietsplash
initrd(vhd0,1)/boot/initrd.img-2.6.32-21-generic
}
menuentrygroupsaspecificoperatingsystem.Thefirstlineinsmodvhdinsertsourvhd.modmoduletothebootloader.vhd.modisaGRUB2modulethattreatsavhdfileasharddisk,andallowsGRUB2toreadfilesfromthevhd.Forexample,theLinuxkernelandinitrdareloadedfromthevhdfile,asconfiguredabove.
Therearethreepaths(asshowninred)relatedtothevhdfilethatyouneedtochangedependingonthedirectorytowhichthevhdfileisextracted.
Thevhdpath(hd0,1)/ubuntu-1004/ubuntu-1004-desktop-i386.vhdisinGRUB2formatwhere(hd0,1)indicatesharddisk0andpartition1,withtherestistheabsolutepathinUNIXformat.Forexample,ifyourvhdfileisinsideafoldercalled123onanexternalUSBdisk,thenyouneedtochangethispathtosomethinglike(hd1,1)/123/ubuntu-1004-desktop-i386.vhd.Thepathimmediatelyaftervloop=shouldbethesameabsolutepathwithoutthedisknumberandpartitionnumber.
TherootpathistheLinuxdevicenameforthediskwherethevhdfileresides.Thenumberisthepartitionnumber,andtheletter'a','b','c',etc,representswhichdisk.For(hd0,1),thenamewouldbe/dev/sda1;For(hd1,1), itwouldbe/dev/sdb1;For(hd2,4),itwouldbe/dev/sdc4,etc.
44.2.3ConfigureWindowsBootLoader
OnceVBootLoaderandthevhdfileareready,youneedtoconfigureWindowsbootmanager,soyoucanboottotheLinuxVHD.Youneedtoappendthevbootldr.mbrentrytothe[operatingsystems]section.Thefollowingissampleboot.inifilewithVBootentryaddedattheverylast.Showninrediswhatyouneedtoaddtoboot.ini.ChangeC:
towhateverdriveyouhavecopiedVBootLoaderfiles.
[bootloader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition
(1)\WINDOWS
[operatingsystems]
multi(0)disk(0)rdisk(0)partition
(1)\WINDOWS="MicrosoftWindowsXPProfessional"/noexecute=optin/fastdetect
C:
\vbootldr.mbr="VBoot-UbuntuVHDBoot"
4.2.3.2WindowsVista/2008/7
WindowsVistaandaboveuseadifferentmechanismotherthanboot.inittoboot,andyouneedtorunbcdedit.exetomakechangestothebootmanager.ThefollowingarethecommandstorunifyouhavecopiedVBootLoadertodriveC:
. YoumustrumthesecommandsasAdministrator.GotoWindowsStartmenu>AllPrograms>Accessories,thenrightclickon"CommandPrompt",thenselect"RunAsAdministrator".Oncecommandpromptwindowisopen,youcanenterthesecommands.
bcdedit/create{D3DCE997-7447-41FC-9740-A8D20EE3BF55}/d"UbuntuVHDBoot"/applicationBOOTSECTOR
bcdedit/set{D3DCE997-7447-41FC-9740-A8D20EE3BF55}devicepartition=C:
bcdedit/set{D3DCE997-7447-41FC-9740-A8D20EE3BF55}path\vbootldr.mbr
bcdedit/displayorder{D3DCE997-7447-41FC-9740-A8D20EE3BF55}/addlast
bcdedit/timeout30
5InstallonLinux
OnLinuxsystems,thereisnoneedtoinstallVBootLoader.Instead,youonlyneedtoaddanentrytoyourcurrentbootloadersotheLinuxVHDcanbebooted.
5.1ConfigureGRUB2
YoucanedittheGRUB2configfile,/boot/grub/grub.cfg,usinganytexteditor,andinsertanentrylikethefollowing:
menuentry"VHDUbuntu,Linux2.6.32-21-generic"{
linux(hd0,1)/ubuntu-1004/vmlinuz-2.6.32-21-genericroot=/dev/sda1vloop=/ubuntu-1004/ubuntu-1004-desktop-i386.vhdvlooppart=p1quietsplash
initrd(hd0,1)/ubuntu-1004/initrd.img-2.6.32-21-generic
}
TherearesomesubtledifferencesbetweenLinuxandWindowshost.OnWindowswhereourGRUB2module,vhd.mod,isavailable,youcanconfigureGRUB2toloadtheLinuxkerenlandinitrdfromtheexactlysamevhdfile,whereasonLinuxsystems,thekernelandinitrdareseparatefilesresidingexternally.Inotherwords,onWindows,it'sstrictlyonlyonevhdfileisrequired;whereasonLinux,3files(kernel,initrd,vhd)arerequired.Wewilltrytomakethevhd.modmoduletosupportLinuxfilesystemsoon.
Obviously,youneedtochangethepathsdependingonthedirectorytowhichthekernel,initrdandvhdfilesareextracted.
Thepath(hd0,1)indicatesharddisk0andpartition1,withtherestistheabsolutepathinUNIXformat.Forexample,ifyourvhdfileisinsideafoldercalled123onanexternalUSBdisk,thenyouneedtochangethispathtosomethinglike(hd1,1)/123/ubuntu-1004-desktop-i386.vhd.Thepathimmediatelyaftervloop=shouldbethesameabsolutepathwithoutthedisknumberandpartitionnumber.
TherootpathistheLinuxdevicenameforthediskwherethevhdfileresides.Thenumberisthepartitionnumber,andtheletter'a','b','c',etc,representswhichdisk.For(hd0,1),thenamewouldbe/dev/sda1;For(hd1,1), itwouldbe/dev/sdb1;For(hd2,4),itwouldbe/dev/sdc4,etc.
5.3ConfigureLegacyGRUB
ForGRUB0.97andsimilar,youcanaddanentrytoyourGRUBconfigfile,/boot/grub/menu.lst,usinganytexteditor,andinsertanentrylikethefollowing:
titleVBoot-UbuntuVHDBoot
kernel/boot/ubuntu-1004/vmlinuz-2.6.32-21-genericroot=/dev/sda1vloop=/boot/ubuntu-1004/ubuntu-1004-desktop