无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站广告联系 微信:wuyouceo QQ:184822951
楼主: 星体投射
打印 上一主题 下一主题

[原创] dnsmasq设置bios和uefi双启动多引导菜单(完美)

  [复制链接]
1#
发表于 2021-10-16 15:16:38 | 显示全部楼层
本帖最后由 liquanyi 于 2021-10-16 15:33 编辑

我的方法很简单,在/etc/dnsmasq.conf里面添加如下内容,不用修改ipxe的内置菜单,直接加载ipxe后第二次加载menu.ipxe菜单,然后菜单根据变量判断生成BIOS或EFI32或EFI64的菜单
  1. enable-tftp
  2. tftp-root=/opt/tftpboot
  3. dhcp-userclass=set:ipxe,iPXE
  4. dhcp-match=set:pcbios,option:client-arch,0
  5. dhcp-match=set:efi-x86,option:client-arch,6
  6. dhcp-match=set:efi-x86_64,option:client-arch,7
  7. dhcp-match=set:efi-x86_64,option:client-arch,9
  8. dhcp-match=set:efi-arm32,option:client-arch,10
  9. dhcp-match=set:efi-arm64,option:client-arch,11
  10. dhcp-boot=tag:!ipxe,tag:pcbios,"undionly.kpxe"
  11. dhcp-boot=tag:!ipxe,tag:efi-x86_64,"snponly.efi"
  12. dhcp-boot=tag:!ipxe,tag:efi-x86,"snponly32.efi"
  13. dhcp-boot=tag:ipxe,tag:pcbios,"menu.ipxe"
  14. dhcp-boot=tag:ipxe,tag:efi-x86_64,"menu.ipxe"
  15. dhcp-boot=tag:ipxe,tag:efi-x86,"menu.ipxe"
复制代码


menu.ipxe菜单文件如下
  1. #!ipxe

  2. set base-url http://openwrt.lan/wwwboot
  3. set menu-timeout 10000
  4. set kspath ${base-url}/kickstarts
  5. cpuid --ext 29 && set arch x86_64 || set arch i386
  6. set start_menu ${platform}_${buildarch}_menu
  7. echo ${start_menu}
  8. goto ${start_menu}

  9. :pcbios_x86_64_menu
  10. goto pcbios_i386_menu

  11. :pcbios_i386_menu
  12. menu My iPXE Boot Menu ${buildarch}_${platform}
  13. set menu-default win10x64
  14. item --gap Linux series
  15. item centos7 --CentOS 7
  16. item debian10 --Debian 10
  17. item --gap Windows series
  18. item win8x32 --Win8 PE x32
  19. item win10x64 --Win10 PE x64
  20. item HardDisk --From hard disk
  21. item --gap Dos series
  22. item mhdd46 --mhdd4.6
  23. item custom_exit --Exit

  24. choose --timeout ${menu-timeout} --default ${menu-default} selected
  25. goto ${selected}

  26. :efi_x86_64_menu
  27. menu My iPXE Boot Menu ${buildarch}_${platform}
  28. set menu-default win10x64
  29. item --gap Linux series
  30. item centos7 --CentOS 7
  31. item debian10 --Debian 10
  32. item --gap Windows series
  33. item win10x64 --Win10 PE x64
  34. item grub2 --Grub2 Shell
  35. item HardDisk --From hard disk

  36. choose --timeout ${menu-timeout} --default ${menu-default} selected
  37. goto ${selected}

  38. :efi_i386_menu
  39. menu My iPXE Boot Menu ${buildarch}_${platform}
  40. set menu-default win8x32
  41. item --gap Windows series
  42. item win8x32 --Win8 PE x32
  43. item HardDisk --From hard disk

  44. choose --timeout ${menu-timeout} --default ${menu-default} selected
  45. goto ${selected}

  46. :shell
  47. echo Type 'Exit' to get the back to the menu
  48. shell
  49. goto ${start_menu}

  50. :failed
  51. echo Booting failed, dropping to shell
  52. goto shell

  53. :reboot
  54. reboot

  55. :HardDisk
  56. exit

  57. :localdisk
  58. sanboot --no-describe --drive 0x80

  59. :centos7
  60. kernel ${base-url}/centos7.4/isolinux/vmlinuz ip=dhcp ks=${kspath}/Centos-7.x-min.cfg repo=${base-url}/centos7.4
  61. initrd ${base-url}/centos7.4/isolinux/initrd.img
  62. boot || goto failed

  63. :debian10
  64. kernel ${base-url}/debian/buster/amd64/linux initrd=initrd.gz
  65. initrd ${base-url}/debian/buster/amd64/initrd.gz
  66. boot || goto failed

  67. :debian10-i386
  68. kernel ${base-url}/debian/buster/i386/linux initrd=initrd.gz
  69. initrd ${base-url}/debian/buster/i386/initrd.gz
  70. boot || goto failed

  71. :win8x32
  72. kernel wimboot.${buildarch}
  73. initrd --name bootmgr.exe ${base-url}/boot/bootmgr.exe bootmgr.exe
  74. initrd --name bootmgfw.efi ${base-url}/boot/bootmgfw32.efi bootmgfw.efi
  75. initrd --name BCD ${base-url}/boot/bcd BCD
  76. initrd --name boot.sdi ${base-url}/boot/boot.sdi boot.sdi
  77. initrd --name boot.wim ${base-url}/sources/WEPE32.WIM boot.wim
  78. boot || goto failed

  79. :win10x64
  80. kernel wimboot.${buildarch}
  81. initrd --name bootmgr.exe ${base-url}/boot/bootmgr.exe bootmgr.exe
  82. initrd --name bootmgfw.efi ${base-url}/boot/bootmgfw.efi bootmgfw.efi
  83. initrd --name BCD ${base-url}/boot/bcd BCD
  84. initrd --name boot.sdi ${base-url}/boot/boot.sdi boot.sdi
  85. initrd --name boot.wim ${base-url}/sources/WEPE64.WIM boot.wim
  86. boot || goto failed

  87. :grub2
  88. kernel ${base-url}/boot/GRUBShell.efi
  89. boot || goto failed

  90. :mhdd46
  91. kernel ${base-url}/boot/memdisk
  92. initrd ${base-url}/boot/mhdd46.ima
  93. boot || goto failed

