PXE

准备配置文件

建立TFTP

yum install syslinux
cp /usr/share/syslinux/pxelinux.0 /lustre/home/admin/pxe/tftp
cp /usr/share/syslinux/vesamenu.c32 /lustre/home/admin/pxe/tftp
mkdir /lustre/home/admin/pxe/tftp/pxelinux.cfg
mkdir /lustre/home/admin/pxe/tftp/pxelinux.cfg/c76
cp /media/cdrom/isolinux/isolinux.cfg /lustre/home/admin/pxe/tftp/pxelinux.cfg/default
cp /media/cdrom/isolinux/vmlinuz /lustre/home/admin/pxe/tftp/c76
cp /media/cdrom/isolinux/initrd.img /lustre/home/admin/pxe/tftp/c76
vi /lustre/home/admin/pxe/vsftp/ks/ks76.cfg

可用的一个default pxe配置文件是

$ cat default
default vesamenu.c32
timeout 1

label linux
  menu label ^Install CentOS 7.6
  menu default
  kernel c76/vmlinuz
  append initrd=c76/initrd.img ks=ftp://192.168.86.2/ks/ks76.cfg quiet
#  append initrd=c76/initrd.img inst.stage2=ftp://192.168.86.2/c76 quiet

可用的ks76.cfg是

$ cat ks76.cfg
install
rootpw --plaintext 111111
url --url="ftp://192.168.86.2/c76"
auth  --useshadow  --passalgo=sha512
text
selinux --disabled
skipx
services --enabled="chronyd"
firewall --disabled
reboot
timezone Asia/Shanghai --isUtc
bootloader --location=mbr --append="net.ifnames=0 biosdevname=1" --location=mbr
zerombr
clearpart --drives=sda --all
#clearpart --none
part / --fstype="ext4" --grow
services --disabled=NetworkManager-wait-online,postfix,auditd,chronyd

%packages
@^minimal
@core
chrony
-iw*
-alsa*
-*firewall*
%end

%addon com_redhat_kdump --disable
%end

建立DHCP

主机上配置个地址,以免误伤

ip address replace 192.168.86.2/24 dev eth2
touch /lustre/home/admin/pxe/dhcp/dhcpleasefile.log

比较好用的一个dhcpd配置文件是

$ cat dhcpd.conf 
option domain-name "PXE";
local-address 192.168.86.2;
#option domain-name-servers 8.8.8.8,8.8.4.4;
#deny unknown-clients;

#default-lease-time 600;
#max-lease-time 7200;

subnet 192.168.86.0 netmask 255.255.255.0 {
  allow booting;
  allow bootp;
  next-server 192.168.86.2;
  filename "/pxelinux.0";
  range dynamic-bootp 192.168.86.3 192.168.86.254;
# option broadcast-address 192.168.86.255;
# option routers 192.168.86.2;
}

### Computes ###
host compute1 {
  hardware ethernet 88:88:88:88:88:01;
  fixed-address 192.168.86.3;
  option host-name "c1";
}
host compute2 {
  hardware ethernet 88:88:88:88:88:02;
  fixed-address 192.168.86.4;
  option host-name "c1";
}
host compute3 {
  hardware ethernet 88:88:88:88:88:03;
  fixed-address 192.168.86.5;
  option host-name "c3";
}

参考资料: http://daemon-notes.com/articles/network/isc-dhcpd/dhcpd.conf

建立FTP

mount /vmshare/CentOS-7-x86_64-Everything-1810.iso /lustre/home/admin/pxe/vsftp/c76
cp -r /media/cdrom /lustre/home/admin/pxe/vsftp/c76

开搞

[admin@localhost singularity]$ \
sudo ip address replace 192.168.86.2/24 dev eth2
screen -XS pxe quit
docker rm \
$(docker stop \
$(docker ps -a -q --filter ancestor=aaii/centos:1810-httpd-dhcp-ftp-tftp \
--format="{{.ID}}"))

screen -dmS pxe
screen -XS pxe exec \

sudo docker run -ti --network host \
-v /lustre/home/admin/pxe/http:/var/www/html \
-v /lustre/home/admin/pxe/tftp:/var/lib/tftpboot \
-v /lustre/home/admin/pxe/vsftp/:/var/ftp \
-v /lustre/home/admin/pxe/dhcp/:/etc/dhcp \
aaii/centos:1810-httpd-dhcp-ftp-tftp bash -c \
" dhcpd -4 eth2 \
-tf /etc/dhcp/dhcptracefile.log \
-cf /etc/dhcp/dhcpd.conf \
-lf /etc/dhcp/dhcpleasefile.log && \
vsftpd -oanon_upload_enable=YES -ono_anon_password=YES && \
in.tftpd -v -4 -c -s /var/lib/tftpboot -L "

你可能感兴趣的:(PXE)