본문 바로가기

LINUX

PXE Server 설치 및 구성(CentOS 6 or 7)

반응형

PXE Server는 네트워크를 통해 하나의 서버에서 다수의 클라이언트로 배포, 패치 등을 set up 할 수 있는 서버입니다.

보통 인프라 쪽에서 자주 사용하는 기능입니다. OS를 install 하거나 패치를 배포하거나 kickstart 등을 구성하여 시간이 많이 드는 반복 작업 등을 자동화할 수 있습니다.

 

 

 

설치 환경은 기본적으로 방화벽 비활성화에 selinux 가 disable 되어 있습니다.

 

root 계정으로 합니다.

 

먼저 패키지를 설치해 줍니다.

 

* uefi와 lagacy모드의 설정이 다릅니다.

 

tftp의 경우 ftp랑 똑같이 파일 전송 서버 역할을 합니다. 좀더 가볍고 간단하게 구성할 수 있습니다.

http의 경우 웹 서버 역할을 할 것입니다.

syslinux는 부팅에 필요한 파일들이 있습니다.

xinetd의 경우는 centos6 버전까지 슈퍼데몬이라고 불리며 네트워크에 관련된 기능을 대신해줍니다. xinetd 안에 tftp, http 등 네트워크 관련된 데몬이 있어 xinet이 올라가 있어야 합니다.

 

yum -y install httpd xinetd syslinux tftp-server

 

필요 파일들을 모읍니다.

 

mkdir -p /var/www/html/tftpboot/uefi

mkdir -p /var/www/html/tftpboot/pxelinux.cfg

 

 

Centos ISO 파일을 마운트 합니다.

 

mount /dev/[ISO 장치] /mnt

 

-UEFI

 

cd /mnt/EFI/BOOT

cp grub.cfg grubx64.efi /var/www/html/tftpboot/uefi

 

추가로 shim.efi 파일이 /var/www/html/tftpboot/uefi 밑에 있어야 합니다.

 

검색하셔서 rpm 파일로 받으시면 됩니다.

 

 

- lagacy

 

해당 경로로 갑니다.

cd /usr/share/syslinux/

 

아래 파일들을 복사합니다.

cp pxelinux.0 menu.c32 memdisk mboot.c32 chain.c32 /var/www/html/tftpboot/pxelinux.cfg

 

tftp 파일을 수정합니다.

vi /etc/xinetd.d/tftp

 

server_args            = -s /var/www/html/tftpboot

disable                 = no

 

 

grub.cfg 파일과 default 파일을 수정해 줍니다.

 

vi /var/www/html/tftpboot/uefi/grub.cfg

 

각각의 설정은 환경에 맞게 수정해 주시면 됩니다.

 

set default="1"

function load_video {
 insmod efi_gop
 insmod efi_uga
 insmod video_bochs
 insmod video_cirrus
 insmod all_vidoe
}

load video
set gfxpayload=keep
insmmod gzio
insmod part_gpt
insmod ext2

set timeout=10

menuentry 'RHEL 7' {
  linuxefi redhat7/vmlinuz inst.repo=http://192.168.0.55/redhat74 ip=dhcp inst.ks=http://192.168.0.55/ks/TEST.cfg
  initrdefi redhat7/initrd.img
}
 

 

 

 

vi /var/www/html/tftpboot/pxelinux.cfg/default

 

#default vesamenu.c32
default menu.c32
prompt 0
timeout 600

display boot.msg

label linux
  menu label ^Install redhat7_R340
  menu default
  kernel vmlinuz
  append initrd=initrd.img ip=dhcp inst.repo=http://192.168.0.55/redhat74
label vesa
  menu label Install system with ^basic video driver
  kernel vmlinuz
  append initrd=initrd.img ip=dhcp inst.xdriver=vesa nomodeset inst.repo=http://192.168.0.55/redhat74
label rescue
  menu label ^Rescue installed system
  kernel vmlinuz
  append initrd=initrd.img rescue
label local
  menu label Boot from ^local drive
  localboot 0xffff
 

간단히 해석하면 kernel은 vmlinuz를 쓰고 이미지는 initd.img를 쓰고 ip는 DHCP로 자동 할당받고 저장소는 192.168.0.55/redhat74 경로를 이용하겠다.

이미지 구성 후 192.168.0.55/ks/TEST.cfg 파일을 이용하여 kickstart 구성을 하겠다.

 

 

 

이제는 redhat7 밖에 없지만 원래 redhat 6도 있었습니다.

필요에 따라 추가하시면 됩니다.

 

이제 DHCP 서버를 구성합니다.

 

vi /etc/dhcp/dhcpd.conf

 

# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.example
#   see dhcpd.conf(5) man page
#

option space pxelinux;
  option pxelinux.magic code 208 = string;
  option pxelinux.configfile code 209 = text;
  option pxelinux.pathprefix code 210 = text;
  option pxelinux.reboottime code 211 = unsigned integer 32;
option architecture-type code 93 = unsigned integer 16;

  subnet 192.168.0.0 netmask 255.255.255.0 {
    allow booting;
    allow bootp;
    option routers 192.168.0.55;
    range 192.168.0.150 192.168.0.230;

    class "pxeclients" {
      match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
      next-server 192.168.0.55;

      if option architecture-type = 00:07 {
        filename "uefi/shim.efi";
      } else {
        filename "pxelinux.cfg/pxelinux.0";
      }
    }
  }

 

 

 

centos6

 

이제 서비스 재시작합니다.

 

service xinetd restart

service dhcpd restart

service httpd restart

 

 

재부팅 시에도 시작하려면 

 

chkconfig xinetd on

chkconfig dhcpd on

chkconfig httpd on

 

 

centos7

 

systemctl restart httpd

systemctl restart tftpd

systemctl restart dhcpd

 

systemctl enable httpd

systemctl enable tftpd

systemctl enable dhcpd

 

 

 

반응형

'LINUX' 카테고리의 다른 글

하모니카 OS 설치  (2) 2021.11.11
CentOS 라우팅 테이블(Routing Table) && 마운트(Mount)  (0) 2021.10.30
PXE Server Kickstart 구성 및 script  (0) 2021.10.06