728x90
반응형
1. DHCP 서버 설치
yum -y install dhcp-server
혹은
dnf install dhcp-server
# vi /etc/dhcp/dhcp.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp-server/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
dhcp_interface="ens34";
subnet 192.168.203.0 netmask 255.255.255.0 {
option routers 192.168.203.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.203.33 192.168.203.38;
default-lease-time 3600;
max-lease-time 7200;
### pxe setting ###
allow booting;
allow bootp;
next-server 192.168.203.1;
filename "pxelinux.0";
}
PXE interface 이름 확인하고 넣을 것!!
2. TFTP-Server 설치
yum -y install[dnf install] tftp-server
cp /usr/lib/systemd/system/tftp.service /etc/systemd/system/tftp-server.service
cp /usr/lib/systemd/system/tftp.socket /etc/systemd/system/tftp-server.socket
파일 복사 후 변경된 경로에서 제대로 동작하기 위해 파일을 아래처럼 수정!
# vi /etc/systemd/system/tftp-server.service
[Unit]
Description=Tftp Server
Requires=tftp-server.socket
Documentation=man:in.tftpd
[Service]
ExecStart=/usr/sbin/in.tftpd -s /var/lib/tftpboot
StandardInput=socket
[Install]
WantedBy=multi-user.target
Also=tftp-server.socket
# vi /etc/systemd/system/tftp-server.socket
[Unit]
Description=Tftp Server Activation Socket
[Socket]
ListenDatagram=69
BindIPv6Only=both
[Install]
WantedBy=sockets.target
데몬 재시작
systemctl restart tftp-server
syslinux 설치
dnf install syslinux
부팅에 필요한 파일 복사
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /usr/share/syslinux/ldlinux.c32 /var/lib/tftpboot/
cp /usr/share/syslinux/libutil.c32 /var/lib/tftpboot/
3. PXE 구성 파일 설정
mkdir /var/lib/tftpboot/pxelinux.cfg
# vi /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
prompt 0
timeout 150
ontimeout local
LABEL local
MENU LABEL Boot Local Disk
localboot 0
LABEL RockyLinux8.6
MENU LABEL RockyLinux 8.6 Install
KERNEL /rockylinux8.6/vmlinuz
APPEND initrd=/rockylinux8.6/initrd.img inst.repo=ftp://192.168.203.32/rockylinux8.6
4. FTP 서버 활용하여 로컬 레포지토리 생성
ftp 패키지 설치
dnf install vsftpd
# vi /etc/vsftpd/vsftpd.conf
11 # Allow anonymous FTP? (Beware - allowed by default if you comment this out).
12 anonymous_enable=YES
103 #chroot_list_file=/etc/vsftpd/chroot_list
104 #
105 chroot_local_user=YES
106 allow_writeable_chroot=YES
107 use_localtime=YES
108 # You may activate the "-R" option to the builtin ls. This is disabled by
설치에 필요한 ISO 이미지 파일 마운트
# lsblk
[root@localhost pxelinux.cfg]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 2.7T 0 disk
├─sda1 8:1 0 2M 0 part
├─sda2 8:2 0 200G 0 part /
└─sda3 8:3 0 32G 0 part [SWAP]
sdb 8:16 0 111.8G 0 disk
├─sdb1 8:17 0 100M 0 part
├─sdb2 8:18 0 16M 0 part
├─sdb3 8:19 0 111.1G 0 part
└─sdb4 8:20 0 557M 0 part
sdc 8:32 1 28.7G 0 disk
└─sdc1 8:33 1 28.7G 0 part /run/media/root/ROCKY-8-6-X
# df -h
[root@localhost pxelinux.cfg]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs 7.7G 9.7M 7.7G 1% /run
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/sda2 196G 18G 169G 10% /
tmpfs 1.6G 60K 1.6G 1% /run/user/0
/dev/sdc1 29G 11G 19G 37% /run/media/root/ROCKY-8-6-X
USB의 파일들을 임시로 출력해줄 디렉터리 생성
cd /tmp
mkdir usb
mount 명령어를 통해 연결한 usb를 /tmp/usb라는 폴더로 출력되게 합니다
mount -t vfat /dev/sdc1 /tmp/usb
umount /tmp/usb
CD 내용 복사하여 로컬레포지토리 구성
mkdir /var/ftp/rockylinux8.6
cp -r /mnt/. /var/ftp/rockylinux8.6/
OS 부팅 이미지 복사
mkdir /var/lib/tftpboot/rockylinux8.6
cp /var/ftp/rockylinux8.6/images/pxeboot/initrd.img /var/lib/tftpboot/rockylinux8.6/
cp /var/ftp/rockylinux8.6/images/pxeboot/vmlinuz /var/lib/tftpboot/rockylinux8.6/
서비스 시작
systemctl restart vsftpd tftp-server dhcpd
FTP 확인
[root@localhost rockylinux8.6]# curl ftp://localhost/rockylinux8.6/
drwxr-xr-x 4 0 0 4096 Dec 11 08:19 AppStream
drwxr-xr-x 4 0 0 4096 Dec 11 08:20 BaseOS
drwxr-xr-x 3 0 0 4096 Dec 11 08:20 EFI
-rw-r--r-- 1 0 0 2204 Dec 11 08:20 LICENSE
drwxr-xr-x 2 0 0 4096 Dec 11 08:14 System Volume Information
-rw-r--r-- 1 0 0 883 Dec 11 08:20 TRANS.TBL
-rw-r--r-- 1 0 0 34494 Dec 11 08:20 autorun.ico
-rw-r--r-- 1 0 0 228 Dec 11 08:14 autorun.inf
drwxr-xr-x 3 0 0 4096 Dec 11 08:20 images
-rw-r--r-- 1 0 0 83253316 Dec 12 01:17 initrd.img
drwxr-xr-x 2 0 0 4096 Dec 11 08:20 isolinux
-r--r--r-- 1 0 0 69145 Dec 11 08:14 ldlinux.sys
-rw-r--r-- 1 0 0 86 Dec 11 08:20 media.repo
-rw-r--r-- 1 0 0 94 Dec 11 08:20 syslinux.cfg
-rw-r--r-- 1 0 0 10457392 Dec 12 01:18 vmlinuz
반응형
'OS' 카테고리의 다른 글
PXE(FTP)_BIOS/UEFI (0) | 2023.12.14 |
---|---|
PXE 설치 _ Kickstart (0) | 2023.12.12 |
PXE란 (0) | 2023.12.06 |
Multi OS(Rocky Linux , Windows10) (0) | 2023.12.06 |
OS 부팅 순서 (0) | 2023.12.05 |