- Cấu trúc thư mục pxe server
/pxeboot/config/
/pxeboot/firmware/
/pxeboot/os-images
$ mkdir -pv /pxeboot/{config,firmware,os-images}
- Download source code IPXE
$ apt install build-essential liblzma-dev isolinux git
$ git clone GitHub – ipxe/ipxe: iPXE network bootloader ->ipxe directory
$ cd ipxe/src
- Create bootconfig.ipxe
$ vi bootconfig.ipxe
cấu hình như sau:
#!ipxe
dhcp
chain tfpt://10.0.99.5/config/boot.ipxe
- Compile iPXE BIOS and UEFI firmwares and embed the bootconfig.ipxe
$ make bin/ipxe.pxe bin/undionly.kpxe bin/undionly.kkpxe bin/undionly.kkkpxe bin-x86_64-efi/ipxe.efi EMBED=bootconfig.ipxe
- Copying the Compiled iPXE Firmwares to /pxeboot/firmware Directory
$ sudo cp -v bin/{ipxe.pxe,undionly.kpxe,undionly.kkpxe,undionly.kkkpxe} bin-x86_64-efi/ipxe.efi /pxeboot/firmware/
- Check cấu trúc thư mục pxeboot
$ tree /pxboot
- Stop dịch vụ systemd-resolved
$ apt install dnsmasq -y
**lỗi: already use port 53
$ systemctl stop systemd-resolved
$ systemctl disable systemd-resolved
$ unlink /etc/resolv.conf
$ nano /etc/resolv.conf
cấu hình như sau:
nameserver 127.0.0.1
nameserver 8.8.8.8
nameserver 1.1.1.1
- Installing and Configuring a DHCP and TFTP Server on pxe server
$ sudo mv -v /etc/dnsmasq.conf /etc/dnsmasq.conf.backup
$ sudo nano /etc/dnsmasq.conf
cấu hình như sau:
“””
interface=ens192
bind-interfaces
domain=pxe.local
dhcp-range=ens192,10.0.99.10,10.0.99.250,255.255.254.0,8h
dhcp-option=option:router,10.0.99.1
dhcp-option=option:dns-server,8.8.4.4
dhcp-option=option:dns-server,8.8.8.8
enable-tftp
tftp-root=/pxeboot
# boot config for BIOS systems
dhcp-match=set:bios-x86,option:client-arch,0
dhcp-boot=tag:bios-x86,firmware/ipxe.pxe
# boot config for UEFI systems
dhcp-match=set:efi-x86_64,option:client-arch,7
dhcp-match=set:efi-x86_64,option:client-arch,9
dhcp-boot=tag:efi-x86_64,firmware/ipxe.efi
“”
$ systemctl restart dnsmasq
$ systemctl status dnsmasq
- Installing and Configuring NFS Server
Ubuntu dùng casper boot vào mode Live installation. casper chỉ support PXE boot qua giao thức NFS.
$ sudo apt install nfs-kernel-server -y
- Cấu hình nfs server
$ sudo nano /etc/exports
cấu hình như sau:
thêm vào dòng cuối
/pxeboot *(ro,sync,no_wdelay,insecure_locks,no_root_squash,insecure,no_subtree_check)$ sudo exportfs -av
- Download file iso hệ điều hành
$ cd ~
tải file iso ubuntu
wget http://https://releases.ubuntu.com/20.04.6/ubuntu-20.04.6-live-server-amd64.iso
tải file iso centos 7
wget http://mirror.viettelcloud.vn/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-DVD-2009.iso
- Mount file iso
$ mount -o loop ubuntu-20.04.6-live-server-amd64.iso /mnt
$ mkdir -pv /pxeboot/os-images/ubuntu-20.04-server
$ rsync -avz /mnt/ /pxeboot/os-images/ubuntu-20.04-server$ umount /mnt
$ rm -rf ubuntu-20.04.6-live-server-amd64.iso
tương tự với centos-7 và ubuntu 22.04
- Cài apache server: tốc độ download nhanh hơn so với NFS,tftp
apt install apache2 -y
ln -s /pxeboot/os-images/ /var/www/html/
systemctl enable apache2
systemctl restart apache2
- Cấu hình ipxe boot
$ nano /pxeboot/config/boot.ipxe
cấu hình như sau:
#!ipxe
set server_ip 10.0.99.5
set root_path /pxeboot
menu Select an OS to boot
item ubuntu-20.04-server Install Ubuntu server 20.04 LTS
item ubuntu-22.04-server Install Ubuntu server 22.04 LTS
item centos-7 Install Centos 7
choose –default exit –timeout 1000000 option && goto ${option}
:ubuntu-20.04-server
set os_root os-images/ubuntu-20.04-server
kernel tftp://${server_ip}/${os_root}/casper/vmlinuz
initrd tftp://${server_ip}/${os_root}/casper/initrd
imgargs vmlinuz initrd=initrd boot=casper maybe-ubiquity netboot=nfs ip=dhcp nfsroot=${server_ip}:${root_path}/${os_root} quiet splash fsck.mode=skip —
boot
:ubuntu-22.04-server
set os_root os-images/ubuntu-22.04-server
kernel tftp://${server_ip}/${os_root}/casper/vmlinuz
initrd tftp://${server_ip}/${os_root}/casper/initrd
imgargs vmlinuz initrd=initrd boot=casper maybe-ubiquity netboot=nfs ip=dhcp nfsroot=${server_ip}:${root_path}/${os_root} quiet splash fsck.mode=skip —
boot
:centos-7
set os_root os-images/centos-7
kernel http://${server_ip}:80/${os_root}/isolinux/vmlinuz
initrd http://${server_ip}:80/${os_root}/isolinux/initrd.img
imgargs vmlinuz initrd=initrd.img ip=dhcp inst.repo=nfs:${server_ip}:${root_path}/${os_root}
boot
- Thiết lập cho các hệ điều hành windows
wget ” https://software.download.prss.microsoft.com/dbazure/Win10_22H2_English_x64v1.iso?t=eff74b84-4478-4013-a59d-547de064ae10&P1=1709001589&P2=601&P3=2&P4=hSMt9C%2bjgIbgzXabXgZfWZd8bV%2f0tOsFTkDu85kOpAiofEaIhuGEJPG1pOysD7QDD0fIp4cMfTmUqVlrewE4iIWOFpZHUcDwiLitXOfMGAYcBJj%2bSLnzDZEjslT139dSGtFAB9Rq0E5lL61JDz0OI4VJ889Kfxl%2fwLztz%2ftglrld8jke3drWFFDIHahPx%2boFkTYWrJyt3V2986rw5J4r85%2bz17bm7AHIoprmoXNHX20UYsVZM1ci268vMDkUOQap4Fa6iMxiJ1GWyi7Yk3xlOIL%2fBL9nRVJkLcBUKSuR%2bAXFVdxovbz%2fEGJ2hdDH6rkEuZbbT0IxWBFUFSgIBfyAOQ%3d%3d ”
mount win10.iso /mnt/
mkdir /pxeboot/os-images/win10/
rsync -avz /mnt/ /pxeboot/os-images/win10/
umount /mnt/
- Tải phần mềm wimboot
wget “https://github.com/ipxe/wimboot/archive/refs/tags/v2.7.6.zip”
unzip
cp wimboot-2.7.6.zip /pxeboot/os-images/
- Cấu hình boot win10
:window10
set os_root os-images/win10
kernel http://${server_ip}:80/os-images/wimboot/wimboot
initrd http://${server_ip}:80/${os_root}/boot/bcd BCD
initrd http://${server_ip}:80/${os_root}/boot/boot.sdi boot.sdi
initrd http://${server_ip}:80/${os_root}/sources/boot.wim boot.wim
boot
- Thiết lập cài vmware
mount vmware-7.03.iso /mnt/
mkdir /pxeboot/os-images/vmware-7/
rsync -avz /mnt /pxeboot/os-images/vmware-7/
- Cấu hình file boot.cfg của vmware
chạy lệnh “sed -i ‘s|/||g’ /pxeboot/os-images/vmware-7/efi/boot/boot.cfg”
vi /pxeboot/os-images/vmware-7.03/efi/boot/boot.cfg
sửa cấu hình cho prefix=http://10.0.99.5:80/os-images/vmware-7/
set up kết thúc
- Thêm cấu hình boot vmware
:vmware-7
set os_root os-images/vmware-7
kernel http://${server_ip}:80/${os_root}/efi/boot/bootx64.efi
initrd http://${server_ip}:80/${os_root}/efi/boot/boot.cfg
imgargs bootx64.efi boot.cfg
boot
- Cấu hình file boot.ipxe hoàn chỉnh với ubuntu 20.04, ubuntu 22.04, vmware-7, win 10:
#!ipxe
set server_ip 10.0.99.5
set root_path /pxeboot
menu Select an OS to boot
item ubuntu-20.04-server Install Ubuntu server 20.04 LTS
item ubuntu-22.04-server Install Ubuntu server 22.04 LTS
item centos-7 Install Centos 7
item vmware-7 Install vmware-7
item window10 Install window10
choose –default exit –timeout 1000000 option && goto ${option}
:ubuntu-20.04-server
set os_root os-images/ubuntu-20.04-server
kernel tftp://${server_ip}/${os_root}/casper/vmlinuz
initrd tftp://${server_ip}/${os_root}/casper/initrd
imgargs vmlinuz initrd=initrd boot=casper maybe-ubiquity netboot=nfs ip=dhcp nfsroot=${server_ip}:${root_path}/${os_root} quiet splash fsck.mode=skip —
boot
:ubuntu-22.04-server
set os_root os-images/ubuntu-22.04-server
kernel tftp://${server_ip}/${os_root}/casper/vmlinuz
initrd tftp://${server_ip}/${os_root}/casper/initrd
imgargs vmlinuz initrd=initrd boot=casper maybe-ubiquity netboot=nfs ip=dhcp nfsroot=${server_ip}:${root_path}/${os_root} quiet splash fsck.mode=skip —
boot
:centos-7
set os_root os-images/centos-7
kernel http://${server_ip}:80/${os_root}/isolinux/vmlinuz
initrd http://${server_ip}:80/${os_root}/isolinux/initrd.img
imgargs vmlinuz initrd=initrd.img ip=dhcp inst.repo=nfs:${server_ip}:${root_path}/${os_root}
boot
:vmware-7
set os_root os-images/vmware-7
kernel http://${server_ip}:80/${os_root}/efi/boot/bootx64.efi
initrd http://${server_ip}:80/${os_root}/efi/boot/boot.cfg
imgargs bootx64.efi boot.cfg
boot
:window10
set os_root os-images/win10
kernel http://${server_ip}:80/os-images/wimboot/wimboot
initrd http://${server_ip}:80/${os_root}/boot/bcd BCD
initrd http://${server_ip}:80/${os_root}/boot/boot.sdi boot.sdi
initrd http://${server_ip}:80/${os_root}/sources/boot.wim boot.wim
boot
- Test
- tài liệu liên quan
Configuring pxe network boot server on ubuntu 22.04 LTS
https://github.com/ipxe/ipxe/discussions/324
Leave A Comment?