复制代码

点评

大佬,太感谢你了,这正是我要找的。能提供包括ipxe的模板文件下载吗?另外能否支持ftp?  详情 回复 发表于 2021-10-16 22:28
回复

使用道具 举报

2#
发表于 2021-10-16 15:45:35 | 显示全部楼层
效果








回复

使用道具 举报

3#
发表于 2021-10-16 23:28:47 | 显示全部楼层
tigerhuang 发表于 2021-10-16 22:28
大佬,太感谢你了,这正是我要找的。能提供包括ipxe的模板文件下载吗?另外能否支持ftp?

pxe启动ipxe与拿配置文件用tftp,后面用http

点评

我的HTTP有其他用途,不支持FTP吗?  详情 回复 发表于 2021-10-17 00:40
回复

使用道具 举报

4#
发表于 2021-10-16 23:53:59 | 显示全部楼层
tigerhuang 发表于 2021-10-16 22:28
大佬,太感谢你了,这正是我要找的。能提供包括ipxe的模板文件下载吗?另外能否支持ftp?

启动PE由于大多数PE精简了启动所需文件,所以需要从官方winre.wim或boot.wim里面提取后放http目录
注意把32位的bootmgfw.efi改名为bootmgfw32.efi
tftpboot.7z (261.45 KB, 下载次数: 5)

bcd.7z (1.42 KB, 下载次数: 2)


回复

使用道具 举报

5#
发表于 2021-10-17 02:09:26 | 显示全部楼层
tigerhuang 发表于 2021-10-17 00:40
我知道tftp是启动以及拿配置用的,不能少。我的HTTP有其他用途,能改为支持FTP(不是tftp)下载镜像文件吗 ...

应该可以的,你把set base-url http://openwrt.lan/wwwboot改成set base-url ftp://你的ftp目录试试

点评

这两天在忙,没上网。 谢谢,我尽快测试后再汇报结果。  详情 回复 发表于 2021-10-18 20:50
回复

使用道具 举报

6#
发表于 2021-10-19 17:56:04 | 显示全部楼层
本帖最后由 liquanyi 于 2021-10-19 17:59 编辑
tigerhuang 发表于 2021-10-18 20:50
抱歉,前两天在忙,没上网。

请问,你的附件里我只看到snponly32.efi,没有snponly.efi这个文件,如何 ...

附件包里面有snponly.efi,undionly.kpxe啊,另外最新的snponly.efi,undionly.kpxe可以在官网下载http://boot.ipxe.org/,snponly32.efi由于官网默认没编译提供需要自己下载源码编译,启动iso的大概这样,你可以自己试试。memdisk从syslinux包里面找
  1. :win10x32
  2. kernel ${dirpath}/win10/memdisk raw iso
  3. initrd ${dirpath}/win10/W10X32_CN_PE.iso
  4. boot || goto failed
复制代码

点评

请问bootmgr.exe,bootmgfw.efi,BCD,boot.sdi这些文件要到哪里去下载?任何一个Win10里面的可以吗?现在头疼是不知道去哪里找所需要的文件。  详情 回复 发表于 2021-10-20 06:04
回复

使用道具 举报

7#
发表于 2021-10-20 08:44:29 | 显示全部楼层
tigerhuang 发表于 2021-10-20 06:04
请问bootmgr.exe,bootmgfw.efi,BCD,boot.sdi这些文件要到哪里去下载?任何一个Win10里面的可以吗?现在头 ...

winre.wim或boot.wim的Windows\Boot目录下面的各个目录去找,BCD我附件上传的有

点评

还是多谢你! 又要考虑去哪里下载Boot目录里的启动文件,想想还是算了,一个问题有牵涉到另外一个问题,要是有人能一次性提供除WinPE外所有启动文件就好了 我另起一个悬赏帖吧,希望有人能实现我的要  详情 回复 发表于 2021-10-21 04:31
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1 )

闽公网安备 35020302032614号

GMT+8, 2024-5-2 22:32

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表