2019/12/03

PXE 부팅 자동화

주의 네트웍크 환경을 잘 분석해야 한다.
무선 공유기 장비의 경우 내부 아이피 공급 방식인 DHCP 관련해 정지 시킨다.
무선 공유기 DHCP 서비스를 계속 할 경우 TFTP를 통해 가지고온 설정 파일에서 문제가 발생할 수 있다.
결론적으로 문선 공유기를 하나의 망으로 통합해 사용한면 된다.

DHCP Server // 대상 컴퓨터의 IP주소 할당)
TFTP Server // 부팅에 필요한 커널을 내려준다)
HTTP Server // 응답파일(preseed.cfg)을 내려준다)
Ubuntu CD image // os설치에 필요한 파일(netboot)

1. DHCP 설정
#apt-get install isc-dhcp-server

설정 파일
=========
추가해야할 설정 파일
vi /etc/dhcp/dhcpd.conf

option domain-name-servers 8.8.8.8;  // dns 주소
default-lease-time 600;
max-lease-time 7200;
authoritative;

subnet 192.168.0.0 netmask 255.255.255.0 {
        range 192.168.0.80 192.168.0.85; // DHCP IP 할당 대역
        filename "pxelinux.0";  // Ubuntu 설치 부팅 이미지
        next-server 192.168.0.82; // TFTP 서버가 될 주소
        option subnet-mask 255.255.255.0;
        option broadcast-address 192.168.0.255;
        option routers 192.168.0.1;
}

현재서버 설정 파일
==================
vi /etc/dhcp/dhcpd.conf
# DHCP server is authoritative for all networks
authoritative;

# extra options
# RFC3442 routes
option rfc3442-classless-static-routes code 121 = array of integer 8;
# MS routes
option ms-classless-static-routes code 249 = array of integer 8;

pid-file-name "/var/run/dhcp-server/dhcpd.pid";

ddns-update-style none;

option domain-name-servers 210.220.163.82, 219.250.36.130;

allow booting;
allow bootp;

default-lease-time 1800;
max-lease-time 7200;


        shared-network br1 {



                next-server 211.211.23.22;
                option tftp-server-name "211.211.23.22";
                filename    "pxelinux.0";


    subnet 172.16.1.0 netmask 255.255.255.0 {
             
            option routers 172.16.1.1;
            option domain-name "fw.fairlieai.net";
            option domain-name-servers 172.16.1.1, 8.8.8.8;
                option ntp-servers 172.16.1.1;
                default-lease-time 1800;
                max-lease-time 7200;


            pool {
             

             

                range 172.16.1.2 172.16.1.100;
            }
        }

        group {
         
            option routers 172.16.1.1;
            option domain-name "fw.fairlineai.net";
            option domain-name-servers 172.16.1.1, 8.8.8.8;
                option ntp-servers 172.16.1.1;
                default-lease-time 1800;
                max-lease-time 7200;


        }




}


보안장비 DHCP 메뉴 선택 후  곱급 설정으로 이동 후 설정 한다.

Thin client / External TFTP-Server
다음 서버: 호스트 -> 172.16.1.1 또는 다음 서버: 기본설정
파일 경로 : pxelinux.0

서비스 재 시작
#server isc-dhcp-server start  또는 /etc/init.d/isc-dhcp-server start


2. TFTP 설치
#apt-get install tftpd-hpa

보안 기능으로 설정 방법.
========================
vi /etc/default/tftpd-hpa

# /etc/default/tftpd-hpa

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot" // tftp-hpa 설치하면 자동으로 생성됨
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"

전체 접근 설정 방법.
====================
vi /etc/default/tftpd-hpa

# /etc/default/tftpd-hpa
TFTP_USERNAME="nobody"
TFTP_DIRECTORY="/var/lib/tftpboot"  // tftp-hpa 설치하면 자동으로 생성됨
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"

설비스 재 시작
server tftpd-hpa start  또눈  /etc/init.d/tftpd-hpa start

서비스 실행확인
ss -ua

3. http
apt-get install apache2

아파치 웹 서버 설치시 자동으로 데몬이 구동되어 따로 설정할 필요가 없음.
자동화된 설치 응답 파일 preseed.cfg을 웹 서버의 루트 디렉토리 /var/www/에 복사하면 된다.

preseed.cfg 파일은 킥스타트 설정 프로그램(system-config-kickstart)으로 생성화면 된다.

4. Netboot 다운
네트워크 설치를 위해 netboot안에 있는
- pxelinux.0
- pxelinux.cfg
- ubuntu-installer
- version.info

4개의  파일들이 필요함.

4개의 파일을 구하는 방법은 여러가지가 있음. 여기서는 기존 이미지를 마운트해 사용하는 방법을 소개 함.

현재 우리가 사용하고 있는 버전 ubuntu-16.10-server-amd64.iso 이므로 이 파일을 다운로드 한다.

iso 파일 마운트
mount ubuntu-11.10-server-amd64.iso /mnt/

