728x90
반응형
0. 참고
https://estar987.tistory.com/61
1. requirement
- HTTP
- TFTP
- DHCP
2. Installation
2-1 httpd : web서비스 설치 후 동작 Test
yum install httpd
echo "Works" > /var/www/html/index.html
systemctl enable httpd
systemctl start httpd
2-2 tftp-server
yum install tftp tftp-server -y
mkdir /var/www/html/linux-install/
vi /usr/lib/systemd/system/tftp.service
[Unit]
Description=Tftp Server
Requires=tftp.socket
Documentation=man:in.tftpd
[Service]
ExecStart=/usr/sbin/in.tftpd -s /var/lib/tftpboot
StandardInput=socket
[Install]
Also=tftp.socket
systemctl enable tftp.socket
systemctl start tftp.socket
2-3 dhcp server
yum install dhcp-common dhcp-server -y
vi /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
# see 'man 5 dhcpd.conf'
#
ddns-update-style interim;
ignore client-updates;
default-lease-time 600;
max-lease-time 7200;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.207.10;
option routers 192.168.207.254;
option space ipxe;
option ipxe-encap-opts code 175 = encapsulate ipxe;
option ipxe.priority code 1 = signed integer 8;
option ipxe.keep-san code 8 = unsigned integer 8;
option ipxe.skip-san-boot code 9 = unsigned integer 8;
option ipxe.syslogs code 85 = string;
option ipxe.cert code 91 = string;
option ipxe.privkey code 92 = string;
option ipxe.crosscert code 93 = string;
option ipxe.no-pxedhcp code 176 = unsigned integer 8;
option ipxe.bus-id code 177 = string;
option ipxe.bios-drive code 189 = unsigned integer 8;
option ipxe.username code 190 = string;
option ipxe.password code 191 = string;
option ipxe.reverse-username code 192 = string;
option ipxe.reverse-password code 193 = string;
option ipxe.version code 235 = string;
option iscsi-initiator-iqn code 203 = string;
option ipxe.pxeext code 16 = unsigned integer 8;
option ipxe.iscsi code 17 = unsigned integer 8;
option ipxe.aoe code 18 = unsigned integer 8;
option ipxe.http code 19 = unsigned integer 8;
option ipxe.https code 20 = unsigned integer 8;
option ipxe.tftp code 21 = unsigned integer 8;
option ipxe.ftp code 22 = unsigned integer 8;
option ipxe.dns code 23 = unsigned integer 8;
option ipxe.bzimage code 24 = unsigned integer 8;
option ipxe.multiboot code 25 = unsigned integer 8;
option ipxe.slam code 26 = unsigned integer 8;
option ipxe.srp code 27 = unsigned integer 8;
option ipxe.nbi code 32 = unsigned integer 8;
option ipxe.pxe code 33 = unsigned integer 8;
option ipxe.elf code 34 = unsigned integer 8;
option ipxe.comboot code 35 = unsigned integer 8;
option ipxe.efi code 36 = unsigned integer 8;
option ipxe.fcoe code 37 = unsigned integer 8;
option ipxe.vlan code 38 = unsigned integer 8;
option ipxe.menu code 39 = unsigned integer 8;
option ipxe.sdi code 40 = unsigned integer 8;
option ipxe.nfs code 41 = unsigned integer 8;
option ipxe.no-pxedhcp 1;
option arch code 93 = unsigned integer 16;
authoritative;
allow booting;
allow bootp;
subnet 192.168.207.0 netmask 255.255.255.0 {
# interface eth0;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.207.255;
option routers 192.168.207.254;
range dynamic-bootp 192.168.207.10 192.168.207.190;
class "pxeclients" {
match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
next-server 192.168.207.10;
if option arch = 00:07 {
filename "ipxe.efi"; # UEFI 모드 클라이언트를 위한 파일
}
elsif option arch = 00:00 {
filename "undionly.kpxe"; # BIOS 모드 클라이언트를 위한 파일
}
else {
filename "ipxe.efi"; # 기본적으로 UEFI 파일 제공
}
}
}
systemctl start dhcpd
3. IPXE
- 설치파일 소스 : https://github.com/ipxe/ipxe
- dhcp를 통해서 IP를 받은 뒤에 BIOS, UEFI 타입에 맞게 부트로더를 선택하게 되고, tftp서버에서 해당 파일을 다운로드 받아 Client가 부팅되게 한다. ipxe 부트로더는 http서비스를 통해서 ipxe 설정파일들을 읽어서 pxe환경을 Client 화면에 출력한다.
3-1 iPXE 컴파일
- iPXE를 UEFI, BIOS 두 용도로 나눠서 컴파일을 한다. 컴파일 할 때 boot.ipxe 파일을 포함시킨다. 그래야 httpd를 통해서 iPXE용 메뉴인 menu.ipxe 파일을 바로 호출할 수 있다.
- UEFI 용으로 컴파일 한다.
# source download
cd ~
git clone https://github.com/ipxe/ipxe.git
mv ipxe ipxe_uefi
cd ipxe_uefi/src
# enbed할 파일 생성 : boot.ipxe
cat > boot.ipxe << EOL
#!ipxe
dhcp
chain http://\${next-server}/ipxe/menu.ipxe
EOL
# 일부 코드 수정 : 그래픽 이미지를 사용하려면 아래 설정을 해주고 컴파일을 해야함
sed -i -e 's/\/\/#define\s*CONSOLE_CMD/#define CONSOLE_CMD/g' config/general.h
sed -i -e 's/\/\/#define\s*TIME_CMD/#define TIME_CMD/g' config/general.h
sed -i -e 's/\/\/#define\s*CONSOLE_FRAMEBUFFER/#define CONSOLE_FRAMEBUFFER/g' config/console.h
# compile
make clean
make bin-x86_64-efi/ipxe.efi EMBED=boot.ipxe
chmod +x bin-x86_64-efi/ipxe.efi
/bin/cp -f bin-x86_64-efi/ipxe.efi /var/www/html/linux-install/
- BIOS(legacy) 용으로 컴파일
# source download
cd ~
git clone https://github.com/ipxe/ipxe.git
mv ipxe ipxe_legacy
cd ipxe_legacy/src
# enbed할 파일 생성 : boot.ipxe
cat > boot.ipxe << EOL
#!ipxe
dhcp
chain http://\${next-server}/ipxe/menu.ipxe
EOL
# 일부 코드 수정 : 그래픽 이미지를 사용하려면 아래 설정을 해주고 컴파일을 해야함
sed -i -e 's/\/\/#define\s*CONSOLE_CMD/#define CONSOLE_CMD/g' config/general.h
sed -i -e 's/\/\/#define\s*TIME_CMD/#define TIME_CMD/g' config/general.h
sed -i -e 's/\/\/#define\s*CONSOLE_FRAMEBUFFER/#define CONSOLE_FRAMEBUFFER/g' config/console.h
# The ESXi Legacy BIOS bootloader mboot.c32 needs COMBOOT enabled in iPXE
sed -i -e 's/\/\/#define\s*IMAGE_COMBOOT/#define IMAGE_COMBOOT/g' config/general.h
# compile
make clean
make bin/undionly.kpxe EMBED=boot.ipxe
/bin/cp -f bin/undionly.kpxe /var/www/html/linux-install/
3-2 ipxe 메뉴 구성
- 기본 메뉴를 위한 http 경로 생성
- OS : iso 이미지를 통해서 OS 이미지 파일을 복사하는 경로
- img : ipxe 메뉴의 배경이미지 파일 경로
- ks : kickstart 파일 경로.
- submenu : ipxe 메뉴용 파일 경로
mkdir -p /var/www/html/ipxe/{OS,img,ks,submenu}
- ipxe 배경 파일 다운로드
cd /var/www/html/ipxe/img
wget http://boot.ipxe.org/ipxe.png # 배경이미지
- 기본 메뉴 파일
vi /var/www/html/ipxe/menu.ipxe
#!ipxe
# Some menu defaults
set menu-timeout 50000
set submenu-timeout 30000
set esc:hex 1b
set bold ${esc:string}[1m
set orange ${esc:string}[33;0m
set yellow ${esc:string}[33;1m
set cyan ${esc:string}[36;1m
set resetfg ${esc:string}[39m
set resetbg ${esc:string}[49m
set resetbold ${esc:string}[22m
set reset ${esc:string}[0m
console --picture http://${next-server}/ipxe/img/ipxe.png --left 64 --right 0 --top 64 --bottom 96
colour --basic 3 --rgb 0xffaa44 3
cpair --foreground 0 --background 3 2
cpair --foreground 3 3
set chotkey ${bold}
set cname ${orange}
goto start
:start
chain --replace --autofree http://${next-server}/ipxe/submenu/start.ipxe\
- 메인 메뉴
vi /var/www/html/ipxe/submenu/start.ipxe
#!ipxe
menu ESTAR - iPXE menu
item --gap -- ---------------- Boot from Local Hard Disk ------------------------------------------------
item --key l exit ${chotkey}l${resetbold}ocal Disk
item --gap -- ---------------- CentOS -------------------------------------------------------------------
item --key c centos7-setup ${chotkey}c${resetbold}entOS 7
item --key C centos8-setup ${chotkey}C${resetbold}entOS 8
item --key r rocky8-setup ${chotkey}r${resetbold}ockyLinux 8
item --gap -- ---------------- ETC ----------------------------------------------------------------------
item --key R reboot ${chotkey}R${resetbold}eboot
item --key s shell iPXE${chotkey}s${resetbold}hell
#choose --timeout ${menu-timeout} --default windows10 os && goto ${os}
choose --timeout ${menu-timeout} os && goto ${os}
###################### Local Disk #############################
:exit
exit
###################### submenu #############################
:centos7-setup
chain http://${next-server}/ipxe/submenu/centos7.ipxe
:centos8-setup
chain http://${next-server}/ipxe/submenu/centos8.ipxe
:rocky8-setup
chain http://${next-server}/ipxe/submenu/rockylinux8.ipxe
###################### ETC #############################
:reboot
reboot
:shell
shell
chain --replace --autofree http://${next-server}/ipxe/submenu/start.ipxe
- Rockylinux 8 버전 메뉴
# vi /var/www/html/ipxe/submenu/rockylinux8.ipxe
#!ipxe
menu ${chotkey}RockyLinux 8${resetbold}
item --gap -- ---------------- BIOS ---------------------------------------------------------------------
item --key 1 rockylinux86-bios ${chotkey}1.${resetbold} RockyLinux 8.6 - bios
item --key 2 rockylinux87-bios ${chotkey}2.${resetbold} RockyLinux 8.7 - bios
item --key 3 rockylinux89-bios ${chotkey}3.${resetbold} RockyLinux 8.9 - bios
item --gap -- ---------------- UEFI ---------------------------------------------------------------------
item --key 4 rockylinux86-uefi ${chotkey}4.${resetbold} RockyLinux 8.6 - uefi
item --key 5 rockylinux87-uefi ${chotkey}5.${resetbold} RockyLinux 8.7 - uefi
item --key 6 rockylinux89-uefi ${chotkey}6.${resetbold} RockyLinux 8.9 - uefi
item --gap -- ---------------- Interactive --------------------------------------------------------------
item --key 7 rockylinux86-uefi-interactive ${chotkey}7.${resetbold} RockyLinux 8.6 - uefi - interactive
item --key 8 rockylinux86-uefi-by-num-from-list ${chotkey}8.${resetbold} RockyLinux 8.6 - uefi - by_number
item --gap -- ---------------- BACK ---------------------------------------------------------------------
item --key b start go ${chotkey}b${resetbold}ack to start
choose --timeout ${menu-timeout} os && goto ${os}
:start
chain --replace --autofree http://${next-server}/ipxe/submenu/start.ipxe
:rockylinux86-bios
set base http://${next-server}/ipxe/OS/rocky8.6/
kernel ${base}/images/pxeboot/vmlinuz initrd=initrd.img inst.repo=${base} inst.ks=http://${next-server}/ipxe/ks/estar-Rocky8.6_BIOS.cfg inst.xdriver=vesa nomodeset ksdevice=eth0 biosdevname=0 net.ifnames=0
initrd ${base}/images/pxeboot/initrd.img
boot
:rockylinux86-uefi
set base http://${next-server}/ipxe/OS/rocky8.6/
kernel ${base}/images/pxeboot/vmlinuz initrd=initrd.img inst.repo=${base} inst.ks=http://${next-server}/ipxe/ks/estar-Rocky8.6_UEFI.cfg inst.xdriver=vesa nomodeset ksdevice=eth0 biosdevname=0 net.ifnames=0
initrd ${base}/images/pxeboot/initrd.img
boot
:rockylinux87-bios
set base http://${next-server}/ipxe/OS/rocky8.7/
kernel ${base}/images/pxeboot/vmlinuz initrd=initrd.img inst.repo=${base} inst.ks=http://${next-server}/ipxe/ks/estar-Rocky8.7_BIOS.cfg inst.xdriver=vesa nomodeset ksdevice=eth0 biosdevname=0 net.ifnames=0
initrd ${base}/images/pxeboot/initrd.img
boot
:rockylinux87-uefi
set base http://${next-server}/ipxe/OS/rocky8.7/
kernel ${base}/images/pxeboot/vmlinuz initrd=initrd.img inst.repo=${base} inst.ks=http://${next-server}/ipxe/ks/estar-Rocky8.7_UEFI.cfg inst.xdriver=vesa nomodeset ksdevice=eth0 biosdevname=0 net.ifnames=0
initrd ${base}/images/pxeboot/initrd.img
boot
:rockylinux89-bios
set base http://${next-server}/ipxe/OS/rocky8.9/
kernel ${base}/images/pxeboot/vmlinuz initrd=initrd.img inst.repo=${base} inst.ks=http://${next-server}/ipxe/ks/estar-Rocky8.9_BIOS.cfg inst.xdriver=vesa nomodeset ksdevice=eth0 biosdevname=0 net.ifnames=0
initrd ${base}/images/pxeboot/initrd.img
boot
:rockylinux89-uefi
set base http://${next-server}/ipxe/OS/rocky8.9/
kernel ${base}/images/pxeboot/vmlinuz initrd=initrd.img inst.repo=${base} inst.ks=http://${next-server}/ipxe/ks/estar-Rocky8.9_UEFI.cfg inst.xdriver=vesa nomodeset ksdevice=eth0 biosdevname=0 net.ifnames=0
initrd ${base}/images/pxeboot/initrd.img
4. OS 이미지 준비
- iso 이미지를 마운트 하고, 속의 내용을 복사하여 파일을 만든다.
# ll
total 2504
drwxr-xr-x 8 root root 4096 Jun 30 14:56 centos7.4
drwxr-xr-x 8 root root 4096 Jun 30 14:52 centos7.6
drwxr-xr-x 8 root root 4096 Jun 30 14:43 centos7.8
drwxr-xr-x 8 root root 4096 Jun 30 14:45 centos7.9
-rwxr-xr-x 1 root root 3411 Jun 30 15:07 grub.cfg
-rwxr-xr-x 1 root root 2292672 Jun 30 14:46 grubx64.efi
drwxr-xr-x 2 root root 4096 Sep 25 13:56 kickstart
-rwxr-xr-x 1 root root 116128 Jun 30 14:52 ldlinux.c32
-rwxr-xr-x 1 root root 22804 Jun 30 14:43 libutil.c32
-rwxr-xr-x 1 root root 26272 Jun 30 14:56 menu.c32
-rwxr-xr-x 1 root root 42397 Jun 30 14:43 pxelinux.0
drwxr-xr-x 2 root root 4096 Sep 25 13:39 pxelinux.cfg
drwxr-xr-x 7 root root 4096 Jun 30 14:55 RHEL8.6
drwxr-xr-x 7 root root 4096 Jun 30 14:46 rocky8.4
drwxr-xr-x 7 root root 4096 Jun 30 14:50 rocky8.6
drwxr-xr-x 7 root root 4096 Jun 30 14:48 rocky8.7
drwxr-xr-x 7 root root 4096 Sep 30 13:09 rocky8.9
drwxr-xr-x 7 root root 4096 Jun 30 14:53 rocky9.2
5. Kickstart
# ls -al | grep Rocky
-rwxr-xr-x 1 root root 8311 Sep 30 10:38 estar-Rocky8.4_BIOS.cfg
-rwxr-xr-x 1 root root 8322 Sep 30 10:38 estar-Rocky8.4_UEFI.cfg
-rwxr-xr-x 1 root root 8353 Sep 30 10:38 estar-Rocky8.6_BIOS.cfg
-rwxr-xr-x 1 root root 8132 Sep 30 11:39 estar-Rocky8.6_UEFI.cfg
-rwxr-xr-x 1 root root 8104 Sep 30 10:38 estar-Rocky8.7_BIOS.cfg
-rwxr-xr-x 1 root root 8368 Sep 30 11:56 estar-Rocky8.7_UEFI.cfg
-rwxr-xr-x 1 root root 8104 Sep 30 13:01 estar-Rocky8.9_BIOS.cfg
-rwxr-xr-x 1 root root 8369 Sep 30 13:01 estar-Rocky8.9_UEFI.cfg
-rwxr-xr-x 1 root root 8315 Sep 30 10:38 estar-Rocky9.2_BIOS.cfg
-rwxr-xr-x 1 root root 8319 Sep 30 10:38 estar-Rocky9.2_UEFI.cfg
6. 실행
반응형
'OS' 카테고리의 다른 글
USB Kickstart 만들기 (0) | 2024.09.26 |
---|---|
[Rocky linux 8] PXE할 서버 지정하기 (0) | 2024.07.08 |
RAID 수준 이해하기: RAID 0, 1, 5, 6, 10, 01 (0) | 2024.07.04 |
PXE 설치 시 BIOS / UEFI 자동 선택 (0) | 2024.02.26 |
레이드(Raid) (0) | 2024.02.17 |