2012年10月2日 星期二

RAMDisk Rootfs 支援 Pxeboot 設定筆記

角色定義
Server端:
安裝 CentOS 6.3 + rdrtool ,提供其他設備開機所需檔案
網路 IP 設定為:10.0.0.1 / 24

Client端:
透過網路方式開機,不需安裝任何作業系統


Client端設定方式如下:
BIOS 設定開機方式為支援 PXE 方式的網路開機


Server端設定方式如下:
安裝 rdrtools ,見CentOS 6 安裝設定 RAM Disk Rootfs Tool 摘要
http://rdrtools.blogspot.tw/2012/08/ram-disk-rootfs-tool-centos-6.html


設定 NFS 服務
編輯 /etc/exports 內容如下
/rdrtools       10.0.0.0/255.255.255.0(rw)

重新啟動 NFS 服務
service nfs restart


安裝設定 TFTP 服務
yum xinetd tftp-server

編輯 /etc/xinetd.d/tftp  內容如下
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        #server_args            = -s /var/lib/tftpboot
        server_args             = -s /tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
} 

重新啟動 xinetd 服務
service xinetd  restart


安裝設定 DHCP 服務
yum dhcp dhcp-common

編輯 /etc/dhcp/dhcpd.conf  內容如下
default-lease-time 600;
max-lease-time 1200;
option subnet-mask 255.255.255.0;
option broadcast-address 10.0.0.255;
option routers 10.0.0.2;
option domain-name-servers 10.0.0.2;
option domain-name "mydomain.org";
allow booting;
allow bootp;
subnet 10.0.0.0 netmask 255.255.255.0 {
   range 10.0.0.11 10.0.0.20;
   range 10.0.0.41 10.0.0.50;
   next-server 10.0.0.1;
   filename "gpxelinux.0";
}

重新啟動 dhcpd 服務
service dhcpd restart


安裝設定 syslinux
下載 syslinux
wget http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-4.05.tar.gz
tar zxfv syslinux-4.05.tar.gz

mkdir -p /tftpboot/pxelinux.cfg
cp `find ./syslinux-4.05  -name menu.c32` /tftpboot
cp `find ./syslinux-4.05  -name gpxelinux.0` /tftpboot

編輯  /tftpboot/pxelinux.cfg/default 內容如下
DEFAULT menu.c32
PROMPT 0
ALLOWOPTIONS 0
TIMEOUT 50
LABEL linux.nfs
MENU LABEL LINUX.nfs
KERNEL vmlinuz-2.6.32-279.el6.x86_64
append initrd=initramfs-2.6.32-279.el6.x86_64.img.rdrtools root=tmpfs RDRPATH=nfs://10.0.0.1/rdrtools RDRCFG=/rdrtools/rdrtool.tmpfs RDRWAIT=3

其他相關環境設定
cd /rdrtools
ln -s ./ rdrtools
cp /boot/vmlinuz-2.6.32-279.el6.x86_64  /tftpboot
cp /boot/initramfs-2.6.32-279.el6.x86_64.img.rdrtools /tftpboot/