본문 바로가기

넋두리/linux 이야기

PXE boot/install 서버만들기.

참고문서:
http://www.serenux.com/2010/05/howto-setup-your-own-pxe-boot-server-using-ubuntu-server/
https://help.ubuntu.com/community/DisklessUbuntuHowto
https://help.ubuntu.com/community/PXEInstallServer

1. boot 서버로 사용할  사설 ip주소를 eth1 에 설정. /etc/network/interfaces 화일에 아래 내용 추가

# Secondary network interface… For private…
auto eth1
iface eth1 inet static
address 172.16.1.1
netmask 255.255.0.0
network 172.16.0.0
broadcast 172.16.255.255

2. tftp, dhcp, 서버 설치.

# apt-get install dhcp3-server tftp-hpa syslinux

3. tftp 서버 설정.

/etc/default/tftpd-hpa 화일에 아래 내용을 추가한다.

아래는 tftp를 standalone으로 실행하며, root디렉토리를 /tftpboot로 설정하는 경우다.

RUN_DAEMON=”yes”
TFTP_OPTIONS=”-l”
TFTP_USERNAME=”tftp”
TFTP_DIRECTORY=”/tftpboot”
TFTP_ADDRESS=”0.0.0.0:69″

위와같이 설정한후, /tftpboot에 부트 화일을 넣어준다. 여기서, 부팅에 필요한 화일들은 cdrom이나 iso를 /mnt/tmp에 마운트 하여 복사한다.

# mkdir -p /tftpboot
# cp /mnt/tmp/install/netboot/pxelinux.0 /tftpboot/
# cd /mnt/tmp/install/netboot/ubuntu-installer/amd64/
# mkdir -p /tftpboot/ubuntu-installer/amd64
# cp -R boot-screens/ /tftpboot/ubuntu-installer/amd64
# cp initrd.gz linux /tftpboot/ubuntu-installer/amd64/

pxe booting을 위한 환경화일을 만든다.

# mkdir -p /tftpboot/pxelinux.cfg
# vi /tftpboot/pxelinux.cfg/default/

include ubuntu_menu.cfg
default ubuntu-installer/amd64/boot-screens/vesamenu.c32
prompt 0
timeout 100

# vi /tftpboot/ubuntu_menu.cfg
menu hshift 13
menu width 49
menu margin 8
menu title My Customised Network Boot Menu
include ubuntu-installer/amd64/boot-screens/stdmenu.cfg
menu begin Cool options
default myfirstoption
label myfirstoption
menu label This is a menu item
label mysecondoption
menu label This is another option
menu end

# chmod 777 /tftpboot

4. dhcp 서버 설정. /etc/dhcp/dhcpd.conf

allow booting;
allow bootp;
subnet 172.16.0.0 netmask 255.255.0.0 {
range dynamic-bootp 172.16.1.2 172.16.1.254;
option broadcast-address 172.16.255.255;

filename “/tftpboot/pxelinux.0″;
}

PXE 부팅이 잘 되는지 확인.

5. booting & install 서버를 만들기.

OS 화일을 웹서버에 복사한다.(웹서버는 이미 구성되어 있고, document root 는 /var/www )

 # cd /var/www
# mkdir ubuntu12.04
# cp -r /mnt/tmp/* /var/www/ubuntu12.04/

웹서버의 DocumentRoot에 ks.cfg (kick start)화일을 만든다.

# vi /var/www/ks.cfg
install
url –url http://172.16.1.1/ubuntu12.04/

부트서버의 plelinux.cfg 디렉토리를 준비한다.

# cp -rf /mnt/tmp/install/netboot/* /tftpboot/
cp: cannot overwrite directory `/tftpboot/pxelinux.cfg’ with non-directory

# cp -rf /mnt/tmp/install/netboot/* /tftpboot/

/tftpboot/ubuntu-installer/amd64/boot-screens/adtxt.cfg를 아래와 같이 수정

label expert(PXE Install)
menu label ^Expert install
kernel ubuntu-installer/amd64/linux
append ks=http://172.16.1.1/ks.cfg priority=low vga=normal initrd=ubuntu-installer/amd64/initrd.gz –

/tftpboot/ubuntu-installer/amd64/boot-screens/txt.cfg를 아래처럼 수정

default install
label install
menu label ^Install
menu default
kernel ubuntu-installer/amd64/linux
append ks=http://172.16.1.1/ks.cfg vga=normal initrd=ubuntu-installer/am
d64/initrd.gz — quiet