|
这一楼就只需要看那几个配置文件的写法就行了 这里有我学习的过程,一些结论是错误的 下面的链接可以参考
- 首先需要通过ISO引导才能进入ipxe的界面 这种方式略过,网站里面的硬件就是集成了这个iso的方式,不用看了
- 然后如果想通过tftp引导启动 则先要下载undionly.kpxe这个文件https://ipxe.org/howto/chainloading
- 然后tftp的boot文件就填这个文件
- 这个文件官网下载的是每次都需要按ctrl+b进入命令行界面的,不知道默认的配置文件名是什么还是说根本没有默认配置文件名
- 官网有教说要自己配置make bin/undionly.kpxe EMBED=boot.ipxe(卧槽,还需要编辑这个boot.ipxe 内容 DHCP chain --autofree boot.ipxe 这样才会查找 我晕了) 指定默认的配置文件,但是我自己编译失败了
- 就用之前的那个吧,实测可以进iscsi
- 下面是之前那个文件的使用方式
- 通过boot.ipxe匹配对应的配置文件,下面的配置文件里面,前面几个都没有匹配到,最后就匹配到最后一个menu.ipxe
- 然后menu.ipxe里面就显示了各种启动选项
- 感觉做这个的是个高手,把各种可能的选项都想到了,我要找找mac匹配的,这样就可以通过mac来匹配不同的配置文件了
- https://ipxe.org/cmd这个页面可以查看ipxe的各种命令
- 通过mac匹配的教程
- 变量${mac:hexhyp}的值应该是010203040506不带任何符号的12位字符,并且必须是小写
- 比如mac-000c29c46fd8.ipxe这样才行,最开始用的大写没有匹配到
- 配置文件就是下面的menu.ipxe
- 然后用initrd启动的时候memdisk这个文件必须在ipxe的同一级目录
- 启动PE的时候ISO文件的大小不能太大,实测WEPE的200M没问题,但是WIN10LTSC的4G的就提示磁盘空间不足了,不知道是为什么
- 感觉启动PE的时候不需要用这种方式,直接sanboot就行比如sanboot http://192.168.11.2/WIN10LTSC/ltsc.iso可以直接启动(用这个方式就不能同时用sanhook)
- (我想研究直接无盘装系统的,先sanhook再启动必须用initrd,但是WEPE没网络,启动到一半就断连接了,然后ltsc的iso又无法启动,卡在这里了)
- 现在问题来了,首先,客户机无盘的情况下怎么装系统到iscsi(-----------就是这个不会,而且这个还需要使用UEFI----------)
- (首先的难点是win10.iso太大,看看怎么才能不出错的引导,其次需要加载iscsi的驱动才能在装的时候维持iscsi,可能要涉及到修改ISO)
- 其次怎么在PE里面挂载ISCSI,方便改密码,比如用户忘记密码了,怎么改?(这个的解决办法是在服务器上建立hyper-v虚拟机,然后改好了关闭虚拟机)
- 通过mac启动以后判断iscsi是否有系统,有就通过iscsi启动系统,没有就启动到pe,并且是把iscsi也添加进去的那种(这个就不用看了,只有第一次是需要装系统的,后面都是直接sanboot)
- 回答:
- 先sanhook命令挂载 格式是 iscsi:服务器IP:用户名:密码:逻辑单元号:目标IQN
- sanhook iscsi:192.168.11.2:::0:iqn.1991-05.com.microsoft:server1-test-target
- 运行以后正确注册了sandevice,但是后面提示could not open san device 看看这个界面https://ipxe.org/err/2c0d60
- 然后用sanboot命令启动iso (-----这个步骤是错的,这两个命令不能同时出现,第一次装系统要研究一下-----)
- sanboot http://192.168.11.2/WIN10LTSC/ltsc.iso
- 最后还有个问题:
- ipxe的界面设置默认显示10秒,然后如果不操作就自动进默认的选项(最下面MAC的配置文件就有了)
- 补充一个:
- uefi启动的时候一定要关闭安全启动,因为ipxe的文件没有签名,过不了安全验证,听说是可以利用linux的grub2的efi文件实现安全启动,不过没必要了,自己用没事
- 测试用我自己的物理机看看
- FC-AA-14-4F-CD-D5
- fcaa144fcdd5
- 回答:直接通过iscsi启动
- https://jingyan.baidu.com/article/ceb9fb108c2a938cac2ba04b.html
- boot.ipxe的内容,这里定义了多个启动顺序
- 比如第一个就是hostname的启动,第二个是uuid启动,第三个是mac#########################################
- #!ipxe
- # Global variables used by all other iPXE scripts
- chain --autofree boot.ipxe.cfg ||
- # Boot <boot-url>/<boot-dir>/hostname-<hostname>.ipxe
- # if hostname DHCP variable is set and script is present
- isset ${hostname} && chain --replace --autofree ${boot-dir}hostname-${hostname}.ipxe ||
- # Boot <boot-url>/<boot-dir>/uuid-<UUID>.ipxe
- # if SMBIOS UUID variable is set and script is present
- isset ${uuid} && chain --replace --autofree ${boot-dir}uuid-${uuid}.ipxe ||
- # Boot <boot-url>/<boot-dir>/mac-010203040506.ipxe if script is present
- chain --replace --autofree ${boot-dir}mac-${mac:hexraw}.ipxe ||
- # Boot <boot-url>/<boot-dir>/pci-8086100e.ipxe if one type of
- # PCI Intel adapter is present and script is present
- chain --replace --autofree ${boot-dir}pci-${pci/${busloc}.0.2}${pci/${busloc}.2.2}.ipxe ||
- # Boot <boot-url>/<boot-dir>/chip-82541pi.ipxe if one type of
- # PCI Intel adapter is present and script is present
- chain --replace --autofree ${boot-dir}chip-${chip}.ipxe ||
- # Boot <boot-url>/menu.ipxe script if all other options have been exhausted
- chain --replace --autofree ${menu-url} ||
- boot.ipxe.cfg的内容 这里面定义了几个变量,包括menu-url和boot-dir(就是boot目录)
- #########################################
- #!ipxe
- # OPTIONAL: Base URL used to resolve most other resources
- # Should always end with a slash
- set boot-url tftp://${next-server}/
- set nas_ip 10.10.10.250
- # OPTIONAL: What URL to use when sanbooting
- # Usually ${boot-url} is used, but required until NFS supports block device API
- # Should always end with a slash
- set sanboot-url http://${nas_ip}:88/Install/
- # OPTIONAL: Relative directory to boot.ipxe used to
- # override boot script for specific clients
- set boot-dir boot/
- # REQUIRED: Absolute URL to the menu script, used by boot.ipxe
- # and commonly used at the end of simple override scripts
- # in ${boot-dir}.
- set menu-url ${boot-url}menu.ipxe
- # OPTIONAL: iSCSI server location and iSCSI IQNs
- # Must be specified as an IP, some clients have issues with name resolution
- # Initiator IQN is also calculated to use hostname, if present
- set iscsi-server ${nas_ip}
- set base-iqn iqn.2000-01.com.synology
- set base-iscsi iscsi:10.10.10.250:::1:iqn.2000-01.com.synology:ipxe.ESXI
- isset ${hostname} && set initiator-iqn ${base-iqn}:${hostname} || set initiator-iqn ${base-iqn}:${mac}
- # OPTIONAL: URL to report memtest results to
- set memtest-report-url http://boot.smidsrod.lan/memtest-report.cgi
- menu.ipxe的内容
- #!ipxe
- #下面这个3000是菜单等待时间代表3秒,
- set menu-timeout 3000
- set menu-default WINDOWS
- isset ${ip} || dhcp
- set initiator-iqn iqn.${product}:${mac:hexhyp}
- #set gateway ${next-server}
- :start
- menu iPXE Boot Menu
- item --gap -- --------------------------------- WIN --------------------------------
- item WINDOWS BOOT WINDOWS(ISCSI)
- item --gap -- ---------------------------- Advanced options ------------------------
- item --key p pe WEPE
- item Win8PEx64 Win8PEx64
- item --key s shell shell -- s
- item --key r reboot reboot computer -- r
- item --key x exit Exit iPXE and continue BIOS boot -- x
- item --gap --
- item --gap -- ------------------------------- systeminfo ---------------------------
- item --gap -- DHCP Server: ${dhcp-server}
- item --gap -- IP: ${ip}
- item --gap -- MAC: ${mac}
- item --gap -- netmask: ${netmask}
- item --gap -- Gateway: ${gateway}
- item --gap -- DNS: ${dns}
- item --gap -- UUID: ${uuid}
- item --gap -- initiator-iqn: ${initiator-iqn}
- choose --timeout ${menu-timeout} --default ${menu-default} selected
- goto ${selected}
- :reboot
- reboot
- :exit
- exit
- :shell
- shell
- goto start
- :WINDOWS
- chain /mac/${mac:hexhyp} || goto install
- :pe
- initrd http://${dhcp-server}/ipxe/WEPE.iso
- chain http://${dhcp-server}/ipxe/memdisk iso raw
- :Win8PEx64
- initrd http://${dhcp-server}/ipxe/Win8PEx64.iso
- chain http://${dhcp-server}/ipxe/memdisk iso raw
-
- :menu
- goto start
- :install
- echo -n ISCSI iqn: && read iqn
- prompt --key y Press 'y' to seting iqn username and password,any key Skip. || goto installmenu
- echo -n username: && read username
- echo -n password: && read password
- goto installmenu
- :installmenu
- set menu-timeout 10000
- menu install Menu
- item --gap -- --------------------------- INSTALL TO ISCSI --------------------------
- item boot(iscsi) BOOT form ISCSI
- item install(iscsi) Install windows to ISCSI
- item install(PE) Alternnate install mode(PE)
- item menu back Menu
- choose --timeout ${menu-timeout} selected
- goto ${selected}
- :boot(iscsi)
- sanboot iscsi:192.168.11.2::::${iqn}
- :install(iscsi)
- sanhook iscsi:192.168.11.2::::${iqn}
- exit
- :install(PE)
- sanhook iscsi:192.168.11.2::::${iqn}
- initrd http://${dhcp-server}/ipxe/Win8PEx64.iso
- chain http://${dhcp-server}/ipxe/memdisk iso raw
- 下面是mac地址的配置文件
- #!ipxe
- # Variables are specified in boot.ipxe.cfg
- # Some menu defaults
- # set menu-timeout 0 if no client-specific settings found 下面3句是设置默认超时时间10秒 默认项目是exit
- isset ${menu-timeout} || set menu-timeout 10000
- set submenu-timeout ${menu-timeout}
- isset ${menu-default} || set menu-default exit
- # Figure out if client is 64-bit capable
- cpuid --ext 29 && set arch x64 || set arch x86
- cpuid --ext 29 && set archl amd64 || set archl i386
- ###################### MAIN MENU ####################################
- :start
- menu iPXE boot menu for ${initiator-iqn}
- item --gap -- ------------------------- Operating systems ------------------------------
- item wepe Boot from WEPE
- item testpe Boot from testpe shibaile
- item WIN10LTSC Boot fromWIN10LTSC
- item TESTWIN10 Boot from TESTWIN10
- item TESTWIN102 Boot from TESTWIN102
- item WIN10ISO Boot from WIN10ISO
- item TEST2016 Boot from TEST2016
- item TESTESXI Boot from TESTESXI
- item --gap -- ------------------------- Tools and utilities ----------------------------
- item --key d menu-diag System tools...
- item --key i menu-install Installers...
- item --gap -- ------------------------- Advanced options -------------------------------
- item --key c config Configure settings
- item shell Drop to iPXE shell
- item reboot Reboot computer
- item
- item --key x exit Exit iPXE and continue BIOS boot
- choose --timeout ${menu-timeout} --default ${menu-default} selected || goto cancel
- set menu-timeout 0
- goto ${selected}
- :cancel
- echo You cancelled the menu, dropping you to a shell
- :shell
- echo Type 'exit' to get the back to the menu
- shell
- set menu-timeout 0
- set submenu-timeout 0
- goto start
- :failed
- echo Booting failed, dropping to shell
- goto shell
- :reboot
- reboot
- :exit
- exit
- :config
- config
- goto start
- :back
- set submenu-timeout 0
- clear submenu-default
- goto start
- ############ MAIN MENU ITEMS ############
- :myiscsi
- sanboot iscsi:192.168.11.2:::1:iqn.1991-05.com.microsoft:server1-target-e3v3-target
- goto start
- :installmyiscsi
- echo Starting windows10 installer for iqn.1991-05.com.microsoft:server1-target-e3v3-target
- set root-path iscsi:192.168.11.2:::1:iqn.1991-05.com.microsoft:server1-target-e3v3-target
- set base-url http://192.168.11.3/ipxe
- set keep-san 1
- sanhook ${root-path} || goto failed
- initrd ${base-url}/win10.iso
- chain memdisk iso raw || goto failed
- goto start
- :testpe
- echo Starting testpe
- sanhook iscsi:192.168.11.2:::0:iqn.1991-05.com.microsoft:server1-test-target
- echo ceshi
- set base-url http://192.168.11.2/WEPE
- initrd ${base-url}/WEPE.iso
- chain memdisk iso raw || goto failed
- goto start
- :wepe
- echo Starting wepe
- sanboot http://192.168.11.2/WEPE/WEPE.iso
- goto start
- :WIN10LTSC
- echo Starting WIN10LTSC
- sanboot http://192.168.11.2/WIN10LTSC/ltsc.iso
- goto start
- :TESTWIN10
- echo Starting TESTWIN10
- sanboot iscsi:192.168.11.2:::0:iqn.1991-05.com.microsoft:server1-test-target
- goto start
- :TESTWIN102
- echo Starting TESTWIN102
- sanboot http://192.168.11.2/WIN10LTSC/ltsc.iso \ iscsi:192.168.11.2:::0:iqn.1991-05.com.microsoft:server1-test-target
-
- goto start
- :WIN10ISO
- echo Starting WIN10ISO
- set base-url http://192.168.11.2/WIN10LTSC
- initrd ${base-url}/ltsc.iso
- chain memdisk iso raw || goto failed
- goto start
- :TEST2016
- echo TEST2016
- sanhook iscsi:192.168.11.2:::1:iqn.1991-05.com.microsoft:server1-test-target
- goto start
- :TESTESXI
- echo TESTESXI
- sanhook iscsi:192.168.11.2:::0:iqn.1991-05.com.microsoft:server1-test-target
- echo ceshi
- set base-url http://192.168.11.2/ESXI
- initrd ${base-url}/ESXI.iso
- chain memdisk iso raw || goto failed
- goto start
- :installfromwepe
- echo Starting install from wepe
- set root-path iscsi:192.168.11.2:::1:iqn.1991-05.com.microsoft:server1-target-e3v3-target
- set base-url http://192.168.11.3/ipxe
- set keep-san 1
- sanhook ${root-path} || goto failed
- initrd ${base-url}/WEPE.iso
- chain memdisk iso raw || goto failed
- goto start
- :windows
- echo Booting Windows from iSCSI for ${initiator-iqn}
- set netX/gateway ${iscsi-server}
- set root-path ${base-iscsi}:${hostname}.Windows
- set keep-san 1
- sanboot ${root-path} || goto failed
- goto start
- :ubuntu
- echo Booting Ubuntu from iSCSI for ${initiator-iqn}
- set root-path ${base-iscsi}:${hostname}.Ubuntu
- set keep-san 1
- sanboot ${root-path} || goto failed
- goto start
- :centos
- echo Booting CentOS from iSCSI for ${initiator-iqn}
- set root-path ${base-iscsi}:${hostname}.CentOS
- set keep-san 1
- sanboot ${root-path} || goto failed
- goto start
- :esxi
- echo Booting ESXi from iSCSI for iqn.2000-01.com.synology:ipxe.ESXI
- set root-path iscsi:10.10.10.250:::1:iqn.2000-01.com.synology:ipxe.ESXI
- set keep-san 1
- sanboot ${root-path} || goto failed
- goto start
- ###################### SYSTEM TOOL MENU #############################
- :menu-diag
- menu Diagnostic tools
- item memtest Memtest86+
- item winpe WinPE
- item
- item --key 0x08 back Back to top menu...
- iseq ${menu-default} menu-diag && isset ${submenu-default} && goto menu-diag-timed ||
- choose selected && goto ${selected} || goto start
- :menu-diag-timed
- choose --timeout ${submenu-timeout} --default ${submenu-default} selected && goto ${selected} || goto start
- :memtest
- set base-url http://${nas_ip}:88/tools
- initrd ${base-url}/memtest86_5.01.iso
- chain memdisk iso raw || goto failed
- goto start
- :winpe
- set base-url http://${nas_ip}:88/tools
- initrd ${base-url}/UQi_USBsys_10th.iso
- chain memdisk iso raw || goto failed
- goto start
- ############################ INSTALLER MENU #########################
- :menu-install
- menu Installers for ${initiator-iqn}
- item winpe-install Hook Windows iSCSI and boot WinPE for intallation
- item ubuntu-install Hook Ubuntu ${archl} iSCSI and install
- item centos-install Hook CentOS ${archl} iSCSI and install
- item esxi-install Hook ESXi ${archl} iSCSI and install
- item
- item --key 0x08 back Back to top menu...
- iseq ${menu-default} menu-install && isset ${submenu-default} && goto menu-install-timed ||
- choose selected && goto ${selected} || goto start
- :menu-install-timed
- choose --timeout ${submenu-timeout} --default ${submenu-default} selected && goto ${selected} || goto start
- :winpe-install
- echo Booting Windows PE ${arch} installer for ${initiator-iqn}
- echo (for installing Windows)
- set netX/gateway ${iscsi-server}
- set root-path ${base-iscsi}:${hostname}.Windows
- set keep-san 1
- echo sanhook start...
- sanhook ${root-path} || goto failed
- echo set base url starting
- set base-url http://${nas_ip}:88/Install/WinPE
- kernel wimboot
- initrd ${base-url}/x64/Boot/BCD bcd
- initrd ${base-url}/x64/Boot/boot.sdi boot.sdi
- initrd ${base-url}/x64/sources/boot.wim boot.wim
- boot || goto failed
- goto start
- :ubuntu-install
- echo Starting Ubuntu 16.04 ${archl} installer for ${initiator-iqn}
- set root-path ${base-iscsi}:${hostname}.Ubuntu
- cpuid --ext 29 && set arch amd64 || set arch x86
- set base-url ${sanboot-url}Ubuntu16/${arch}
- kernel ${base-url}/netboot/linux
- initrd ${base-url}/netboot/initrd.gz
- imgargs linux auto=true fb=false url=${base-url}/./preseed.cfg DEBCONF_DEBUG=5 netcfg/get_hostname=${hostname}.Ubuntu partman-iscsi/login/address=${iscsi-server} partman-iscsi/login/targets=${base-iqn}:${hostname}.Ubuntu
- boot || goto failed
- goto start
- :centos-install
- echo Starting CentOS 7 ${archl} installer for ${initiator-iqn}
- set root-path ${base-iscsi}:${hostname}.CentOS
- set base-url ${sanboot-url}CentOS/x86_64
- set keep-san 1
- sanhook ${root-path} || goto failed
- kernel ${base-url}/images/pxeboot/vmlinuz initrd=initrd.img repo=${base-url}
- initrd ${base-url}/images/pxeboot/initrd.img
- boot || goto failed
- goto start
- :esxi-install
- echo Starting ESXi 6.7 installer for iqn.2000-01.com.synology:ipxe.ESXI
- set root-path iscsi:10.10.10.250:::1:iqn.2000-01.com.synology:ipxe.ESXI
- set base-url http://10.10.10.250:88/Install/ESXI
- set keep-san 1
- sanhook ${root-path} || goto failed
- initrd ${base-url}/123.iso
- chain memdisk iso raw || goto failed
- goto start
- 其他资料
- https://www.jianshu.com/p/7c8b44d03edc
- https://blog.csdn.net/weixin_34346099/article/details/89671375 这两个配合着看应该可以让dnsmasq支持dhcp的相关参数
- 菜单编写范例 但是还是不知道默认文件名
- http://bbs.wuyou.net/forum.php?mod=viewthread&tid=402755&ordertype=1
- 关于uefi引导
- 首先要有一个esp分区,然后在这个分区里面放对应的文件就行
- 怎么创建ESP分区呢
- https://jingyan.baidu.com/article/046a7b3e76a8d0f9c27fa9af.html
- ESP分区一般都是FAT32格式
- 然后WIN10默认的引导文件是efi\boot\Bootx64.efi
- 用bcdedit命令编辑这个文件
- https://www.cnblogs.com/fatt/p/4397615.html
- bcdedit /store F:\EFI\Microsoft\Boot\bootmgfw.efi E:\windows /l zh-cn
- 不知道为什么这里提示说不是注册表文件,但是我明明看见默认的文件就是这个啊
- bcdboot F:\windows /l zh-cn
- 测试sanhook iso
- 和内存超过iso大小
- 内存大于 initrd iso 失败
- 只用iso 也失败,提示没有驱动,估计是ISO没有加载完毕
- initrd BCD 等3个文件也失败,估计也是文件缺少
- 研究怎么把完整的iso下载下来
- https://github.com/zwj4031/ipxeboot
- 我怀疑是initrd下载下来的文件 memdisk装不下 应该不是,memdisk是自适应的 而且看速度也不会这么快,应该就是限制了大小,要看看sanboot iso的大小限制
- 下面可以学习自建一个
- https://baike.baidu.com/item/initrd/3239796?fr=aladdin
- RDSIZE=4000
- BLKSIZE=1024 字节
- # Create an emptyramdisk image
- dd if=/dev/zero of=ramdisk.img bs=1024 count=10
- B站的那个UP主的网站是
- https://www.vediotalk.com/?p=3858
- 另外一篇教程
- https://blog.csdn.net/beckdon/article/details/41015597
- B站另外一个WIN7的教程是先把WIN7装在本地硬盘,然后把硬盘对拷的服务器上
- 不知道他用带网卡的PE是做什么用的? 还是我没看仔细?
- 装玩系统以后一定要开启ISCSI服务,这样把硬盘对拷到服务器上的时候启动系统才会自动连接(是否需要?)
- 这个教程用dnsmasq分了bios和uefi
- https://www.haiyun.me/archives/1384.html
- 然后明天研究启动方式
- 传统的bios就是initrd iso然后chain memdisk raw iso
- uefi的就可以直接sanboot iso
复制代码
|
|