【Grub Grub2】万能优盘启动盘 (WinPE、LinuxPE)-- 方法1 U盘三分区法(不推荐,供参考)
? ? ? ? 由于工作需要,經(jīng)常使用Windows和Linux雙系統(tǒng),系統(tǒng)使用過程中,個人涉及到的開發(fā)軟件過多(光基于Eclipse的IDE就有好幾個),經(jīng)常過度安裝軟件,有時會越來越龐大,越來越不穩(wěn)定,定期要重新安裝配置,但是又不想重頭安裝,基本軟件最好先配置好備份一下,然后直接恢復(fù)。
? ? ? ? Windows下使用Ghost即可,Linux下之前使用dd以及tar備份過,前者磁盤限制較大,后者效果很不好,后來使用了CloneZilla做備份,注意恢復(fù)時需要修改引導(dǎo),所以為了避免引導(dǎo)被破壞,可以參考以下方式分配硬盤。
| 第1分區(qū) | 【GRUB2 分區(qū)】 | 約250MB fat/fat32格式 | 放GRUB2配置文件,如何制作BIOS或者UEFI的GRUB2引導(dǎo),請參考: BIOS:https://blog.csdn.net/u010875635/article/details/82584644 UEFI:https://blog.csdn.net/u010875635/article/details/74289971 |
| 第2分區(qū) | 【W(wǎng)in7 NTFS分區(qū)】 | 約100GB NTFS格式 | Windows安裝時,引導(dǎo)選擇在本分區(qū),且不新建引導(dǎo),這樣不會破壞整體GRUB2引導(dǎo),對于有多個Windows,可以多建幾個分區(qū),統(tǒng)一使用GRUB2引導(dǎo) |
| 第3分區(qū) | 【文件分區(qū)1】 | 自定義 | ? |
| …… | …… | 自定義 | ? |
| 第3+n分區(qū) | 【文件分區(qū)n】 | 自定義 | ? |
| 第4+n分區(qū) | 【Linux ext4分區(qū)】 | ? | Windows安裝時,引導(dǎo)選擇在本分區(qū),不能選擇磁盤,這樣不會破壞整體GRUB2引導(dǎo),對于有多個Linux,可以多建幾個分區(qū),統(tǒng)一使用GRUB2引導(dǎo) |
? ? ? 以上屬于題外話,下面講述U盤萬能啟動盤的制作,萬能啟動盤有以下特性
? ? ? ? 整個優(yōu)盤的分區(qū)分布如下:
| 第1分區(qū) | 【UD分區(qū)】隱藏 | 根據(jù)WinPE大小確定,一般500MB | 放置bios版的grub,以及winpe |
| 第2分區(qū) | 【數(shù)據(jù)分區(qū)】可見 | 正常U盤拷貝文件的區(qū)域 | 可將Ubuntu鏡像拷貝進去 |
| 第3分區(qū) | 【EFI分區(qū)】高端隱藏 | 根據(jù)UEFI版本W(wǎng)inPE和CloneZilla大小決定,500MB左右 | BIOS及UEFI版本GRUB2,以及EFI WinPE,CloneZilla等 |
?
? ? 制作需要原料(由于文件太大,我就不上傳一鍵制作軟件了)
1、U盤三分區(qū)一鍵制作軟件(例如天意優(yōu)盤三分區(qū),我們在這個基礎(chǔ)上改就好了)
2、制作好的BIOS及UEFI版本的GRUB2
3、Ubuntu鏡像
4、CloneZilla鏡像
5、UltraISO以及FbinstTool兩個編輯軟件
6、U盤一個(2G以上,若Ubuntu較大,則需更大優(yōu)盤)
?
? ? ? ? 解壓已有的U盤三分區(qū)壓縮包,會發(fā)現(xiàn)三個文件,ty.fba、ty.exe、ty.iso,fba對應(yīng)UD分區(qū),ISO對應(yīng)EFI分區(qū)。
?
一、制作步驟
? ? ? ? 1、解壓CloneZilla,提取 live、syslinux文件夾以及CloneZilla-Live-Version和GPL文件
?
? ? ? ? 2、使用UltraISO編輯ty.iso,將live、syslinux文件夾以及CloneZilla-Live-Version和GPL文件添加到根目錄
?
? ? ? ? 3、將BIOS和UEFI的GRUB2添加到ty.iso的對應(yīng)目錄(根據(jù)制作是參數(shù)確定)
?
?
? ? ? ? 3、編輯GRUB2的配置菜單(提取CloneZilla下EFI/boot/grub.conf的menuentry菜單,集成進入我們的菜單),GRUB2原生支持UEFI,所以部分BIOS菜單也可添加到UEFI版本GRUB2菜單。
? ? ? ? BIOS版GRUB2菜單范例(grub.cfg)
? ? ? ? 注意:XUbuntu鏡像的路徑為/OS/Linux下,所以我們后面要將鏡像放到對應(yīng)的可見區(qū)域內(nèi),名稱一定要確保完全一致。
insmod echo insmod part_msdos insmod fat#background insmod jpeg insmod gfxmenu insmod gfxterm insmod gfxterm_background insmod gfxterm_menu insmod true#adjust the screen resolution terminal_output gfxtermset background_image=$prefix/background.jpg# set menu_color_normal=white/black # set menu_color_highlight=black/light-gray # background_color 255,255,155,0; then#default select menu index set default=0#timeout set timeout_style=menu set timeout=5menuentry "Win7" --class windows --class os {insmod ntfsinsmod chaininsmod echoset root=(hd1,msdos2)echo "Start Windows"chainloader +1 }menuentry "Install XUbuntu18.04" --class ubuntu --class os {insmod ext2insmod linuxinsmod loopbackinsmod ntfsinsmod echosearch.file /OS/Linux/xubuntu-18.04-desktop-amd64.iso rootloopback loop0 /OS/Linux/xubuntu-18.04-desktop-amd64.isolinux (loop0)/casper/vmlinuz ro boot=casper iso-scan/filename=/OS/Linux/xubuntu-18.04-desktop-amd64.iso ro splashinitrd (loop0)/casper/initrd.lzecho "Install XUbuntu 18.04" }menuentry "Clonezilla live (Default settings, VGA 800x600)"{insmod linuxsearch --set -f /live/vmlinuzlinux /live/vmlinuz boot=live union=overlay username=user hostname=bionic config quiet components noswap edd=on nomodeset locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch="no" vga=788 ip= net.ifnames=0 splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1initrd /live/initrd.img } menuentry "Clonezilla live (Default settings, VGA 1024x768)"{insmod linuxsearch --set -f /live/vmlinuzlinux /live/vmlinuz boot=live union=overlay username=user hostname=bionic config quiet components noswap edd=on nomodeset locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch="no" vga=791 ip= net.ifnames=0 splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1initrd /live/initrd.img }menuentry "Clonezilla live (Default settings, VGA 640x480)"{insmod linuxsearch --set -f /live/vmlinuzlinux /live/vmlinuz boot=live union=overlay username=user hostname=bionic config quiet components noswap edd=on nomodeset locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch="no" vga=785 ip= net.ifnames=0 splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1initrd /live/initrd.img }menuentry "Clonezilla live (Default settings, KMS)"{insmod linuxsearch --set -f /live/vmlinuzlinux /live/vmlinuz boot=live union=overlay username=user hostname=bionic config quiet components noswap edd=on locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch="no" vga=791 ip= net.ifnames=0 splashinitrd /live/initrd.img }menuentry "Clonezilla live (To RAM, boot media can be removed later)"{insmod linuxsearch --set -f /live/vmlinuzlinux /live/vmlinuz boot=live union=overlay username=user hostname=bionic config quiet components noswap edd=on nomodeset locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch="no" vga=788 toram=live,syslinux ip= net.ifnames=0 splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1initrd /live/initrd.img }menuentry "Clonezilla live Safe graphic settings (vga=normal)"{insmod linuxsearch --set -f /live/vmlinuzlinux /live/vmlinuz boot=live union=overlay username=user hostname=bionic config quiet components noswap edd=on nomodeset locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch="no" ip= net.ifnames=0 nomodeset vga=normal nosplashinitrd /live/initrd.img }menuentry "Clonezilla live (Failsafe mode)"{insmod linuxsearch --set -f /live/vmlinuzlinux /live/vmlinuz boot=live union=overlay username=user hostname=bionic config quiet components noswap edd=on nomodeset locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch="no" acpi=off irqpoll noapic noapm nodma nomce nolapic nosmp ip= net.ifnames=0 nomodeset vga=normal nosplashinitrd /live/initrd.img }menuentry --hotkey=s "Clonezilla live (speech synthesis)"{insmod linuxsearch --set -f /live/vmlinuzlinux /live/vmlinuz boot=live union=overlay username=user hostname=bionic config quiet components noswap edd=on nomodeset locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch="no" vga=788 ip= net.ifnames=0 splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1 speakup.synth=soft ---initrd /live/initrd.img }#menuentry "memtest"{ # search --set -f /live/memtest # linux16 /live/memtest #}#menuentry "FreeDOS"{ # linux16 memdisk # initrd /live/freedos.img #}menuentry "iPXE"{search --no-floppy --set=root -f /live/ipxe.efichainloader /live/ipxe.efi + 1 }menuentry "-------------------" --class ubuntu --class os{set root=(hd0,gpt1) }menuentry "reboot" --class windows --class os{insmod rebootreboot }menuentry "halt" --class windows --class os{insmod halthalt }?
? ? ? ? UEFI版GRUB2,菜單
function load_video {if [ x$feature_all_video_module = xy ]; theninsmod all_videoelseinsmod efi_gopinsmod efi_ugainsmod ieee1275_fbinsmod vbeinsmod vgainsmod video_bochsinsmod video_cirrusfi }insmod part_msdos insmod fat#set font font="$prefix/unicode.pf2" if loadfont $font ; thenset gfxmode=autoload_videoinsmod gfxtermset locale_dir=$prefix/localeset lang=zh_CNinsmod gettext fi#adjust the screen resolution terminal_output gfxterm#background insmod jpeg if background_image $prefix/background.jpg; thentrue elseset menu_color_normal=white/blackset menu_color_highlight=black/light-grayif background_color 255,255,155,0; thenclearfi fi#default select menu index set default=0#timeout set timeout_style=menu set timeout=5menuentry "start win8 pe" --class windows --class os {set efifile=/EFI/Boot/win8pe.efisearch.file $efifile rootecho "Start Windows"chainloader $efifile }menuentry "start windows" --class windows --class os {insmod ntfsset efifile=/EFI/Microsoft/Boot/bootmgfw.efisearch.file $efifile rootecho "Start Windows"chainloader $efifile}menuentry "start ubuntu" --class ubuntu --class os {insmod ext2set kernelfile=/vmlinuzset initrdfile=/initrd.imgsearch.file $kernelfile rootlinux $kernelfile ro root=/dev/sda2initrd $initrdfileecho "Start Ubuntu" }menuentry "-------------------" --class ubuntu --class os{set root=(hd0,gpt1) }menuentry "install ubuntu" --class ubuntu --class os {insmod ext2insmod loopbackset isofile=/OS/Linux/xubuntu-16.04.3-desktop-amd64.iso search.file $isofile rootloopback loop $isofilelinux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofileinitrd (loop)/casper/initrd.lz }menuentry "-------------------" --class ubuntu --class os{set root=(hd0,gpt1) }menuentry "reboot" --class windows --class os{insmod rebootreboot }menuentry "halt" --class windows --class os{insmod halthalt }? ? ? ? 4、使用FbinstTool修改UD分區(qū)grub菜單,增加啟動grub2菜單(grub2不支持ud分區(qū),所以bios版本grub2放到了EFI分區(qū)鏡像)。
?
? ? ? ? 從grub啟動grub2。
title GRUB2 Menufind --set-root /efi/grub/z_g2ldrkernel /efi/grub/z_g2ldr?
? ? ? ? 至此,定制版萬能啟動優(yōu)盤制作完畢,插入U盤,使用ty.exe開始制作,制作完畢后,將Ubuntu鏡像放到可見區(qū)菜單中設(shè)置的目錄中,開機從U盤啟動即可。
?
二、相關(guān)文件修改
1、GRUB菜單修改,使用FbinstTool工具即可
2、GRUB2菜單修改,使用由于EFI分區(qū)是隱藏的,所以需要使用工具(例如Bootice的分區(qū)管理)顯示分區(qū),然后使用記事本修改菜單即可,若是在Linux下則更簡單,直接掛載分區(qū),然后修改。
3、若是覺得Ubuntu放在外部麻煩,可以下載精簡版的將其打包進ISO中,然后重新制作U盤即可隱藏。一般來說太大會不方便更換。
4、升級CloneZilla和Ubuntu,替換文件夾及文件即可,若是有菜單修改需求,修改菜單。
5、若是不希望使用grub,可以不用UD分區(qū),將所有文件制作到一個ISO中,然后寫入U盤,寫完之后將grub2的BIOS引導(dǎo)使用扇區(qū)工具(BootIce)寫入mbr,這里使用UD分區(qū)目的就是直接使用ty.exe工具一鍵制作而已。
? ? ? ??
總結(jié)
以上是生活随笔為你收集整理的【Grub Grub2】万能优盘启动盘 (WinPE、LinuxPE)-- 方法1 U盘三分区法(不推荐,供参考)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 大智慧705服务器文件夹,大智慧2文件目
- 下一篇: 同花顺股票自动交易