728x90
반응형
우분투 22.04에서 PXE 네트워크 부팅 서버를 구성하는 방법
테스트 환경
- 운영체제 : Ubuntu 22.04.5
- DHCP : isc-dhcp-server(DHCP 서비스)
- TFTP : tftpd-hpa(PXE 클라이언트에 부트로더/커널/인트림 제공)
- HTTP : nginx(ISO, 커널/인트림, autoinstall 파일 제공)
- PXE 부트로더 : syslinux/pxelinux(BIOS + PXELINUX)
- 자동 설치 : cloud-init (NoCloud)
1. DHCP 서버(isc-dhcp-server)
패키지 설치 및 서비스 활성화
sudo apt install -y isc-dhcp-server
sudo systemctl enable --now isc-dhcp-server
설정 파일
sudo cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf_$(date '+%Y%m%d_%H%M%S')
sudo vim /etc/dhcp/dhcpd.conf
sudo tee /etc/dhcp/dhcpd.conf > /dev/null << 'EOF'
default-lease-time 600;
max-lease-time 7200;
authoritative;
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.106 192.168.10.110;
option routers 192.168.10.1;
option domain-name-servers 8.8.8.8, 8.8.4.4;
# PXE 부트 파일 지정
filename "pxelinux.0";
next-server 192.168.10.100;
}
EOF
서비스 재시작
sudo systemctl restart isc-dhcp-server
서비스 상태 확인
sudo systemctl status isc-dhcp-server
2. TFTP 서버(tftpd-hpa)
패키지 설치 및 서비스 활성화
sudo apt install -y tftpd-hpa
sudo systemctl enable --now tftpd-hpa
설정 파일
sudo cp /etc/default/tftpd-hpa /etc/default/tftpd-hpa_$(date '+%Y%m%d_%H%M%S')
sudo vim /etc/default/tftpd-hpa
sudo tee /etc/default/tftpd-hpa > /dev/null << 'EOF'
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure --create"
EOF
TFTP 루트 디렉토리 생성
sudo mkdir -p /var/lib/tftpboot
서비스 재시작
sudo systemctl restart tftpd-hpa
서비스 상태 확인
sudo systemctl status tftpd-hpa
3. PXELINUX(Syslinux) 구성
sudo apt install -y syslinux-common pxelinux
PXELINUX 부팅 이미지(pxelinux.0)를 /var/lib/tftpboot 디렉터리로 복사
sudo cp /usr/lib/PXELINUX/pxelinux.0 /var/lib/tftpboot/
sudo cp /usr/lib/syslinux/modules/bios/{ldlinux.c32,libcom32.c32,libutil.c32,menu.c32,vesamenu.c32} \
/var/lib/tftpboot/
sudo mkdir -p /var/lib/tftpboot/pxelinux.cfg
UEFI 모드
더보기
---
sudo apt-get install -y syslinux-efi
sudo mkdir -p /var/lib/tftpboot/uefi
sudo cp /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi /var/lib/tftpboot/uefi
sudo cp /usr/lib/syslinux/modules/efi64/{ldlinux.e64,libcom32.c32,libutil.c32,vesamenu.c32} /var/lib/tftpboot/uefi
ln -s /var/lib/tftpboot/pxelinux.cfg /var/lib/tftpboot/uefi/pxelinux.cfg
---
TFTP 루트 디렉토리 설정
sudo chmod -R 755 /var/lib/tftpboot
sudo chown -R nobody:nogroup /var/lib/tftpboot
4. Nginx 설치 및 HTTP 서버 구성
sudo apt install -y curl gnupg2 ca-certificates lsb-release ubuntu-keyring
curl -fsSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
sudo apt update
sudo apt install -y nginx
sudo systemctl enable --now nginx
default.conf 설정 파일 백업
sudo cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf_$(date '+%Y%m%d_%H%M%S')
default.conf 설정 파일 수정
sudo vim /etc/nginx/conf.d/default.conf
sudo tee /etc/nginx/conf.d/default.conf << 'EOF'
server {
listen 80;
server_name _;
access_log /var/log/nginx/host-access.log main;
error_log /var/log/nginx/host-error.log;
client_max_body_size 0;
location / {
root /usr/share/nginx/html;
autoindex on;
}
location /iso/ {
alias /usr/share/nginx/html/iso/;
autoindex on;
}
location /ubuntu/ {
alias /usr/share/nginx/html/ubuntu/;
autoindex on;
}
location /autoinstall/ {
alias /usr/share/nginx/html/autoinstall/;
autoindex on;
default_type text/plain;
}
}
EOF
sudo nginx -t
sudo systemctl restart nginx
5. 우분투 ISO 파일 준비
HTTP Repository 구성
sudo mkdir -p /usr/share/nginx/html/{iso,ubuntu/22.04}
cd /usr/share/nginx/html/iso
wget https://releases.ubuntu.com/22.04/ubuntu-22.04.5-live-server-amd64.iso
ISO 이미지 다운로드 및 ISO 마운트
sudo mkdir -p /mnt/iso
sudo mount -o loop,ro ubuntu-22.04.5-live-server-amd64.iso /mnt/iso
sudo cp -r /mnt/iso/* /usr/share/nginx/html/ubuntu/22.04/
sudo umount /mnt/iso
squashfs 링크 생성
cd /usr/share/nginx/html/ubuntu/22.04/casper
ln -s ubuntu-server-minimal.ubuntu-server.installer.squashfs filesystem.squashfs
Ubuntu 24.04
더보기
---
sudo mkdir -p /usr/share/nginx/html/ubuntu/24.04
cd /usr/share/nginx/html/iso
wget https://releases.ubuntu.com/24.04/ubuntu-24.04.3-live-server-amd64.iso
sudo mkdir -p /mnt/iso
sudo mount -o loop,ro ubuntu-24.04.3-live-server-amd64.iso /mnt/iso
sudo cp -r /mnt/iso/* /usr/share/nginx/html/ubuntu/24.04/
sudo umount /mnt/iso
---
커널(vmlinuz) 및 initrd 파일 복사
sudo cp /usr/share/nginx/html/ubuntu/22.04/casper/{vmlinuz,initrd} \
/var/lib/tftpboot/
sudo cp /usr/share/nginx/html/ubuntu/22.04/casper/{vmlinuz,initrd} \
/usr/share/nginx/html/ubuntu/22.04/
7. cloud-init (NoCloud) 확장 구성
디렉터리 생성
sudo mkdir -p /usr/share/nginx/html/autoinstall
meta-data 생성
sudo vim /usr/share/nginx/html/autoinstall/meta-data
sudo tee /usr/share/nginx/html/autoinstall/meta-data << 'EOF'
instance-id: ubuntu-2204-pxe
local-hostname: ubuntu-pxe
EOF
user-data 생성
- password는 반드시 openssl passwd -6으로 생성한 해시값 사용
# 패스워드 : ubuntu
openssl passwd -6 'ubuntu'
$6$YHHqTfkwCtHcDgHa$ljH6JlVWXT05xha4sCOjnQckLICoQJ5GpDlF0iwJ74zESHPTo.Sqwnb16zwZeHIAIcd9M0Kd503JPO5FD/tgb/
sudo vim /usr/share/nginx/html/autoinstall/user-data
sudo tee /usr/share/nginx/html/autoinstall/user-data << 'EOF'
#cloud-config
autoinstall:
version: 1
locale: ko_KR.UTF-8
keyboard:
layout: kr
timezone: Asia/Seoul
identity:
hostname: ubuntu-pxe
username: ubuntu
password: "$6$YHHqTfkwCtHcDgHa$ljH6JlVWXT05xha4sCOjnQckLICoQJ5GpDlF0iwJ74zESHPTo.Sqwnb16zwZeHIAIcd9M0Kd503JPO5FD/tgb/"
ssh:
install-server: true
allow-pw: true
packages:
- vim
- curl
- net-tools
storage:
layout:
name: direct
late-commands:
- curtin in-target -- systemctl enable ssh
EOF
8. 부팅 설정 파일 생성(cloud-init 연동)
/srv/tftp/pxelinux.cfg/default 파일을 생성하고 PXE 부팅 메뉴를 구성
sudo mkdir -p /var/lib/tftpboot/pxelinux.cfg
sudo vim /var/lib/tftpboot/pxelinux.cfg/default
sudo tee /var/lib/tftpboot/pxelinux.cfg/default << 'EOF'
DEFAULT menu.c32
PROMPT 0
TIMEOUT 300
MENU TITLE Ubuntu 22.04 PXE Boot Menu
LABEL ubuntu-2204-autoinstall
MENU LABEL Install Ubuntu 22.04 (Auto)
KERNEL vmlinuz
INITRD initrd
APPEND ip=dhcp \
boot=casper \
netboot=http \
casper-path=casper \
autoinstall \
ds=nocloud-net;s=http://192.168.10.100/autoinstall/ \
url=http://192.168.10.100/ubuntu/22.04/ \
fsck.mode=skip
LABEL ubuntu-2204-manual
MENU LABEL Install Ubuntu 22.04 (Manual)
KERNEL vmlinuz
INITRD initrd
APPEND ip=dhcp \
boot=casper \
netboot=http \
casper-path=casper \
url=http://192.168.10.100/ubuntu/22.04/
LABEL local
MENU LABEL Boot Local Disk
LOCALBOOT 0
EOF
서비스 재시작
sudo systemctl restart isc-dhcp-server tftpd-hpa nginx
네트워크 부팅 설치(Network boot)
오류

Begin: Running /scripts/casper-premount ... done.
done.
Unable to find a medium containing a live file system
Attempt interactive netboot from a URL?
yes no (default yes):
실패
728x90
반응형
'리눅스' 카테고리의 다른 글
| CentOS Stream 10에서 PXE 서버를 구성하는 방법 (0) | 2025.12.21 |
|---|---|
| CentOS Stream 10에서 고정 IP를 설정하는 방법 (0) | 2025.12.21 |
| macOS에서 ISO 이미지를 USB 부팅 디스크로 생성하는 방법 (1) | 2025.12.17 |
| 네트워크 성능 튜닝 (1) | 2025.12.16 |
| 우분투 24.04에서 TFTP 서버를 구축하는 방법 (0) | 2025.12.16 |