IT2010. 10. 20. 00:02
반응형

Debian GNU/Linux 3.0 네트워크 부팅 HOWTO

DHCP, BpBatch, TFTP, NFS의 이해 및 설정

이희(李熙, Hee Lee) me@leehee.pe.kr

최종 수정 날짜 2002년 11월 28일 Since 2002.11.19.
본 문서는 Debian GNU/LINUX 3.0(Woody)을 기반으로 DHCP(Dynamic Host Configuration Protocol),BpBatch(a versatile remote-boot processor),TFTP(Trivial File Transfer Protocol),NFS(Network File System)를 이용한 네트워크 부팅을 설명하고 있다. 본 문서 중 오타나 잘못된 부분이 있으면 위의 이메일 주소로 연락바랍니다.

1. 네트워크 부팅 개요

네트워크 부팅의 목적

같은 기능을하는 여러 서버들을 하나의 네트워크 부팅 서버를 두어 각각의 서버들에 별도의 OS 설치 없이 부팅이 가능하게끔 해주는것에 목적이 있다. 그리고 각각 서버에 OS 설치하는 시간이나 어떠한 작업에 있어서의 시간을 단축시켜주는 효과도 있다.

네트워크 부팅 준비

  • PXE부팅을 지원하는 다수의 머신
  • Debian GNU/Linux 3.0 설치를 위한 CD 또는 디스켓
  • DHCP 3.0
  • TFTP
  • NFS
  • BpBatch