tftp 공간으로 이동
cp –a /mnt/install/netboot/* /var/lib/tftpboot/

인터넷에서 다운로드 후 파일 압축 해제.
wget http://archive.ubuntu.com/ubuntu/dists/yakkety-updates/main/installer-amd64/current/images/netboot/netboot.tar.gz
cd /var/lib/tftpboot/
tar zxvf netboot.tar.gz

여기 까지 진행 하면은 부팅 준비 된 상태가 된다.
하지만 자동 설치는 되지 않으면서, 수동으로 설치가 된다.

5. 설치 자동화
부팅 관련 화면 이미지 위치
/var/lib/tftpboot/ubuntu-installer/amd64/boot-screens

자동 설치를 위해 Automated Install 메뉴 추가
기존 스크립트 하단에 추가

vi txt.cfg
default install
label install
        menu label ^Install
        menu default
        kernel ubuntu-installer/amd64/linux
        append vga=788 initrd=ubuntu-installer/amd64/initrd.gz --- quiet
label cli
        menu label ^Command-line install
        kernel ubuntu-installer/amd64/linux
        append tasks=standard pkgsel/language-pack-patterns= pkgsel/install-language-support=false vga=788 initrd=ubuntu-installer/amd64/initrd.gz  -quiet

label automated
menu label ^Automated Install
menu default
kernel ubuntu-installer/amd64/linux
#append auto=true priority=critical vga=normal initrd=ubuntu- installer/amd64/initrd.gz url=http://yakkety.fw.fairlineai.net/preseed.cfg –quiet
append auto=true priority=critical vga=788 initrd=ubuntu-installer/amd64/initrd.gz preseed/url=tftp://192.168.11.66/preseed.cfg preseed/interactive=false

응답파일 pressed.cfg 작성
응답파일 설정은 다양하다. 네트웍크 설정, 패키지 선택등을 설정할 수 있다.
system-config-kickstart GUI 통해 설정 할 수 있으며, 텍스트 방법으로 설정 할 수 있다.

텍스트 방법으로 설정하는 내용을 설명한다.
vi /var/www/preseed.cfg
### Contents of the preconfiguration file
### Localization
# Locale sets language and country.
# d-i debian-installer/locale string en_US // 영문설치
d-i debian-installer/locale string ko_KR

# Keyboard selection.
# Disable automatic (interactive) keymap detection.
d-i console-setup/ask_detect boolean false
#d-i console-setup/modelcode string pc105
d-i console-setup/layoutcode string us

### Network configuration
# netcfg will choose an interface that has link if possible. This makes it
# skip displaying a list if there is more than one interface.
d-i netcfg/choose_interface select auto

# Any hostname and domain names assigned from dhcp take precedence over
# values set here. However, setting the values still prevents the questions
# from being shown, even if values come from dhcp.
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain

# Disable that annoying WEP key dialog.
d-i netcfg/wireless_wep string
### Mirror settings
# If you select ftp, the mirror/country string does not need to be set.
d-i mirror/country string manual
d-i mirror/http/hostname string archive.ubuntu.com
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string

# Suite to install.
d-i mirror/suite string lucid; // 이 부분을 버전 이름을 입력한다. 16.10의 경우 yakkety 로 변경 해준다.

### Clock and time zone setup
# Controls whether or not the hardware clock is set to UTC.
d-i clock-setup/utc boolean true

# You may set this to any valid setting for $TZ; see the contents of
# /usr/share/zoneinfo/ for valid values.
d-i time/zone string Asia/Seoul

# Controls whether to use NTP to set the clock during the install
d-i clock-setup/ntp boolean true

### Partitioning
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-auto/purge_lvm_from_device boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-auto/choose_recipe select atomic
d-i partman-auto/expert_recipe string                         \
      boot-root ::                                            \
              40 50 100 ext4                                  \
                      $primary{ } $bootable{ }                \
                      method{ format } format{ }              \
                      use_filesystem{ } filesystem{ ext4 }    \
                      mountpoint{ /boot }                     \
              .                                               \
              500 10000 1000000000 ext4                       \
                      method{ format } format{ }              \
                      use_filesystem{ } filesystem{ ext4 }    \
                      mountpoint{ / }                         \
              .                                               \
              64 512 300% linux-swap                          \
                      method{ swap } format{ }                \
              .
### Account setup
# To create a normal user account.
d-i passwd/user-fullname string ubuntu
d-i passwd/username string master
# Normal user's password, either in clear text
d-i passwd/user-password password nds1101
d-i passwd/user-password-again password nds1101

### Package selection
tasksel tasksel/first multiselect ubuntu-server

# Individual additional packages to install
d-i pkgsel/include string openssh-server build-essential
### Boot loader installation
# This is fairly safe to set, it makes grub install automatically to the MBR
# if no other operating system is detected on the machine.
d-i grub-installer/only_debian boolean true

### Finishing up the installation
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note

※ 아이피를 DHCP로 받아오지 않고 고정IP로 설정해주려면 위에 Network 부분을아래와 같이 설정 해준다.
==================================================================================================
d-i netcfg/disable_dhcp boolean true
d-i netcfg/get_nameservers string 8.8.8.8
d-i netcfg/get_ipaddress string 192.168.0.85
d-i netcfg/get_netmask string 255.255.255.0
d-i netcfg/get_gateway string 192.168.0.1
d-i netcfg/confirm_static boolean true

6. 클라이 인트 부팅
이제 설치 대상 컴퓨터를 부팅하면 tftp로부터 부팅 이미지를 받고 응답파일을 읽
어 자동으로 패키지를 내려받아 설치가 된다.
※ 부팅하기전에 CMOS 에 boot 로 들어가서 부팅순서를 cd-rom 보다 network
우선순위로 해줘야 한다.
CMOS들어가는 방법은 부팅할때 부팅화면 나오기전에 Delete키를 눌러주면된다.
컴퓨터 마다 달라서 F1,F2 키인 경우도 있다.

댓글 없음:

댓글 쓰기