【Grub & Grub2】万能优盘启动盘 (WinPE、LinuxPE)-- 方法1 U盘三分区法(不推荐,供参考)

        由于工作需要,经常使用Windows和Linux双系统,系统使用过程中,个人涉及到的开发软件过多(光基于Eclipse的IDE就有好几个),经常过度安装软件,有时会越来越庞大,越来越不稳定,定期要重新安装配置,但是又不想重头安装,基本软件最好先配置好备份一下,然后直接恢复。

        Windows下使用Ghost即可,Linux下之前使用dd以及tar备份过,前者磁盘限制较大,后者效果很不好,后来使用了CloneZilla做备份,注意恢复时需要修改引导,所以为了避免引导被破坏,可以参考以下方式分配硬盘。

推荐的硬盘分区方式
分区描述大小备注
第1分区【GRUB2 分区】

约250MB

fat/fat32格式

放GRUB2配置文件,如何制作BIOS或者UEFI的GRUB2引导,请参考:

BIOS:https://blog.csdn.net/u010875635/article/details/82584644

UEFI:https://blog.csdn.net/u010875635/article/details/74289971

第2分区【Win7 NTFS分区】

约100GB

NTFS格式

Windows安装时,引导选择在本分区,且不新建引导,这样不会破坏整体GRUB2引导,对于有多个Windows,可以多建几个分区,统一使用GRUB2引导
第3分区【文件分区1】自定义 
…………自定义 
第3+n分区【文件分区n】自定义 
第4+n分区【Linux ext4分区】 Windows安装时,引导选择在本分区,不能选择磁盘,这样不会破坏整体GRUB2引导,对于有多个Linux,可以多建几个分区,统一使用GRUB2引导

      以上属于题外话,下面讲述U盘万能启动盘的制作,万能启动盘有以下特性

  1. 同时使用GRUB和GRUB2(因为GRUB2不支持UD分区)
  2. 支持UD分区
  3. 支持BIOS和UEFI
  4. 含WinPE(含aomei无损windows分区)
  5. 含LinuxPE如Slitaz及Ubuntu Live CD(含gparted无损Linux分区)
  6. 含CloneZilla(支持Linux系统备份)

        整个优盘的分区分布如下:

万能启动优盘分区分布
分区描述大小备注
第1分区

【UD分区】隐藏

根据WinPE大小确定,一般500MB放置bios版的grub,以及winpe
第2分区【数据分区】可见正常U盘拷贝文件的区域

可将Ubuntu镜像拷贝进去

第3分区【EFI分区】高端隐藏根据UEFI版本WinPE和CloneZilla大小决定,500MB左右BIOS及UEFI版本GRUB2,以及EFI WinPE,CloneZilla等

 

    制作需要原料(由于文件太大,我就不上传一键制作软件了)

1、U盘三分区一键制作软件(例如天意优盘三分区,我们在这个基础上改就好了)

2、制作好的BIOS及UEFI版本的GRUB2

3、Ubuntu镜像

4、CloneZilla镜像

5、UltraISO以及FbinstTool两个编辑软件

6、U盘一个(2G以上,若Ubuntu较大,则需更大优盘)

 

        解压已有的U盘三分区压缩包,会发现三个文件,ty.fba、ty.exe、ty.iso,fba对应UD分区,ISO对应EFI分区。

 

一、制作步骤

        1、解压CloneZilla,提取 live、syslinux文件夹以及CloneZilla-Live-Version和GPL文件

 

        2、使用UltraISO编辑ty.iso,将live、syslinux文件夹以及CloneZilla-Live-Version和GPL文件添加到根目录

 

        3、将BIOS和UEFI的GRUB2添加到ty.iso的对应目录(根据制作是参数确定)

 

 

        3、编辑GRUB2的配置菜单(提取CloneZilla下EFI/boot/grub.conf的menuentry菜单,集成进入我们的菜单),GRUB2原生支持UEFI,所以部分BIOS菜单也可添加到UEFI版本GRUB2菜单。

        BIOS版GRUB2菜单范例(grub.cfg)

        注意:XUbuntu镜像的路径为/OS/Linux下,所以我们后面要将镜像放到对应的可见区域内,名称一定要确保完全一致。

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 gfxterm


