Windows不分區VHD裝Linux多系統(五):Win7(物理機)添加引導


上一篇:Windows不分區VHD裝Linux多系統(四):VM虛擬機里Ubuntu18引導修改

 下一篇:Windows不分區VHD裝Linux多系統(六):優化 & 安裝NVIDIA 920MX獨顯驅動

######################################################################################## 

這里要先感謝

無憂論壇  和 論壇里niumao

我將niumao的教程做進一步實踐整理,避免新人踩坑。

#########################################################################################

准備文件:上篇教程里從ubuntu虛擬機里傳出來的文件

    文件一,在ubuntu虛擬機的Home(家)目錄下的“initrd.img-5.4.0-42-generic”

    文件二,在ubuntu虛擬機的/boot目錄下的“vmlinuz-5.4.0-42-generic”

    文件三,安裝好系統的vhd文件,“ubuntu.vhd”

 

導方式介紹

grub4dos、g2ldr、grub2-efi(EFI-GPT)、grub2ia32(僅能在32位UEFI下引導系統,所以不常用,這里不介紹了)

    方式一:GRub4dos啟動,只需要三個文件 grldr、grldr.mbr、menu.lst與一個目錄grub

    方式二:g2ldr啟動,只需要兩個文件 g2ldr、g2ldr.mbr與一個目錄grub2

    方式三:grub2-efi啟動,只需要 EFI、grub2 兩個目錄

 

選引導方式

對於BIOS-MBR結構,可以選擇 grub4dos(推薦) 或 g2ldr

對於EFI-GPT結構,選擇grub2-efi方式

 

安裝引導

選擇上面對應方式的文件,這里選擇grub4dos方式,

  將grldr、 grldr.mbr、menu.lst、目錄grub 文件放在系統盤根目錄下(我的win7系統在C盤,所以放C盤下面)。

下面是menu.lst文本的內容

  注意:不要用WIN自帶的“記事本”編輯文件(會給文件自動加BOM頭),用notepad、notepad++、Emedit等軟件編輯。

timeout 5
default 0
font   /grub/ufont.gz
color normal=0x0F highlight=0x0E helptext=0x0A heading=0x02 standard=0x02 border=0x77
graphicsmode -1 800 600 24:32
splashimage /grub/bg.lzma
MINI_MENUSETTING 1 5 2 22 15 7 64 13
hotkey -nb
write 0x8274 0x2001

iftitle [ find --set-root --ignore-floppies --ignore-cd  /ubuntu/ubuntu.vhd ]啟動ubuntu.vhd
find --set-root --ignore-floppies --ignore-cd  /ubuntu/ubuntu.vhd
uuid ()
kernel /ubuntu/vmlinuz  root=UUID=%?%  kloop=/ubuntu/ubuntu.vhd  kroot=/dev/mapper/loop0p1
initrd  /ubuntu/initrd.img  

iftitle [ find --set-root --ignore-floppies --ignore-cd  /casper/vmlinuz ] 啟動UBT-small.squashfs
find --set-root --ignore-floppies --ignore-cd  /casper/vmlinuz
kernel /casper/vmlinuz boot=casper
initrd  /casper/initrd.img 

iftitle [ find --set-root --ignore-floppies --ignore-cd  /ubuntu/UBT-small.iso ] 啟動 UBT-small.iso
find --set-root --ignore-floppies --ignore-cd  /ubuntu/UBT-small.iso
kernel  /ubuntu/vmlinuz boot=casper iso-scan/filename=/ubuntu/UBT-small.iso locale=zh_CN.UTF-8  quiet splash
initrd   /ubuntu/initrd.img
	 
iftitle [ find --set-root --ignore-floppies --ignore-cd  /vmlinuz ] 啟動硬盤UBUNTU
find --set-root --ignore-floppies --ignore-cd /vmlinuz
uuid ()
kernel /vmlinuz root=UUID=%?% 
initrd /initrd.img

iftitle [ find --set-root /bootmgr ] 啟動硬盤Win7或win8
find --set-root /bootmgr
chainloader /bootmgr

iftitle [ find --set-root /ntldr ] 啟動硬盤WINXP
find --set-root /ntldr
chainloader /ntldr

title  啟動G2LDR
find --set-root /g2ldr
kernel /g2ldr

