-
UEFI를 위한 PXE Boot 서버 구축IT 2020. 12. 5. 17:16반응형
가상화 환경에서 새로운 서버를 생성하는 과정은 VM 생성 -> IP 할당 -> Hostname 설정 -> OS 설정 -> Application 설정과 같은 순서로 이루어 지게되고 예전에는 Manual로 진행하는 작업이 많았지만 최근에는 자동화 툴이 워낙 잘 나오고 있기 때문에 대부분 자동화 되었다. IP 할당 후 이후 단계는 원격 접속이 가능하므로 매우 쉬운 과정으로 볼 수 있으나 VM 생성 -> IP 할당까지는 아직까지도 조금 번거로운 과정이다. 이 번거로운 과정을 조금씩 자동화 해보고 위해 원격 부팅 후 아이피 DHCP를 활용하여 IP를 자동 할당하는 과정까지 정리해보고자 한다.
DHCP Setup
서버에서 dnf를 이용하여 dhcp-server를 설치한다.
# dnf -y install dhcp-server
dhcp-server를 설치하게 되면 /etc/dhcp/dhcpd.conf 에 환경을 설정해 주어야 한다. sample 파일은 /usr/share/doc/dhcp/dhcpd.conf.example 파일을 참고하여 구성하면 된다.
dhcpd.conf 파일 설정이 완료되면 dhcpd 서비스 활성화와 서비스를 시작한다.
# systemctl enable dhcpd && systemctl start dhcpd
TFTP Setup
PXE를 사용한 네트워크 부팅은 tftp 서버를 이용하여 이루어지게 된다. 먼저 tftp server를 설치하도록 하자.
# dnf -y install tftp-server
tftp-server가 완료되면 EFI 부팅 파일을 받아와야 한다. 부팅 파일은 shim, grub2-efi rpm 이미지에서 추출 가능하다. yumdownload를 사용하여 rpm 파일 다운로드 후 추출해도 되며 별도의 yum-utils 패키지 설치가 싫다면 구글에서 위 rpm 검색하여 메뉴얼 다운로드도 가능하다. yumdownload에 관한 내용은 레퍼런스를 참고하면 된다.
rpm 파일에서 efi 이미지를 추출하여 tftpboot 디렉토리에 복사한다.
# rpm2cpio shim-x64-15-15.el8_2.x86_64.rpm | cpio -dimv # rpm2cpio grub2-efi-x64-2.02-87.el8_2.x86_64.rpm | cpio -dimv # cp boot/efi/EFI/centos/grubx64.efi /var/lib/tftpboot/ # cp boot/efi/EFI/centos/shimx64.efi /var/lib/tftpboot/
efi 이미지 복사가 완료되었으면 이번에는 boot image를 준비하도록 한다. 부팅 이미지는 ISO에서 추출해도되지만 간단하게 centos mirror 서버에서 다운로드 가능하다. centos mirror는 레퍼런스 2번 항목을 참고하도록 하자.
부팅 이미지는 /var/lib/tftp/images에 OS별 디렉토리를 만들고 복사하면 된다. Path는 반드시 일정한 규칙을 두고 만들도록 하자.
# mkdir -p /var/lib/tftp/images/centos/8 # cd /var/lib/tftp/images/centos/8 # curl http://mirror.kakao.com/centos/8/BaseOS/x86_64/os/images/pxeboot/vmlinuz -o vmlinuz # curl http://mirror.kakao.com/centos/8/BaseOS/x86_64/os/images/pxeboot/initrd.img -o initrd.img
grub.cfg 설정
UEFI 부팅을 위한 grub.conf 설정을 진행하도록 한다. grub.cfg 파일은 /var/lib/tftpboot에 위치시키고 필수 내용을 입력하도록 한다. CentOS의 anaconda-kickstart를 이용한 OS 자동 설치를 목표로 함으로 inst.ks와 inst.repo를 지정하여 자동 설치가 될수 있도록 한다.
set default="0" function load_video { insmod efi_gop insmod efi_uga insmod video_bochs insmod video_cirrus insmod all_video } load_video set gfxpayload=keep insmod gzio insmod part_gpt insmod ext2 set timeout=1 set repo="http://mirror.kakao.com/centos/8/BaseOS/x86_64/os" set base="http://10.0.0.1:51080/centos" menuentry 'Install CentOS Linux 8' --class fedora --class gnu-linux --class gnu --class os { linuxefi images/centos/8/vmlinuz inst.ks=${base}/8/kickstart/anaconda-ks.cfg inst.repo=${repo} initrdefi images/centos/8/initrd.img }
nginx 설정
grub.cfg에서 kickstart 설정 파일은 Web을 읽어오게 된다. 이부분을 위하여 nginx 서버를 설치해야한다.
# dnf -y install nginx
nginx 설치가 완료되면 /etc/nginx/nginx.conf에서 기본 서비스 포트를 비활성화한다. 그리고 kickstart 파일을 위한 새로운 포트를 열어야 한다. /etc/nginx/conf.d/tftp.conf 파일을 만들고 아래와 같이 내용을 입력한다.
server { listen 51080; root /var/lib/tftp; location / { autoindex on; } }
/var/lib/tftp 디렉토리에 centos/8/kickstart 디렉토리를 만들고 anaconda-ks.cfg 파일을 복사하도록 한다.
전체적인 내용은 간단하지만 dhcp, tftp 그리고 nginx 설정을 완벽하게 해야지만 원격 부팅과 OS 자동 설치가 가능하다. 나중에 기회가 되면 kickstart에 좀 더 세부적으로 다뤄보도록 하겠다.
레퍼런스
- https://docs.centos.org/en-US/centos/install-guide/pxe-server/#sect-network-boot-setup-uefi
Preparing for a Network Installation :: CentOS Docs Site
After setting up a network server containing the package repositories to be used in the installation, the next step is to configure the PXE server itself. This server will contain files necessary to boot the CentOS and start the installation. Additionally,
docs.centos.org
- https://www.redhat.com/sysadmin/pxe-boot-uefi
How to set up PXE boot for UEFI hardware
The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat. The content published on this site are community contributions and are for informational purpose only AND ARE NOT, AND ARE NOT INTENDED TO BE, RED
www.redhat.com
- http://mirror.kakao.com/centos/8/BaseOS/x86_64/os/images/pxeboot/
CentOS Mirror
mirror.kakao.com
UEFI - 나무위키
은(는) 여기로 연결됩니다. OpenAI사가 개발한 인공지능 소프트웨어에 대한 내용은 GPT-3 문서 를 , 에 대한 내용은 문서 를 , 에 대한 내용은 문서 를 , 에 대한 내용은 문서 를 , 에 대한 내용은 문
namu.wiki
반응형'IT' 카테고리의 다른 글
CentOS kickstart example (0) 2021.01.01 Kubernetes Cluster Version 업그레이드 (0) 2021.01.01 Bind Setup Guide (0) 2020.12.05 389 Directory Server 설치 [3] (0) 2020.11.30 389 Directory Server 설치 [2] (0) 2020.11.30