set 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=5

menuentry "Win7" --class windows --class os {
	insmod ntfs
	insmod chain
	insmod echo
	set root=(hd1,msdos2)
	echo "Start Windows"
	chainloader +1
}

menuentry "Install XUbuntu18.04" --class ubuntu --class os {
	insmod ext2
	insmod linux
	insmod loopback
	insmod ntfs
	insmod echo
	search.file /OS/Linux/xubuntu-18.04-desktop-amd64.iso root
	loopback loop0 /OS/Linux/xubuntu-18.04-desktop-amd64.iso
	linux (loop0)/casper/vmlinuz ro boot=casper iso-scan/filename=/OS/Linux/xubuntu-18.04-desktop-amd64.iso ro splash
	initrd (loop0)/casper/initrd.lz
	echo "Install XUbuntu 18.04"
}


menuentry "Clonezilla live (Default settings, VGA 800x600)"{
  insmod linux
  search --set -f /live/vmlinuz
  linux /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
  initrd /live/initrd.img
}
menuentry "Clonezilla live (Default settings, VGA 1024x768)"{
  insmod linux
  search --set -f /live/vmlinuz
  linux /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=1
  initrd /live/initrd.img
}

menuentry "Clonezilla live (Default settings, VGA 640x480)"{
  insmod linux
  search --set -f /live/vmlinuz
  linux /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=1
  initrd /live/initrd.img
}

menuentry "Clonezilla live (Default settings, KMS)"{
  insmod linux
  search --set -f /live/vmlinuz
  linux /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  splash
  initrd /live/initrd.img
}

menuentry "Clonezilla live (To RAM, boot media can be removed later)"{
  insmod linux
  search --set -f /live/vmlinuz
  linux /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=1
  initrd /live/initrd.img
}

menuentry "Clonezilla live Safe graphic settings (vga=normal)"{
  insmod linux
  search --set -f /live/vmlinuz
  linux /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 nosplash
  initrd /live/initrd.img
}

menuentry "Clonezilla live (Failsafe mode)"{
  insmod linux
  search --set -f /live/vmlinuz
  linux /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 nosplash
  initrd /live/initrd.img
}

menuentry --hotkey=s "Clonezilla live (speech synthesis)"{
  insmod linux
  search --set -f /live/vmlinuz
  linux /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.efi
  chainloader /live/ipxe.efi + 1
}



menuentry "-------------------" --class ubuntu --class os{
	set root=(hd0,gpt1)
}



menuentry "reboot" --class windows --class os{
	insmod reboot
	reboot
}

menuentry "halt" --class windows --class os{
	insmod halt
	halt
}

 

        UEFI版GRUB2,菜单

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}


insmod part_msdos
insmod fat

#set font
font="$prefix/unicode.pf2"
if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=zh_CN
  insmod gettext
fi

#adjust the screen resolution
terminal_output gfxterm

#background
insmod jpeg
if background_image $prefix/background.jpg; then
  true
else
  set menu_color_normal=white/black
  set menu_color_highlight=black/light-gray
  if background_color 255,255,155,0; then
    clear
  fi
fi



#default select menu index
set default=0

#timeout
set timeout_style=menu
set timeout=5


menuentry "start win8 pe" --class windows --class os {
	set efifile=/EFI/Boot/win8pe.efi
	search.file $efifile root
	echo "Start Windows"
	chainloader $efifile
}

menuentry "start windows" --class windows --class os {
	insmod ntfs
	set efifile=/EFI/Microsoft/Boot/bootmgfw.efi
	search.file $efifile root
	echo "Start Windows"
	chainloader $efifile}

menuentry "start ubuntu" --class ubuntu --class os {
	insmod ext2
	set kernelfile=/vmlinuz
	set initrdfile=/initrd.img
	search.file $kernelfile root
	
	linux $kernelfile ro root=/dev/sda2
	initrd $initrdfile
	echo "Start Ubuntu"
}


