본문 바로가기
I T/Linux

pxe,kickstart 를 이용한 원격 OS 설치

by 루솨 2015. 8. 30.

1. TFTP 설치 및 설정

[root@localhost /]# yum install tftp tftp-server

[root@localhost /]# vi /etc/xinetd.d/tftp

# default: off
# description: The tftp server serves files using the trivial file transfer \
#       protocol.  The tftp protocol is often used to boot diskless \
#       workstations, download configuration files to network-aware printers, \
#       and to start the installation process for some operating systems.

service tftp
{
        disable = no
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /tftpboot
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

 

2. syslinux 설치

[root@localhost /]# yum install syslinux

 

3. DHCP 설치 및 설정

[root@localhost /]# yum install dhcp dhcp-devel

[root@localhost /]# vi /etc/dhcpd.conf

ddns-update-style none;
allow booting;
allow bootp;
default-lease-time 60;
max-lease-time 60;
option subnet-mask              255.255.255.0;
option domain-name-servers      192.168.0.17;
class "pxeclients" {
        match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
        next-server 192.168.0.17;
        filename "pxelinux.0";
}
0subnet 192.168.0.0 netmask 255.255.255.0 {
       # option routers  GATEWAY주소;
        option routers 192.168.0.17;
        #option broadcast-address 브로드캐스트 주소;
        option broadcast-address 192.168.0.255;
        pool {
                allow members of "pxeclients";
                range dynamic-bootp 192.168.0.200 192.168.0.230;
        }
}

 

4. NFS 설치 및 설정

[root@localhost /]# yum install nfs-utils

   ; CentOS 최신버전 다운로드 및 mount

[root@localhost /]# wget http://mirrors.kernel.org/centos/5.5/isos/i386/CentOS-5.5-i386-bin-DVD.iso

[root@localhost /]# mount -t iso9660 -o loop /root/CentOS-5.5-i386-bin-DVD.iso /home/centos5tmp

[root@localhost /]# cp -R /home/centos5tmp /images/centos5

[root@localhost /]# vi /etc/exportfs

/images/centos5 *(ro)
/tftpboot/ *(ro)

[root@localhost /]# exportfs -a

 

5. PXE 환경설정 및 부팅이미지 복사

[root@localhost /]# cd /tftpboot

[root@localhost /]# mkdir centos5.5 ks pxelinux.cfg

[root@localhost /]# cp /usr/share/syslinux/pxelinux.0 /tftpboot/

[root@localhost /]# cp /images/centos5/images/pxeboot/vmlinuz /tftpboot/centos5.5/

[root@localhost /]# cp /images/centos5/images/pxeboot/initrd.img /tftpboot/centos5.5/

[root@localhost /]# vi /tftpboot/pxelinux.cfg/default

timeout=30
default CentOS5.5
label CentOS5.5
kernel centos5.5/vmlinuz
append ksdevice=eth0 initrd=centos5.5/initrd.img network ks=nfs:192.168.0.17:/tftpboot/ks/ks.cfg text

 

6. kickstart 설정

[root@localhost /]# vi /tftpboot/ks/ks.cfg

#install 또는 upgrade
install

# 설치 모드 지정 (이 옵션이 없으면 그래픽 모드로 설치가 진행 됩니다.)
text

# 미러링 서버 지정
# 예) url --url http://centos.mirror.cdnetworks.com/centos/5.4/os/i386
# 예) nfs --server=192.168.0.1 --dir=/mnt/md0
nfs --server=192.168.0.17 --dir=/images/centos5

# 언어선택으로 기본설정 사용.
# langsupport 에 ko_KR.UTF-8 를 추가해주면 한국어 지원.
# 예) langsupport --default=en_US.UTF-8 en_US.UTF-8 ko_KR.UTF-8
lang en_US.UTF-8
langsupport --default=en_US.UTF-8 en_US.UTF-8 ko_KR.UTF-8

# 키보드 설정
keyboard us

# 마우스 설정
mouse none

# 네트웍 설정
# dhcp 로 ip를 가져오지 못하면 고정 ip 설정화면이 나옵니다.
# 아래 주석은 여러가지 형태의 네트웍 설정방법을 예로 보여준 것 입니다.
#network --bootproto dhcp
#network --bootproto static 
network --device eth0 --bootproto dhcp
#network --device eth0 --bootproto static --ip 192.168.0.251--netmask 255.255.255.0 --gateway 192.168.0.1 --nameserv
er 168.126.63.1 --hostname sunxxx

# root 패스워드 입니다. 원하시는걸로 바꾸시면됩니다.
rootpw --iscrypted $1$5aH5feJ4$hV4mobHAt8w39MKlqIWOM.

# firewall 설정 단계로 개인적으로 os 설치완료후 설정할 것을 권장합니다.
firewall --disabled

# selinux 설정 단계로 완벽하게 이해 하지 못한다면 disabled 하는것을 권장합니다.
selinux --disabled

# 시스템에서 사용될 인증 옵션을 설정합니다. 기본값 사용
authconfig --enableshadow --enablemd5

# timezone 설정
timezone --utc Asia/Seoul

# 부트로더 설정
bootloader --location=mbr --driveorder=sda --append="rhgb quiet"

# 시스템에 있는 모든 파티션을 삭제 합니다.
clearpart --initlabel --all

# 파티션을 나눕니다.
part / --fstype ext3 --size=4096 --ondisk=sda
part swap --size=16384 --ondisk=sda
part /tmp --fstype ext3 --size=2048 --ondisk=sda
part /var --fstype ext3 --size=4096 --ondisk=sda
part /usr --fstype ext3 --size=10240 --ondisk=sda
part /home --fstype ext3 --size=1 --grow --ondisk=sda
#reboot

# 패키지를 선택합니다. (나머지는 설치 완료 후 yum 으로 설치)
%packages
@development-tools
ntp
net-snmp
net-snmp-devel

# 설치 후 실행할 쉘스크립트
%post
wget -q -O - http://linux.dell.com/repo/hardware/latest/bootstrap.cgi|bash
yum install -y srvadmin-all

yum update

 

7. 서비스 시작(순서대로!!)

[root@localhost /]# service xinetd start

[root@localhost /]# service dhcpd start

[root@localhost /]# service portmap start

[root@localhost /]# service nfs start