PXE-安装esxi
PXE-安装esxi
搭建pxe服务器,使用ubuntu20.04
只适用于UEFI启动方式,pxe服务器为192.168.10.1。
安装tftp,http,dhcp服务器
root@ubuntu:/etc/apt# apt install tftpd-hpa isc-dhcp-server apache2
配置dhcp服务器,这里的bootx64.efi为tftp工作目录中的启动引导文件
ubuntu@ubuntu:~$ sudo egrep -v '^$|^#' /etc/dhcp/dhcpd.conf
[sudo] password for ubuntu:
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.10 192.168.10.20;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.10.255;
default-lease-time 600;
max-lease-time 7200;
filename "bootx64.efi";
server-name "192.168.10.1";
}
这里我有两张网卡,指定为ens37开启dhcp服务
ubuntu@ubuntu:~$ sudo cat /etc/default/isc-dhcp-server
# Defaults for isc-dhcp-server (sourced by /etc/init.d/isc-dhcp-server)
# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
#DHCPDv4_CONF=/etc/dhcp/dhcpd.conf
#DHCPDv6_CONF=/etc/dhcp/dhcpd6.conf
# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
#DHCPDv4_PID=/var/run/dhcpd.pid
#DHCPDv6_PID=/var/run/dhcpd6.pid
# Additional options to start dhcpd with.
# Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=""
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACESv4="ens37"
INTERFACESv6=""
准备boot.cfg文件
tftp 默认工作路径为/srv/tftp
ubuntu@ubuntu:~$ cat /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftp"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure"
挂载光盘镜像至SRV/TFTP/ESXI
ubuntu@ubuntu:~$ sudo mkdir /srv/tftp/esxi
ubuntu@ubuntu:~$ sudo mount /home/ubuntu/VMware-VMvisor-Installer-7.0U3n-21930508.x86_64.iso /srv/tftp/esxi/
mount: /srv/tftp/esxi: WARNING: device write-protected, mounted read-only.
ubuntu@ubuntu:~$
拷贝EFI启动文件
ubuntu@ubuntu:~$ ll /srv/tftp/
total 14
drwxr-xr-x 3 root nogroup 4096 Mar 27 08:33 ./
drwxr-xr-x 3 root root 4096 Mar 27 05:14 ../
dr-xr-xr-x 1 root root 6144 Jun 15 2023 esxi/
ubuntu@ubuntu:~$ sudo cp /srv/tftp/esxi/efi/boot/* /srv/tftp/
ubuntu@ubuntu:~$ ll /srv/tftp/
total 410
drwxr-xr-x 3 root nogroup 4096 Mar 27 08:37 ./
drwxr-xr-x 3 root root 4096 Mar 27 05:14 ../
-r-xr-xr-x 1 root root 1742 Mar 27 08:37 boot.cfg*
-r-xr-xr-x 1 root root 206480 Mar 27 08:37 bootx64.efi*
-r-xr-xr-x 1 root root 75216 Mar 27 08:37 crypto64.efi*
dr-xr-xr-x 1 root root 6144 Jun 15 2023 esxi/
-r-xr-xr-x 1 root root 111472 Mar 27 08:37 safeboot.efi*
编辑boot.cfg #编辑模式,:%s/\///g
ubuntu@ubuntu:~$ cat /srv/tftp/boot.cfg
bootstate=0
title=Loading ESXi installer
timeout=5
prefix=
kernel=/b.b00
kernelopt=runweasel cdromBoot
modules=/jumpstrt.gz --- /useropts.gz --- /features.gz --- /k.b00 --- /uc_intel.b00 --- /uc_amd.b00 --- /uc_hygon.b00 --- /procfs.b00 --- /vmx.v00 --- /vim.v00 --- /tpm.v00 --- /sb.v00 --- /s.v00 --- /atlantic.v00 --- /bnxtnet.v00 --- /bnxtroce.v00 --- /brcmfcoe.v00 --- /elxiscsi.v00 --- /elxnet.v00 --- /i40en.v00 --- /iavmd.v00 --- /icen.v00 --- /igbn.v00 --- /ionic_en.v00 --- /irdman.v00 --- /iser.v00 --- /ixgben.v00 --- /lpfc.v00 --- /lpnic.v00 --- /lsi_mr3.v00 --- /lsi_msgp.v00 --- /lsi_msgp.v01 --- /lsi_msgp.v02 --- /mtip32xx.v00 --- /ne1000.v00 --- /nenic.v00 --- /nfnic.v00 --- /nhpsa.v00 --- /nmlx4_co.v00 --- /nmlx4_en.v00 --- /nmlx4_rd.v00 --- /nmlx5_co.v00 --- /nmlx5_rd.v00 --- /ntg3.v00 --- /nvme_pci.v00 --- /nvmerdma.v00 --- /nvmetcp.v00 --- /nvmxnet3.v00 --- /nvmxnet3.v01 --- /pvscsi.v00 --- /qcnic.v00 --- /qedentv.v00 --- /qedrntv.v00 --- /qfle3.v00 --- /qfle3f.v00 --- /qfle3i.v00 --- /qflge.v00 --- /rste.v00 --- /sfvmk.v00 --- /smartpqi.v00 --- /vmkata.v00 --- /vmkfcoe.v00 --- /vmkusb.v00 --- /vmw_ahci.v00 --- /bmcal.v00 --- /crx.v00 --- /elx_esx_.v00 --- /btldr.v00 --- /esx_dvfi.v00 --- /esx_ui.v00 --- /esxupdt.v00 --- /tpmesxup.v00 --- /weaselin.v00 --- /esxio_co.v00 --- /loadesx.v00 --- /lsuv2_hp.v00 --- /lsuv2_in.v00 --- /lsuv2_ls.v00 --- /lsuv2_nv.v00 --- /lsuv2_oe.v00 --- /lsuv2_oe.v01 --- /lsuv2_oe.v02 --- /lsuv2_sm.v00 --- /native_m.v00 --- /qlnative.v00 --- /trx.v00 --- /vdfs.v00 --- /vmware_e.v00 --- /vsan.v00 --- /vsanheal.v00 --- /vsanmgmt.v00 --- /tools.t00 --- /xorg.v00 --- /gc.v00 --- /imgdb.tgz --- /basemisc.tgz --- /resvibs.tgz --- /imgpayld.tgz
build=7.0.3-0.95.21930508
updated=0
ubuntu@ubuntu:~$ sudo vi /srv/tftp/boot.cfg
ubuntu@ubuntu:~$ more /srv/tftp/boot.cfg
bootstate=0
title=Loading ESXi installer
timeout=5
prefix=esxi #tftp服务器下的镜像存放目录
kernel=b.b00
kernelopt=runweasel #删除cdrom
modules=jumpstrt.gz --- useropts.gz --- features.gz --- k.b00 --- uc_intel.b00 --- uc_amd.b00 --- uc_hygon.b00 --- procfs.b00 --- vmx.v00 --- vim
.v00 --- tpm.v00 --- sb.v00 --- s.v00 --- atlantic.v00 --- bnxtnet.v00 --- bnxtroce.v00 --- brcmfcoe.v00 --- elxiscsi.v00 --- elxnet.v00 --- i40e
n.v00 --- iavmd.v00 --- icen.v00 --- igbn.v00 --- ionic_en.v00 --- irdman.v00 --- iser.v00 --- ixgben.v00 --- lpfc.v00 --- lpnic.v00 --- lsi_mr3.
v00 --- lsi_msgp.v00 --- lsi_msgp.v01 --- lsi_msgp.v02 --- mtip32xx.v00 --- ne1000.v00 --- nenic.v00 --- nfnic.v00 --- nhpsa.v00 --- nmlx4_co.v00
--- nmlx4_en.v00 --- nmlx4_rd.v00 --- nmlx5_co.v00 --- nmlx5_rd.v00 --- ntg3.v00 --- nvme_pci.v00 --- nvmerdma.v00 --- nvmetcp.v00 --- nvmxnet3.
v00 --- nvmxnet3.v01 --- pvscsi.v00 --- qcnic.v00 --- qedentv.v00 --- qedrntv.v00 --- qfle3.v00 --- qfle3f.v00 --- qfle3i.v00 --- qflge.v00 --- r
ste.v00 --- sfvmk.v00 --- smartpqi.v00 --- vmkata.v00 --- vmkfcoe.v00 --- vmkusb.v00 --- vmw_ahci.v00 --- bmcal.v00 --- crx.v00 --- elx_esx_.v00
--- btldr.v00 --- esx_dvfi.v00 --- esx_ui.v00 --- esxupdt.v00 --- tpmesxup.v00 --- weaselin.v00 --- esxio_co.v00 --- loadesx.v00 --- lsuv2_hp.v00
--- lsuv2_in.v00 --- lsuv2_ls.v00 --- lsuv2_nv.v00 --- lsuv2_oe.v00 --- lsuv2_oe.v01 --- lsuv2_oe.v02 --- lsuv2_sm.v00 --- native_m.v00 --- qlna
tive.v00 --- trx.v00 --- vdfs.v00 --- vmware_e.v00 --- vsan.v00 --- vsanheal.v00 --- vsanmgmt.v00 --- tools.t00 --- xorg.v00 --- gc.v00 --- imgdb
.tgz --- basemisc.tgz --- resvibs.tgz --- imgpayld.tgz
build=7.0.3-0.95.21930508
updated=0
ubuntu@ubuntu:~$
开启一个测试机测试,可以安装,但是还是要配何键盘接收许可,手动安装。
已经自动获取ip地址
ubuntu@ubuntu:/srv/tftp/esxi$ sudo dhcp-lease-list
To get manufacturer names please download http://standards.ieee.org/regauth/oui/oui.txt to /usr/local/etc/oui.txt
Reading leases from /var/lib/dhcp/dhcpd.leases
MAC IP hostname valid until manufacturer
===============================================================================================
00:0c:29:a5:37:3f 192.168.10.11 -NA- 2024-03-27 08:54:54 -NA-
00:50:56:c0:00:02 192.168.10.10 WIN-23MV2JBD2R 2024-03-27 08:55:14 -NA-
显然不是我们需要的方式
创建一个kickstart.cfg文件,使用自动安装 kickstart写的比较简单。有需要自行改
ubuntu@ubuntu:~$ sudo vi /var/www/html/ks.cfg
[sudo] password for ubuntu:
ubuntu@ubuntu:~$ sudo cat /var/www/html/ks.cfg
accepteula
install --firstdisk --overwritevmfs
rootpw redhat123
reboot
network --bootproto=static --ip=192.168.10.11 --netmask=255.255.255.0 --gateway=192.168.10.254 --hostname=esxi-01 --nameserver=114.114.114.114 --addvmportgroup=1
安装完毕的ESXI系统下面/etc/vmware/weasel自动生成一个ks.cfg。可以改改拿来用
参考:
vmaccepteula
install --firstdisk --overwritevmfs --novmfsondisk
network --bootproto=static --ip=192.168.0.10 --netmask=255.255.255.0 --gateway=192.168.0.1 --hostname=esx1.virten.lab --nameserver=192.168.0.1
rootpw VMware1!
keyboard German
reboot
%firstboot --interpreter=busybox
# Enable SSH
vim-cmd hostsvc/enable_ssh
vim-cmd hostsvc/start_ssh
# Enable ESXi Shell
vim-cmd hostsvc/enable_esx_shell
vim-cmd hostsvc/start_esx_shell
# Suppress Shell warning
esxcli system settings advanced set -o /UserVars/SuppressShellWarning -i 1
# NTP
esxcli system ntp set -s de.pool.ntp.org
esxcli system ntp set -e 1
https://github.com/fgrehl/virten-scripts/blob/master/bash/esxi_ks_injector/KS-TEMPLATE.CFG
tftp
ubuntu@ubuntu:~$ sudo vi /srv/tftp/boot.cfg
ubuntu@ubuntu:~$ curl http://192.168.10.1/ks.cfg
accepteula
install --firstdisk --overwritevmfs
rootpw redhat@123
reboot
network --bootproto=static --ip=192.168.10.11 --netmask=255.255.255.0 --gateway=192.168.10.254 --hostname=esxi-01 --nameserver=114.114.114.114 --addvmportgroup=1
ubuntu@ubuntu:~$ more /srv/tftp/boot.cfg
bootstate=0
title=Loading ESXi installer
timeout=5
prefix=esxi
kernel=b.b00
kernelopt=ks=http://192.168.10.1/ks.cfg #####这里
modules=jumpstrt.gz --- useropts.gz --- features.gz --- k.b00 --- uc_intel.b00 --- uc_amd.b00 --- uc_hygon.b00 --- procfs.b00 --- vmx.v00 --- vim
.v00 --- tpm.v00 --- sb.v00 --- s.v00 --- atlantic.v00 --- bnxtnet.v00 --- bnxtroce.v00 --- brcmfcoe.v00 --- elxiscsi.v00 --- elxnet.v00 --- i40e
n.v00 --- iavmd.v00 --- icen.v00 --- igbn.v00 --- ionic_en.v00 --- irdman.v00 --- iser.v00 --- ixgben.v00 --- lpfc.v00 --- lpnic.v00 --- lsi_mr3.
v00 --- lsi_msgp.v00 --- lsi_msgp.v01 --- lsi_msgp.v02 --- mtip32xx.v00 --- ne1000.v00 --- nenic.v00 --- nfnic.v00 --- nhpsa.v00 --- nmlx4_co.v00
--- nmlx4_en.v00 --- nmlx4_rd.v00 --- nmlx5_co.v00 --- nmlx5_rd.v00 --- ntg3.v00 --- nvme_pci.v00 --- nvmerdma.v00 --- nvmetcp.v00 --- nvmxnet3.
v00 --- nvmxnet3.v01 --- pvscsi.v00 --- qcnic.v00 --- qedentv.v00 --- qedrntv.v00 --- qfle3.v00 --- qfle3f.v00 --- qfle3i.v00 --- qflge.v00 --- r
ste.v00 --- sfvmk.v00 --- smartpqi.v00 --- vmkata.v00 --- vmkfcoe.v00 --- vmkusb.v00 --- vmw_ahci.v00 --- bmcal.v00 --- crx.v00 --- elx_esx_.v00
--- btldr.v00 --- esx_dvfi.v00 --- esx_ui.v00 --- esxupdt.v00 --- tpmesxup.v00 --- weaselin.v00 --- esxio_co.v00 --- loadesx.v00 --- lsuv2_hp.v00
--- lsuv2_in.v00 --- lsuv2_ls.v00 --- lsuv2_nv.v00 --- lsuv2_oe.v00 --- lsuv2_oe.v01 --- lsuv2_oe.v02 --- lsuv2_sm.v00 --- native_m.v00 --- qlna
tive.v00 --- trx.v00 --- vdfs.v00 --- vmware_e.v00 --- vsan.v00 --- vsanheal.v00 --- vsanmgmt.v00 --- tools.t00 --- xorg.v00 --- gc.v00 --- imgdb
.tgz --- basemisc.tgz --- resvibs.tgz --- imgpayld.tgz
build=7.0.3-0.95.21930508
updated=0
重启服务,客户机再来一次重新开机
ubuntu@ubuntu:~$ sudo systemctl restart apache2
ubuntu@ubuntu:~$ sudo systemctl restart isc-dhcp-server.service
ubuntu@ubuntu:~$ sudo systemctl restart tftpd-hpa.service
ubuntu@ubuntu:~$ sudo systemctl status tftpd-hpa.service
● tftpd-hpa.service - LSB: HPA's tftp server
Loaded: loaded (/etc/init.d/tftpd-hpa; generated)
Active: active (running) since Wed 2024-03-27 09:23:29 UTC; 5s ago
Docs: man:systemd-sysv-generator(8)
Process: 10156 ExecStart=/etc/init.d/tftpd-hpa start (code=exited, status=0/SUCCESS)
Tasks: 1 (limit: 4557)
Memory: 1.0M
CGroup: /system.slice/tftpd-hpa.service
└─10184 /usr/sbin/in.tftpd --listen --user tftp --address :69 --secure /srv/tftp
Mar 27 09:23:29 ubuntu systemd[1]: Starting LSB: HPA's tftp server...
Mar 27 09:23:29 ubuntu tftpd-hpa[10156]: * Starting HPA's tftpd in.tftpd
Mar 27 09:23:29 ubuntu tftpd-hpa[10156]: ...done.
Mar 27 09:23:29 ubuntu systemd[1]: Started LSB: HPA's tftp server.
ubuntu@ubuntu:~$ sudo systemctl status isc-dhcp-server.service
● isc-dhcp-server.service - ISC DHCP IPv4 server
Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2024-03-27 09:23:22 UTC; 22s ago
Docs: man:dhcpd(8)
Main PID: 10087 (dhcpd)
Tasks: 4 (limit: 4557)
Memory: 4.9M
CGroup: /system.slice/isc-dhcp-server.service
└─10087 dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf /etc/dhcp/dhcpd.conf ens37
Mar 27 09:23:23 ubuntu dhcpd[10087]: PID file: /run/dhcp-server/dhcpd.pid
Mar 27 09:23:23 ubuntu dhcpd[10087]: Wrote 2 leases to leases file.
Mar 27 09:23:23 ubuntu sh[10087]: Wrote 2 leases to leases file.
Mar 27 09:23:23 ubuntu dhcpd[10087]: Listening on LPF/ens37/00:0c:29:21:b9:d7/192.168.10.0/24
Mar 27 09:23:23 ubuntu sh[10087]: Listening on LPF/ens37/00:0c:29:21:b9:d7/192.168.10.0/24
Mar 27 09:23:23 ubuntu dhcpd[10087]: Sending on LPF/ens37/00:0c:29:21:b9:d7/192.168.10.0/24
Mar 27 09:23:23 ubuntu sh[10087]: Sending on LPF/ens37/00:0c:29:21:b9:d7/192.168.10.0/24
Mar 27 09:23:23 ubuntu dhcpd[10087]: Sending on Socket/fallback/fallback-net
Mar 27 09:23:23 ubuntu sh[10087]: Sending on Socket/fallback/fallback-net
Mar 27 09:23:23 ubuntu dhcpd[10087]: Server starting service.
ubuntu@ubuntu:~$ sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2024-03-27 09:23:10 UTC; 41s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 9940 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 9957 (apache2)
Tasks: 55 (limit: 4557)
Memory: 5.6M
CGroup: /system.slice/apache2.service
├─9957 /usr/sbin/apache2 -k start
├─9958 /usr/sbin/apache2 -k start
└─9959 /usr/sbin/apache2 -k start
Mar 27 09:23:10 ubuntu systemd[1]: Starting The Apache HTTP Server...
Mar 27 09:23:10 ubuntu apachectl[9948]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1>
Mar 27 09:23:10 ubuntu systemd[1]: Started The Apache HTTP Server.
ubuntu@ubuntu:~$
验证:
本文链接:
/archives/1711522795913
版权声明:
本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自
Emporer-Linux!
喜欢就支持一下吧