menuentry "-------------------" --class ubuntu --class os{
	set root=(hd0,gpt1)
}

menuentry "install ubuntu" --class ubuntu --class os {
	insmod ext2
	insmod loopback

	set isofile=/OS/Linux/xubuntu-16.04.3-desktop-amd64.iso	
	search.file $isofile root

	loopback loop $isofile
	linux	(loop)/casper/vmlinuz.efi  boot=casper iso-scan/filename=$isofile
	initrd	(loop)/casper/initrd.lz
}

menuentry "-------------------" --class ubuntu --class os{
	set root=(hd0,gpt1)
}

menuentry "reboot" --class windows --class os{
	insmod reboot
	reboot
}

menuentry "halt" --class windows --class os{
	insmod halt
	halt
}

        4、使用FbinstTool修改UD分区grub菜单,增加启动grub2菜单(grub2不支持ud分区,所以bios版本grub2放到了EFI分区镜像)。

 

        从grub启动grub2。

title GRUB2 Menu
      find --set-root /efi/grub/z_g2ldr
      kernel /efi/grub/z_g2ldr

 

        至此,定制版万能启动优盘制作完毕,插入U盘,使用ty.exe开始制作,制作完毕后,将Ubuntu镜像放到可见区菜单中设置的目录中,开机从U盘启动即可。

 

二、相关文件修改

1、GRUB菜单修改,使用FbinstTool工具即可

2、GRUB2菜单修改,使用由于EFI分区是隐藏的,所以需要使用工具(例如Bootice的分区管理)显示分区,然后使用记事本修改菜单即可,若是在Linux下则更简单,直接挂载分区,然后修改。

3、若是觉得Ubuntu放在外部麻烦,可以下载精简版的将其打包进ISO中,然后重新制作U盘即可隐藏。一般来说太大会不方便更换。

4、升级CloneZilla和Ubuntu,替换文件夹及文件即可,若是有菜单修改需求,修改菜单。

5、若是不希望使用grub,可以不用UD分区,将所有文件制作到一个ISO中,然后写入U盘,写完之后将grub2的BIOS引导使用扇区工具(BootIce)写入mbr,这里使用UD分区目的就是直接使用ty.exe工具一键制作而已。

        

  • 2
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果Oracle Linux启动盘损坏,需要重新创建引导分区并重新安装GRUB2,可以按照以下步骤进行操作: 1. 首先,使用另一台计算机或者U盘启动Oracle Linux安装程序,并选择“Rescue a Oracle Linux system”选项进入救援模式。 2. 在救援模式中,选择“Start shell”选项,进入命令行模式。 3. 使用fdisk或者parted工具查看当前的分区结构,确定引导分区所在的位置。 4. 使用mkfs命令格式化引导分区,例如: ``` mkfs.ext4 /dev/sda1 ``` 这里假设引导分区为/dev/sda1,并使用ext4文件系统格式化。 5. 接着,将引导分区挂载到某个目录下,例如: ``` mount /dev/sda1 /mnt/boot ``` 这里将/dev/sda1挂载到/mnt/boot目录下。 6. 然后,在/mnt/boot目录下创建/boot/grub目录,并将引导程序复制到该目录下,例如: ``` mkdir -p /mnt/boot/grub cp /usr/lib/grub/i386-pc/* /mnt/boot/grub/ ``` 这里假设使用的是i386-pc架构的引导程序,所以从/usr/lib/grub/i386-pc目录下复制。 7. 接着,使用chroot命令将系统根目录切换到引导分区所在的目录下,例如: ``` chroot /mnt ``` 8. 然后,重新安装GRUB2引导程序,例如: ``` grub2-install /dev/sda ``` 这里假设系统安装在/dev/sda磁上。 9. 最后,退出chroot环境,卸载引导分区并重启系统,让新的引导分区GRUB2生效,例如: ``` exit umount /mnt/boot reboot ``` 重启后,系统应该能够正常引导了。 注意:上述操作仅适用于重新创建引导分区和重新安装GRUB2,如果启动盘上的其他数据丢失或损坏,需要进行数据恢复或者重新安装系统等操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值