title 自動ISO菜單
command (bd)/grub/automenu

title 重啟
reboot

title 關機
halt

 

修改BCD文件

系統從硬件啟動,先引導扇區-->BCD文件看要啟動的列表。

在BCD里添加剛才放到C盤根目錄下的grldr文件,grldr會列出menu.lst的啟動列表。 

注意要先備份BCD文件,一下內容保存成"bcd-backUP.bat"批處理文件(bcd-backUP名字隨便,后綴.bat不能變)

@ECHO off
Color 3e

::時間不是兩位補0
if "%date:~5,2%" lss "10" (set mm=0%date:~6,1%) else (set mm=%date:~5,2%)
if "%date:~8,2%" lss "10" (set dd=0%date:~9,1%) else (set dd=%date:~8,2%)
if "%time:~0,2%" lss "10" (set hh=0%time:~1,1%) else (set hh=%time:~0,2%)
if "%time:~3,2%" lss "10" (set nn=0%time:~4,1%) else (set nn=%time:~3,2%)

::備份BCD文件,並按備份時間改名,年月日_時分秒
bcdedit /export BCD_backUP_%date:~0,4%%mm%%dd%_%hh%%nn%%time:~6,2%

添加引導 ,啟動磁盤選擇你系統所在的盤,啟動分區選C盤,菜單標題隨意寫(不要有特殊字符)

這里用BOOTICE v1.3.4 x64(64位)文件編輯

如果是win7系統,使用bootice軟件。
編輯BCD---本地BCD--增加啟動項---實模式--在boot/locate之處點擊一下,選擇一下啟動硬盤和啟動分區(這里填選grldr所在分區)--啟動文件處填寫grldr.mbr---啟動項的名字可以自己起,例如GRUB4DOS.
改變一下顯示時間設置(timeout)為10秒或者20秒(時間設置至少5秒以上,否則都沒有顯示出來就跳過了)。
記得要保存設置。有兩個保存按鈕都要點擊到。
重啟后在BCD菜單選擇GRUB4DOS。

 

建立存放VHD文件的目錄

在磁盤任意分區根目錄下建立一個ubuntu文件夾(最好不要在C盤)

將“initrd.img-5.4.0-42-generic改名initrd.img”、“vmlinuz-5.4.0-42-generic改名vmlinuz”、“ubuntu.vhd”這三個文件放到ubuntu文件夾下。

這些名字和上面的menu.lst文件的第一個 iftitle 段對應。先這樣設置,能用后,在修改自己喜歡的路徑。

為什么把引導文件放到其他目錄?是為了限制訪問范圍,保護系統目錄。物理機引導不小心弄壞了,系統就起不來了。你懂的。

 

如果是winXP系統,編輯boot.ini, 加入一行 C:\grldr.mbr=GRUB4DOS.
重啟系統。選擇GRUB4DOS。

注意 GRub4dos啟動只需要三個文件 grldr grldr.mbr menu.lst與一個目錄grub.

########################

g2ldr方式的引導設置:
把兩個文件g2ldr g2ldr.mbr grub2目錄 復制到系統盤或C盤根目錄下。
如果是win7系統,使用bootice軟件。
編輯BCD---本地BCD--增加啟動項---實模式--在boot/locate之處點擊一下,選擇一下啟動硬盤和啟動分區(這里填選g2ldr所在分區)--啟動文件處填寫g2ldr.mbr (或者 gr2dr.mbr)---啟動項的名字可以自己起,例如G2LDR.
改變一下顯示時間設置(timeout)為10秒或者20秒。
記得要保存設置。有兩個保存按鈕都要點擊到。
重啟后在BCD菜單選擇G2LDR。

如果是winXP系統,編輯boot.ini,加入一行 C:\g2ldr.mbr=G2LDR.(或者 C:\gr2dr.mbr=G2LDR)
重啟系統。選擇G2LDR。

注意 G2ldr啟動只需要兩個文件 g2ldr g2ldr.mbr 與一個目錄grub2.

注意 使用grub2efi 或 g2ldr時候原則上只需要一個VHD文件.

 

未完,待續…………

 

下一篇:Windows不分區VHD裝Linux多系統(六):優化 & 安裝NVIDIA 920MX獨顯驅動


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM