| 
 | 
 
 本帖最后由 2011895866818 于 2017-11-26 19:15 编辑  
 
└─boot 
    └─grub 
        │  intern.cfg 
        │  embed.cfg 
        │ 
        ├─fonts 
        │      unicode.pf2 
        │ 
        ├─locale 
        │      en_CA.mo 
        │      en_GB.mo 
        │      en@quot.mo 
        │      en_AU.mo 
        │      zh_CN.mo 
        │ 
        └─x86_64-efi 
                boot.mod 
                odc.mod 
                lvm.mod 
                ………… 
 
所有子模块都可以包含到x86_64-efi目录 
引导grub2.efi后这个目录,会自动挂载到  (memdisk)  
 
在boot的同级目录打包 
tar -cvf ../md.tar boot/ 
然后 
cd  .. 
 
grub-mkimage --directory '/usr/lib/grub/x86_64-efi' --prefix '(memdisk)/boot/grub' --output 'grub2allx86_64.efi' --format 'x86_64-efi' --compression 'auto'  --memdisk 'md.tar' 'memdisk' 'tar' -c mods/boot/grub/embed.cfg -v 
 
就得到了:grub2allx86_64.efi  【附件】 
 
embed.cfg 嵌入到core里面, 这个(memdisk)/boot/grub/embed.cfg是放在这里方便查看的 
 
- set prefix=(memdisk)/boot/grub
 
 - insmod normal
 
 - normal (memdisk)/boot/grub/intern.cfg
 
 
  复制代码 
这里用normal加载cfg非常重要,不然后面的菜单有问题,内嵌菜单执行的时候,还没有进入normal模式, 
无法处理菜单条目,很多命令无法调用,等等 
 
 intern.cfg 直接放在(memdisk)/boot/grub 
 
- #20171126 tick v3.1
 
 - #分辨率,字体
 
 - font=unicode
 
 - if loadfont $font ; then
 
 -   set gfxmode=auto
 
 -   insmod all_video
 
 -   insmod gfxterm
 
 -   set locale_dir=$prefix/locale
 
 -   set lang=zh_CN
 
 -   insmod gettext
 
 - fi
 
 - terminal_output console
 
 - terminal_output gfxterm
 
 - #隐藏内置菜单,颜色设置
 
 - set timeout_style=hidden
 
 - set timeout=0
 
 - set menu_color_normal=white/black
 
 - set menu_color_highlight=black/light-gray
 
 - if background_color 44,0,30,0; then
 
 -   clear
 
 - fi
 
 - #分区支持
 
 - insmod part_gpt
 
 - insmod fat
 
 - insmod ntfs
 
 - insmod gzio
 
 - insmod part_gpt
 
 - insmod ext2
 
 - #加载外部菜单
 
 - menuentry 'Find grub.cfg'   {
 
  
-         #search --no-floppy --file --set=root  /grub.cfg
 
 -         #configfile /grub.cfg
 
  
-         #search --no-floppy --file --set=root  /boot/grub.cfg
 
 -         #configfile /boot/grub.cfg
 
  
-         search --no-floppy --file --set=root  /grub/grub.cfg
 
 -         configfile /grub/grub.cfg
 
  
-         search --no-floppy --file --set=root  /boot/grub/grub.cfg
 
 -         configfile /boot/grub/grub.cfg
 
 - }
 
 
  复制代码 
 
  
 
grub2-my-v03.rar
(1.47 MB, 下载次数: 328)
 
 
 |   
 
 
 
 |