๊ธฐ์ค ํ๊ฒฝ
- PXE ์๋ฒ IP
- 17.3.115.126
- ๋์ ์๋ฒ ๋์ญ
- 17.3.115.0/24
- ์ค์น OS
- Rocky Linux 9.7 (์ถํ์ ๋ง์ด๊ทธ๋ ์ด์ ๊ฐ๋ฅ)
- ๋ฒ์ ์ ํํ ๋๋ ๋ฌด์กฐ๊ฑด ์ต์ ๋ฒ์ ์ฌ์ฉ์ด ์๋ ์์ ์ฑ์ ๊ณ ๋ คํ์ฌ ์ ํ
- ๋ฐฉ์
- PXE + Kickstart ์๋ ์ค์น
- UEFI / BIOS ๋ ๋ค ๋์
์ ์ฒด ํ๋ฆ ์ ๋ฆฌ
- ํ์ํ ํจํค์ง ์ค์น ๋ฐ ํ์ธ
- DHCP ์ค์
- ISO ๋ง์ดํธ
- ๋ถํ ํ์ผ ๋ณต์ฌ (TFTP)
- Rocky ์ค์น ํ์ผ ๊ณต๊ฐ (HTTP)
- PXE ๋ฉ๋ด ์์ฑ
- Kickstart ์์ฑ
- ์๋น์ค ์์
- ๋ฐฉํ๋ฒฝ ํ์ฉ
- PXE ์๋ฒ ์ํ ์ ๊ฒ
- ๋์ ์๋ฒ PXE ๋ถํ ์ ๋ก๊ทธ ํ์ธ
(1) ํ์ํ ํจํค์ง ์ค์น ๋ฐ ํ์ธ
- ์ค์น ์ฌ๋ถ ํ์ธ
- rpm -qa | egrep "dhcp|tftp|syslinux|httpd|grub2-efi|shim"
- ํจํค์ง ์ค์น
- dnf install -y dhcp-server tftp-server syslinux httpd grub2-efi-x64 shim-x64
- DHCP ์ค์น ํ์ธ
- rpm -qa | grep dhcp-server
- ๋๋ ํ ๋ฆฌ ๊ตฌ์ฑ
- /var/lib/tftpboot : PXE ๋ถํ ์ฉ ํ์ผ
- /var/www/html : Rocky ์ค์น ํ์ผ + Kickstart
(2) DHCP ์ค์
option arch code 93 = unsigned integer 16;
default-lease-time 600;
max-lease-time 7200;
deny unknown-clients;
authoritative;
subnet 17.3.115.0 netmask 255.255.255.0 {
option routers 17.3.115.2; # ๊ฒ์ดํธ์จ์ด ์ฃผ์
option subnet-mask 255.255.255.0;
option domain-name-servers 17.17.17.102, 17.17.17.103; # dns ์ค์
next-server 17.3.115.126;
if option arch = 00:07 or option arch = 00:09 {
filename "shimx64.efi";
} else {
filename "pxelinux.0";
}
}
host server-123 {
hardware ethernet 10:e7:c6:43:3c:02;
fixed-address 17.3.115.123;
}
host server-127 {
hardware ethernet 84:69:93:79:ec:66;
fixed-address 17.3.115.127;
}
- ์ค์ ํ์ผ ์์ฑ
- `/etc/dhcp/dhcpd.conf`์ ์์ฑ (ํจํค์ง ์ค์นํ๋ฉด ํ์ผ์ ์๋์ผ๋ก ์์ฑ๋์ด ์์)
- option arch code 93 = unsigned integer 16;
- ํด๋ผ์ด์ธํธ ์ํคํ ์ฒ ํ์ ์ ์
- PXE ํด๋ผ์ด์ธํธ๊ฐ BIOS์ธ์ง UEFI์ธ์ง
- authoritative;
- ๊ณต์ DHCP ์๋ฒ ์ ์ธ
- next-server 17.3.115.126;
- PXE ์๋ฒ ์์น
- IP ์ค์ ์ ๊ฐ์ ๋คํธ์ํฌ ๋์ญ ์์์ ์ง์
- ์ค์ ํ์ผ ๋ฌธ๋ฒ ๊ฒ์ฌ
- dhcpd -t -cf /etc/dhcp/dhcpd.conf
(3) ISO ๋ง์ดํธ
- ๋กํค Minimal ์ฌ์ฉ
- ISO ํ์ผ ์ค๋น
mkdir -p /mnt/iso
mount -o loop Rocky-9.7~.iso(๊ฒฝ๋ก ์ง์ ) /mnt/iso
- ํ์ธ
- ls /mnt/iso
- images, EFI ๋ฑ์ ํด๋(ํ์ผ)์ด ๋ณด์ฌ์ผ ํจ
(4) ๋ถํ ํ์ผ ๋ณต์ฌ (TFTP)
- ์ค์น ISO ์ ์ฒด๋ฅผ ์ฃผ๋ ๊ฒ์ด ์๋, ๋ถํ ์ ํ์ํ ์ต์ ํ์ผ์ TFTP๋ก ์ ๊ณต
- ํ์ํ๋ค๋ฉด ํ์ผ์ ๊ถํ ์ค์ (ํ์ผ์ ์ฝ์ง ๋ชปํ ์๋ ์์)
BIOS PXE์ฉ ํ์ผ
find /usr/share -name pxelinux.0 # /usr/share/syslinux/pxelinux.0
find /usr/share -name ldlinux.c32 # /usr/share/syslinux/ldlinux.c32
find /usr/share -name libcom32.c32 # /usr/share/syslinux/libcom32.c32
find /usr/share -name libutil.c32 # /usr/share/syslinux/libutil.c32
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /usr/share/syslinux/ldlinux.c32 /var/lib/tftpboot/
cp /usr/share/syslinux/libcom32.c32 /var/lib/tftpboot/
cp /usr/share/syslinux/libutil.c32 /var/lib/tftpboot/
# ์ด ๋์ ์ ํ์ด์ง๋ง ๊ถ์ฅํ๋ค๊ณ ํจ
find /usr/share -name menu.c32 # /usr/share/syslinux/menu.c32
find /usr/share -name vesamenu.c32 # /usr/share/syslinux/vesamenu.c32
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
cp /usr/share/syslinux/vesamenu.c32 /var/lib/tftpboot/
UEFI PXE์ฉ ํ์ผ
find /boot -name shimx64.efi
find /boot -name grubx64.efi
cp /boot/efi/EFI/rocky/shimx64.efi /var/lib/tftpboot/
cp /boot/efi/EFI/rocky/grubx64.efi /var/lib/tftpboot/
PXE ์ปค๋ ๋ณต์ฌ
cp /mnt/iso/images/pxeboot/vmlinuz /var/lib/tftpboot/rocky/9.7/
cp /mnt/iso/images/pxeboot/initrd.img /var/lib/tftpboot/rocky/9.7/
- vmlinuz(์ปค๋)๋ก ๋ถํ
- initrd.img๋ก ์ค์น๊ธฐ ์ฌ๋ฆผ
- ์ด๊ธฐ ๋ถํ ์ฉ ์์ ๋ฃจํธ ํ์ผ ์์คํ
- ์๋์ฝ๋ค ์ค์น๊ธฐ, ๋๋ผ์ด๋ฒ, ๋คํธ์ํฌ ๊ธฐ๋ฅ ๋ฑ์ด ๋ค์ด์์
(5) Rocky ์ค์น ํ์ผ ๋ณต์ฌ (HTTP)
mkdir -p /var/www/html/rocky/9.7
cp -r /mnt/iso/* /var/www/html/rocky/9.7/
ls /var/www/html/rocky/9.7/repodata # Minimal๋ repodata ์กด์ฌํด์ผ ํจ
- HTTP ํด๋๋ก ๋กํค ๋ง์ดํธ ๋ณต์ฌ
(6) PXE ๋ฉ๋ด ์์ฑ
BIOS ๋ฉ๋ด ์์ฑ
DEFAULT rocky9.7-auto
PROMPT 0
TIMEOUT 10
LABEL rocky9.7-auto
KERNEL rocky/9.7/vmlinuz
APPEND initrd=rocky/9.7/initrd.img inst.repo=http://17.3.115.126/rocky/9.7 inst.ks=http://17.3.115.126/ks.cfg quiet
LABEL local-disk
LOCALBOOT 0
- `mkdir -p /var/lib/tftpboot/pxelinux.cfg`
- `/var/lib/tftpboot/pxelinux.cfg/default`์ ์์ฑ
- ํด๋น ํ์ผ ์์น
- /var/lib/tftpboot/rocky/9.7/
- vmlinuz
- initrd.img
- /var/www/html/
- rocky/9.7
- ks.cfg
- /var/lib/tftpboot/rocky/9.7/
UEFI ๋ฉ๋ด ์์ฑ (grub.cfg ์์ฑ)
set timeout=10
set default=0
menuentry "Rocky Linux 9.7 Auto Install" {
linuxefi /rocky/9.7/vmlinuz inst.repo=http://17.3.115.126/rocky/9.7 inst.ks=http://17.3.115.126/ks.cfg quiet
initrdefi /rocky/9.7/initrd.img
}
- `/var/lib/tftpboot/grub.cfg`์ ์์ฑ
- ํด๋น ํ์ผ ์์น
- ์์ ๋์ผ
์ฃผ์!
- ์ง๊ธ ์ํ๋ `/var/www/html/rocky/9.7`๊ฐ ์๋ `/var/www/html/rocky/9.7/Minimal`์ `/repodata/repomd.xml`๊ฐ ์์นํด ์์
- PXE ๋ฉ๋ด์์ repo ์์น๋ฅผ `/rocky/9.7`๋ก ์ก์๋จ๊ธฐ ๋๋ฌธ์ `/Minimal` ํด๋ ์์ ์๋ ํ์ผ๋ค์ ๋ชจ๋ ๊บผ๋ด์ค์ผ ํจ
- ์ ํํ ์ด์ ๋ ๋ชจ๋ฅด๊ฒ ์ง๋ง PXE ๋ฉ๋ด์์ repo ๊ฒฝ๋ก ๋ค์ `/Minimal`์ ๋ถ์ด๋ ๊ฑธ๋ก๋ ํด๊ฒฐ์ด ๋์ง ์์
(7) Kickstart ์ค์ ์์ฑ
text
reboot
# English install (avoid Korean font issues)
lang en_US.UTF-8
keyboard us
timezone Asia/Seoul --utc
url --url="http://17.3.115.126/rocky/9.7"
rootpw --plaintext 'simul!'
# IP ์๋ ํ ๋น ๋ฐ DNS ์๋ฒ ์ค์
network --bootproto=dhcp --device=link --activate
# ํธ์คํธ๋ช
์ค์
network --hostname=localhost.localdomain
# Auto select install disk
%pre --log=/tmp/ks-pre.log
if ls /dev/nvme*n1 >/dev/null 2>&1; then
install_disk=$(ls /dev/nvme*n1 | head -n1 | sed 's|/dev/||')
else
install_disk=$(lsblk -ndo NAME,TYPE,SIZE \
| awk '$2=="disk"{print $1,$3}' \
| sort -k2 -h \
| head -n1 \
| awk '{print $1}')
fi
cat > /tmp/disk.ks <<EOF
ignoredisk --only-use=${install_disk}
zerombr
clearpart --all --initlabel --drives=${install_disk}
bootloader --boot-drive=${install_disk}
part /boot/efi --fstype=efi --size=1024 --ondisk=${install_disk}
part /boot --fstype=ext4 --size=1024 --ondisk=${install_disk}
part swap --fstype=swap --size=16384 --ondisk=${install_disk}
part / --fstype=xfs --grow --ondisk=${install_disk}
EOF
%end
%include /tmp/disk.ks
%packages
@^minimal-environment
%end
%post
echo "DEV server clean install completed." > /root/ks-info.txt
echo "All configuration will be applied by Ansible." >> /root/ks-info.txt
# root SSH ๋ก๊ทธ์ธ ํ์ฉ
sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
sed -i 's/^PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
# ๋น๋ฐ๋ฒํธ ๋ก๊ทธ์ธ ํ์ฉ
sed -i 's/^#PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config
sed -i 's/^PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config
# SSH ํ์ฑํ
systemctl enable sshd
systemctl restart sshd
%end
- `/var/www/html`์ ์์ฑ
(8) ์๋น์ค ์์
systemctl enable --now dhcpd
systemctl enable --now tftp.socket
systemctl enable --now httpd
# ์ํ ํ์ธ
systemctl status dhcpd
systemctl status tftp.socket
systemctl status httpd
(9) ๋ฐฉํ๋ฒฝ ํ์ฉ (ํฌํธ ์คํ)
firewall-cmd --permanent --add-service=dhcp
firewall-cmd --permanent --add-service=tftp
firewall-cmd --permanent --add-service=http
firewall-cmd --reload
# ํ์ธ
firewall-cmd --list-all
(10) PXE ์๋ฒ ์ํ ์ ๊ฒ
# Kickstart ์ ๊ทผ ํ์ธ
curl <http://17.3.115.126/ks.cfg>
# Repo ์ ๊ทผ ํ์ธ
curl <http://17.3.115.126/rocky/9.7/.treeinfo>
curl <http://17.3.115.126/rocky/9.7/repodata/repomd.xml>
(11) ๋์ ์๋ฒ PXE ๋ถํ ์ ๋ก๊ทธ ํ์ธ
journalctl -u dhcpd -f
journalctl -u tftp.socket -f
tail -f /var/log/httpd/access_log # ํ์ผ ๊ฒฝ๋ก
- ๋ก๊ทธ ํ์ธ์ PXE ์๋ฒ์์ ์งํ
์ ๊ณผ์ ์งํ ํ ์๋๋ ์์ธ
- .treeinfo ๊ฒฝ๋ก ๋ชป์ฐพ์
- ์ด ํ์ผ์ ์ง๊ธ ๊ณผ์ (Minimal ์ฌ์ฉ)์์ ์์ด๋ ๋ฌด๊ดํ๋ฏ ํจ (ํ์ผ์ด ์กด์ฌํ์ง ์์)
- repodata/repomd.xml ๊ฒฝ๋ก ๋ชป์ฐพ์
- ์ค์ ํ์ผ(default, grub.cfg)์์ rocky/9.7์ repo ๊ฒฝ๋ก๋ก ์ค์ ํ ์ํ์ธ๋ฐ ์ค์ ๋ก repodata๋ Minimal ํด๋ ์์ ๋ค์ด์์
- ๋จผ์ repo ๊ฒฝ๋ก ๋์ /Minimal์ ๋ถ์ฌ๋ดค๋๋ฐ ์๋ฌ ๋ฐ์ํจ
- Minimal ๋ด๋ถ์ ํด๋๋ค์ ์ค์ ํ repo ๊ฒฝ๋ก๋ก ์ฎ๊ธฐ๋ ํด๊ฒฐ๋จ
๋์ ์๋ฒ์์ ์ด๋๋ฏผ ๊ณ์ ์ถ๊ฐ
useradd -m admin
passwd admin
usermod -aG wheel admin # ์ฌ์ฉ์๋ฅผ wheel ๊ทธ๋ฃน์ ์ถ๊ฐ (sudo ๊ถํ ๊ด๋ฆฌ์ ๊ทธ๋ฃน)
su - admin
- ๋ฌผ๋ก admin์ด ์๋ ๋ค๋ฅธ ์ด๋ฆ ์ฌ์ฉ ๊ฐ๋ฅ