※ 별도의 사이트에서 다운로드 해야되는 것들 : Debian GNU/Linux 3.0( http://www.debian.org) , BpBatch( http://www.bpbatch.org)

네트워크 부팅 과정 요약

  1. 네트워크 부팅 클라이언트 서버 부팅
  2. PXE부팅에 의해 DHCP서버에서 IP를 부여받음
  3. TFTP를 이용하여 부트 프로세서인 bpbath를 다운
  4. bpbatch 스크립트 파일의 설정에 따라 커널을 로딩하고 본격적으로 리눅스 부팅 시작
  5. 커널 파라메터의 nfsroot 옵션에 의해 NFS로 네트워크 부팅 서버의 nfsroot를 공유
  6. 공유된 파일시스템의 설정에 따라 부팅

2. 네트워크 부팅 서버 구축

2.1 TFTP 설정

※ 참고 : RFC1350(TFTP) [Korean, TEXT]

TFTP 데몬 설치

Debian GNU/Linux의 dselect를 이용하여 설치를 한다. 독립적으로 데몬이 실행되지않고 inetd데몬에 의해 실행된다.

TFTP의 역할

부팅과정에서 클라이언트가 요청하는 파일들을 전송해준다.

TFTP 설정 파일


        .        .        #:BOOT: Tftp service is provided primarily for booting.  Most sites        # run this only on machines acting as "boot servers."        tftp            dgram   udp     wait.200        nobody  /usr/sbin/tcpd  /usr/sbin/in.tftpd /tftpboot        .        .        

※ TFTP 설정의 예 ( /etc/inetd.conf )

wait.200에서의 200이라는 숫자는 클라이언트의 접속 제한수이다. 그리고 /tftpboot는 TFTP 전송과정에서 root로 인식되는 디렉토리이다. 이 디렉토리안에 BpBatch 부트 프로세스 및 스크립트 파일과 커널 이미지를 넣어두게 된다. 처음 설치시 기본 설정은 wait라고만 되어있고 /boot라는 디렉토리로 되어있다. 그리고 마지막으로 설정을 변경한 후 반드시 /etc/init.d/inetd restart를 해줘야 적용된다는 점 잊지말도록 하자.

2.2 DHCP 설정

※ 참고 : RFC2131(DHCP) [Korean, TEXT] , DHCP mini-HOWTO [English, HTML] , DHCP HOWTO [Korean, HTML] , DHCP mini-HOWTO [Korean, TEXT]

DHCP Server 데몬 설치

DHCP Server 데몬도 역시 dselect를 이용하여 3.0 버전을 설치한다. 버전에 따라 설정이 약간 변경되므로 반드시 3.0을 설치하도록 한다. 데몬의 시작,재시작,정지 : /etc/init.d/dhcp3-server start (,restart, stop)

DHCP의 역할

클라이언트 첫 부팅시 해당 Mac AddressIP Address를 부여하고 bpbatch 부트 프로세스의 위치와 스크립트의 위치를 알려준다.

DHCP 설정 하기

MULTICAST 설정

프로그램을 설치한 후에는 커널이 멀티캐스팅을 지원하고 있는지 확인해 보아야 합니다. 멀티캐스트란 로컬 머신과 네트워크사이에서 인터넷 연결 등의 상호작용을 지원하는 기능을 말합니다. 현재 대부분의 시스템에서 기본적으로 지원되고 있으며, 아래와 같은 명령어로 확인해 볼 수 있습니다.


        [root@ns52 init.d]# ifconfig eth0        eth0      Link encap:Ethernet  HWaddr 00:D0:B7:67:12:4E          inet addr:192.168.5.202  Bcast:192.168.5.255  Mask:255.255.0.0        UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1        RX packets:196646358 errors:0 dropped:0 overruns:0 frame:3693        TX packets:192442883 errors:0 dropped:0 overruns:77 carrier:567238        collisions:1266207 txqueuelen:100         RX bytes:1776455888 (1.6 GiB)  TX bytes:1222822803 (1.1 GiB)        Interrupt:10         

위표와같이 MULTICAST를 지원하면 다음설정으로 넘어가고, 지원하지 않는다면 멀티캐스팅을 지원하도록 커널 컴파일을 다시 해야합니다.

DHCP클라이언트와 DHCP서버가 서로 통신을 하려면, 먼저, 255.255.255.0의 IP주소에 정보를 보낼 수 있어야 합니다. 하지만, subnet broadcast 주소가 네트워크에 따라서 다를 수 있으므로, 이 주소에 대한 설정에 주의를 해야 합니다. 만약에 그렇지 않으면, DHCP서버로부터 DHCPOFFER 메시지를 클라이언트에서 보게 될 것입니다.

이제 아래의 명령어로 브로드캐스트 라우터를 만들어 줍니다.


        # route add -host 255.255.255.255 dev eth0        

네트워크 카드의 이름에 eth0가 사용되었지요. 사용하고 계신 시스템환경에 따라 이름이 다를 수 있으므로 ifconfig -a 명령어를 사용해서 네트워크 카드의 이름을 확인한 후 입력하시기 바랍니다.


        255.255.255.255: Unknown host        

만일 위와 같은 메시지가 나타나면 vi 에디터로 /etc/hosts 파일을 열고 아래의 내용을 추가합니다.


        255.255.255.255 reroute        

※ 재부팅시 적용되게 하기위해 /etc/init.d/rcS 마지막에 route add -host 255.255.255.255 dev eth0 를 추가해준다.

/etc/dhcp3/dhcpd.conf 설정


        #        # dhcpd.conf        #        # DHCP configuration file for DHCP ISC 3.0 & BpBatch        #        #        # Definition of PXE-specific options        #        option option-135       code 135 = text;        #        # Use this to send dhcp log message to a different log file        # (You also have to hack syslog.conf to complete the redirection).        #        log-facility local7;        #        # Subnet-specific options (eth0)        #        subnet 192.168.0.0 netmask 255.255.0.0 {        option domain-name-servers 192.168.5.202;        option broadcast-address 255.255.255.255;        option routers 192.168.5.202;        option subnet-mask 255.255.0.0;        next-server 192.168.5.202;        filename "bpbatch/bpbatch";        option option-135 "bpbatch/bpbatch";        default-lease-time -1;        deny unknown-clients;        #        # Host specific options        #        host s830 {        hardware ethernet 00:03:47:BD:46:4B;        fixed-address 192.168.5.30;        }        host s832 {        hardware ethernet 00:02:B3:2F:A4:38;        fixed-address 192.168.5.32;        }        .        .        .        .        .        host s888 {        hardware ethernet 00:D0:B7:9A:21:0E;        fixed-address 192.168.5.88;        }        host s889 {        hardware ethernet 00:D0:B7:9A:1C:40;        fixed-address 192.168.5.89;        }        host s890 {        hardware ethernet 00:D0:B7:67:10:AA;        fixed-address 192.168.5.90;        }        }        

※ DHCP 설정 파일의 예 ( /etc/dhcp3/dhcpd.conf )

filename "bpbatch/bpbatch";라고 되어있는 부분을 잠깐 살펴보자. 따옴표안의 파일 경로는 /tftpboot/의 상대 경로이다. 그리고 option option-135 "bpbatch/bpbatch";는 실행시킬 스크립트파일의 위치인데 확장자 .bpb를 생략하고 써주는것을 명심하고 3.0 이전 버전과 달리 option option-135 code 135 = text;라고 옵션에 대한 용도를 앞부분에서 선언을 해줘야한다는것을 기억하자.

DHCP로그를 위한 설정

/etc/syslog.conf

적당한 위치에 local7.* /var/log/dhcp.log추가한다.

2.3 BpBatch 설정

※ 참고 : Linux Remote-Boot mini-HOWTO [English, PDF] , Linux remote-boot quick guide [English, HTML]

BpBatch 설치

BpBatch 공식 사이트( http://www.bpbatch.org)를 방문하여 BpBatch (tar.gz)를 다운 받는다. 압축을 풀면 여러 파일들이 있는데 이중에서 필요한 파일은 bpbatch.Pbpbatch.ovl이다. 이 두 파일을 /tftpboot/bpbatch/디렉토리를 생성하여 복사해 넣는다. bpbatch.Pbpbatch로 파일명을 바꿔준다.

BpBatch의 역할

BpBatch는 부트 프로세서로서 부트 이미지가 없는 클라이언트에 TFTP를 통해 전송되어 클라이언트가 부팅할 수 있게해준다.

BpBatch 스크립트 파일

/tftpboot/bpbatch/bpbatch.bpb

BpBatch 스크립트 파일은 BpBatch 이미지와 같은 디렉토리(/tftpboot/bpbatch/)에 .bpb라는 확장자로 만들어주면 된다.


        #        # bpbatch.bpb        #        ShowLog        Set CacheNever = "On"        linuxboot "kernel-image/kernel-2.4.19" "root=/dev/nfs nfsroot=/nfsroot ip=:192.168.5.202::::eth0:both"        

※ bpbatch 스크립트 파일의 예 ( /tftpboot/bpbatch/bpbatch.bpb )

이 스크립트 파일의 예는 kernel 2.4.18 이상 버전의 경우이다. 커널버전이 2.4.18 미만의 경우에서는 커널 파라메터가 "root=/dev/nfs nfsroot=192.168.5.202:/nfsroot"가 되어야한다. 이렇게 2.4.18이상일때와 이전과 다른 이유는 kernel level ip auto-configuration support의 소스가 약간 변경되어 파라메터 방식이 변경되서이다.

2.4 커널 설정

클라이언트 커널 컴파일시 확인해야하는 설정(커널버전 2.4.19기준)

Processor type and features --->

(4GB) High Memory Support

[*] Symmetric multi-processing support

Block devices --->

<*> Loopback device support

<*> RAM disk support

Networking options --->

[*] IP: kernel level autoconfiguration

[*] IP: DHCP support (NEW)

File systems --->

Network File Systems --->

<*> NFS file system support

[*] Root file system on NFS

2.5 NFS 설정

NFS 데몬 설치

dselect를 실행하여 nfs-kernel-server를 설치한다. 시작,재시작,중지는 /etc/init.d/nfs-kernel-server start (,restart,stop) 이렇게 하면된다. 무리없이 잘 될것이다.

NFS의 역할

클라이언트가 처음 부팅시 사용할 root file system를 공유해서 사용하기 위해서 NFS가 필요하다. 그리고 또다른 필요한 디렉토리를 공유해서 사용하기 위해서 필요로한다.

NFS 설정 파일


        # /etc/exports: the access control list for filesystems which may be exported        #               to NFS clients.  See exports(5).        /nfsroot                *(rw,no_root_squash)        /home                   *(rw,no_root_squash)        

※ NFS 설정 파일의 예 ( /etc/export )

/nfsroot 디렉토리 구성

서버의 것과 동일하게 복사를 할 디렉토리

  • /sbin
  • /bin
  • /usr
  • /root
  • /dev
  • /etc - 복사한 후 수정 필요
  • /lib
  • /var.common - 서버의 /var 를 이름을 바꾸어 복사
  • /var.orig - /var.common의 내용과 동일하나 일부는 /var.common의 심볼릭 링크로 변경
빈 디렉토리만 생성(NFS서버를 통해 Mount를 하기위함, 그냥 빈 디렉토리로 존재 또는 RAM Disk에 Mount하기 위함)
  • /home
  • /var - RAM Disk를 만들어 Mount시킨다.
  • /tmp
  • /floppy
  • /initrd
  • /local1 - 클라이언트에 붙어있는 하드디스크를 Mount하기위한 디렉토리
  • /local2 - 클라이언트에 붙어있는 하드디스크를 Mount하기위한 디렉토리
  • /lost+found
  • /mnt
  • /opt
  • /proc
※ 주의 사항 : 디렉토리를 복사할때 -a 옵션으로 해야한다. 디렉토리나 파일의 퍼미션의 정보도 그대로 복사하기 위함이다. 그렇지않을 경우 클라이언트 부팅시 에러가 발생한다. 그리고 빈디렉토리를 생성할때도 서버의 퍼미션을 그대로 적용시키도록한다.

var.common , var.orig의 용도

네트워크 부팅 클라이언트에서 /var 디렉토리는 임시로 사용하는 디렉토리라서 서버에 반드시 저장할 필요가 없다. 그래서 RAM Disk에 마운트해서 사용을 하는데 /var 안의 내용중 용량이 큰것은 RAM Disk의 용량의 제약으로 저장하기 힘들다. 그래서 var.common이라는 디렉토리안에 저장하고 /var 에서 링크하여 사용하게된다. 추후에 RAM Disk에 /var를 마운트 시키는 과정을 보면 /var.orig 이라는 디렉토리를 /var에 복사를 하게끔 되어있다. /var.orig 디렉토리는 원래의 데이터와 /var.common의 내용을 링크하는 파일들로 구성되어있다. 용량이 크고 내용이 거의 바뀌지 않는 것들은 링크로 되어있고 그렇지 않은 경우는 원래 디렉토리, 파일로 되어있다.


        total 52        drwxr-xr-x   13 root     root         4096 Oct 30 08:43 .        drwxr-xr-x   22 root     root         4096 Oct 30 05:34 ..        drwxr-xr-x    6 root     root         4096 Oct 30 00:10 cache        drwxr-xr-x   12 root     root         4096 Nov 11 15:20 lib        

※ /var.common의 예


        total 36        drwxr-xr-x    9 root     root         4096 Nov 11 17:54 .        drwxr-xr-x   22 root     root         4096 Oct 30 05:34 ..        lrwxrwxrwx    1 root     root           19 Oct 30 01:53 cache -> ../var.common/cache        lrwxrwxrwx    1 root     root           17 Oct 30 01:53 lib -> ../var.common/lib        drwxrwsr-x    2 root     staff        4096 Feb  9  2002 local        drwxrwxrwt    2 root     root         4096 Feb  9  2002 lock        drwxr-xr-x    5 root     root         4096 Nov 11 17:21 log        drwxr-xr-x    2 root     root         4096 Oct 30 08:43 opt        drwxr-xr-x    5 root     root         4096 Nov 11 17:22 run        drwxr-xr-x    3 root     root         4096 Nov 11 17:55 spool        drwxrwxrwt    3 root     root         4096 Oct 30 00:01 tmp        

※ /var.orig의 예

3. 네트워크 부팅 서버 설정

3.1 IP Masquerading

네트워크 부팅 클라이언트가 외부와 통신이 가능하게 해주기 위한 설정이다. 본 예제에서는 ipchains를 이용해서 IP Masquerading를 하는 방법을 알아보자. (※ ipchains는 커널에서 지원을 해줘야 사용 가능하다.)


        # echo 1 > /proc/sys/net/ipv4/ip_forward        # /sbin/ipchains -P forward DENY        # /sbin/ipchains -A forward -j MASQ -s 192.168.5.0/24 -d 0.0.0.0/0        # /sbin/ipchains -A forward -j MASQ -s 0.0.0.0/0 -d 192.168.5.0/24        

※ 재부팅시 적용시키기위해 /etc/init.d/rcS 파일 마지막에 위의 명령어들을 추가해준다.

3.2 시스템 로그 데몬 변경

클라이언트에서 발생하는 log들을 받아들이기 위해 시스템 로그 데몬의 설정을 변경한다.


        .        .        .        .        # Options for start/restart the daemons        #   For remote UDP logging use SYSLOGD="-r"        #        SYSLOGD="-r"        .        .        .        

※ /etc/init.d/syslogd

위와같이 -r를 추가하고 /etc/init.d/syslogd restart를 실행하여 적용시킨다.

4. 네트워크 부팅 클라이언트 설정

네트워크 부팅 클라이언트의 경로는 네트워크 부팅 서버의 /nfsroot이다. 서버의 설정을 변경하지 않도록 주의하기 바란다.

4.1 클라이언트 파일 시스템 설정


        # /etc/fstab: static file system information.        #        # <file system> <mount point>   <type>  <options>               <dump>  <pass>        ns52:/nfsroot   /               nfs     rsize=8192,wsize=8192,timeo=14,intr     0       0        /dev/ram1       /var            ext2    noauto                  0       0        ns52:/home      /home           nfs     rsize=8192,wsize=8192,timeo=14,intr     0       0        proc            /proc           proc    defaults                0       0        /dev/fd0        /floppy         auto    user,noauto             0       0        /dev/hda2       /local1         ext2    defaults                0       0        /dev/hdb1       /local2         ext2    defaults                0       0        

※ /etc/fstab

4.2 스크립트 파일 생성 및 삭제

/etc/init.d/ 디렉토리에 스크립트 파일 생성


        #!/bin/sh        #        # autohostname.sh : 자동으로 호스트네임을 설정한다.        #        IFCONFIG=`/sbin/ifconfig eth0`        ADDR=`echo "$IFCONFIG" | sed -n '/inet addr/p' | awk '{print $2}' | sed 's/addr://g'`        NSLOOKUP=`/usr/bin/nslookup -silent $ADDR`        HOSTNAME=`echo "$NSLOOKUP" | sed -n '/name =/p' | awk '{print $4}' | sed 's/\.softwise\.kidc\.//g'`        /bin/hostname $HOSTNAME        

※ /etc/init.d/autohostname.sh


        #!/bin/sh        #        # cluster.sh        #        mount -n /proc        echo Creating /var ...        mke2fs -q -i 1024 /dev/ram1 4096        mount /dev/ram1 /var -o defaults,rw        cp -a /var.orig/* /var        umount /proc        

※ /etc/init.d/cluster.sh

/etc/rc2.d/ 부팅시 실행되는 불필요한 스크립트 삭제

ex) S15bind9, S20dhcp3-server, S20nfs-kernel-server, S19nfs-common,...

위에서 생성한(autohostname.sh, cluseter.sh) 스크립트를 /etc/rcS.d/에 링크


        # cd /nfsroot/etc/rcS.d        # ln -s ../init.d/cluster.sh S01cluster.sh        # ln -s ../init.d/autohostname.sh S60autohostname.sh        # la -al        total 12        drwxr-xr-x    2 root     root         4096 Oct 30 03:18 .        drwxr-xr-x   44 root     root         4096 Nov 19 11:44 ..        -rw-r--r--    1 root     root          701 Jan 25  2002 README        lrwxrwxrwx    1 root     root           20 Oct 30 03:18 S01cluster.sh -> ../init.d/cluster.sh        lrwxrwxrwx    1 root     root           19 Oct 30 01:51 S05keymap.sh -> ../init.d/keymap.sh        lrwxrwxrwx    1 root     root           22 Oct 30 01:51 S10checkroot.sh -> ../init.d/checkroot.sh        lrwxrwxrwx    1 root     root           25 Oct 30 01:51 S18hwclockfirst.sh -> ../init.d/hwclockfirst.sh        lrwxrwxrwx    1 root     root           18 Oct 30 01:51 S20modutils -> ../init.d/modutils        lrwxrwxrwx    1 root     root           20 Oct 30 01:51 S30checkfs.sh -> ../init.d/checkfs.sh        lrwxrwxrwx    1 root     root           19 Oct 30 01:51 S30procps.sh -> ../init.d/procps.sh        lrwxrwxrwx    1 root     root           19 Oct 30 01:51 S30setserial -> ../init.d/setserial        lrwxrwxrwx    1 root     root           19 Oct 30 01:51 S35devpts.sh -> ../init.d/devpts.sh        lrwxrwxrwx    1 root     root           21 Oct 30 01:51 S35mountall.sh -> ../init.d/mountall.sh        lrwxrwxrwx    1 root     root           18 Oct 30 01:51 S39ifupdown -> ../init.d/ifupdown        lrwxrwxrwx    1 root     root           21 Oct 30 01:51 S40hostname.sh -> ../init.d/hostname.sh        lrwxrwxrwx    1 root     root           20 Oct 30 01:51 S40networking -> ../init.d/networking        lrwxrwxrwx    1 root     root           17 Oct 30 01:51 S41portmap -> ../init.d/portmap        lrwxrwxrwx    1 root     root           21 Oct 30 01:51 S45mountnfs.sh -> ../init.d/mountnfs.sh        lrwxrwxrwx    1 root     root           27 Oct 30 01:51 S48console-screen.sh -> ../init.d/console-screen.sh        lrwxrwxrwx    1 root     root           20 Oct 30 01:51 S50hwclock.sh -> ../init.d/hwclock.sh        lrwxrwxrwx    1 root     root           21 Oct 30 01:51 S55bootmisc.sh -> ../init.d/bootmisc.sh        lrwxrwxrwx    1 root     root           17 Oct 30 01:51 S55urandom -> ../init.d/urandom        lrwxrwxrwx    1 root     root           25 Oct 30 03:18 S60autohostname.sh -> ../init.d/autohostname.sh        

4.3 클라이언트 시스템 로그파일 설정변경

클라이언트의 /var은 RAMDISK를 사용하기 때문에 용량이 작다. 그래서 클라이언트의 시스템 로그는 서버쪽에 저장되게끔 바꾼다. /nfsroot/etc/syslog.conf 파일의 수정한 예를 보자.


        #  /etc/syslog.conf     Configuration file for syslogd.        #        #                       For more information see syslog.conf(5)        #                       manpage.        #        # First some standard logfiles.  Log by facility.        #        *.*     @ns52        

※ /nfsroot/etc/syslog.conf

위와 같이 해주면 모든 log가 ns52라는 서버로 저장된다.

4.4 /etc/mtab 변경

파일시스템의 마운트된 상태를 캐쉬해두는 /nfsroot/etc/mtab이 사실과 달라질 수 있다. 그래서 이 파일을 쓰는 대신, 실제로 마운트된 상태를 알려주는 /proc/mounts 를 사용한다. /etc/mtab를 삭제하고, 이파일을 /proc/mounts에 심볼릭 링크를한다.

5. 서버/클라이언트 동일한 설정

/etc/rc.boot/에 추가해줘야 할 것들


#!/bin/sh/sbin/hdparm -d1 -c1 /dev/hda/sbin/hdparm -d1 -c1 /dev/hdb

※ /etc/rc.boot/idedma


#!/bin/shmii-tool -F 100baseTx-FD eth0 eth1 eth2mii-tool -v

※ /etc/rc.boot/no-auto-negotiation


#!/bin/shecho -n "Increasing /proc/sys/kernel/shmmax to "echo 2100000000 > /proc/sys/kernel/shmmaxcat /proc/sys/kernel/shmmax

※ /etc/rc.boot/shmmax
반응형

'IT' 카테고리의 다른 글

mint linux 10 스샷  (2) 2010.10.26
debian lenny 한국 daum source List 입니다.  (4) 2010.10.21
인터넷 검색 창에서 한영 전환 안될때  (2) 2010.10.19
Grub 백그라운드 사진..  (0) 2010.10.18
Debian network 예제  (2) 2010.10.16
Posted by Dream Come True