Linux 无盘服务器简明架设指南

时间:2009-06-21   来源:   网友评论:0   人气: 429 作者:

假设有一台服务器装有 Debian GNU/Linux。有两块网卡
网卡 eth0 (对外) IP 10.0.2.15 netmask 255.255.255.0 gateway 10.0.2.2
网卡 eth1 (对内) IP 192.168.1.1 netmask 255.255.255.0
网络结构如下:
       NIC    NIC IP                    Clients
+-----------------------------+
|                             |
|+-- [eth0] 10.0.2.15         +- to WAN
|                             |
|+-- [eth1] 192.168.1.1       +- to clients
|                             |  IP from 192.168.1.2 - 192.168.1.254
+-----------------------------+



以 root 用户登录,执行:

1. 建需要的目录
#mkdir /diskless
#mkdir /diskless/nfsroot
#mkdir /diskless/tftpboot
#mkdir /diskless/tftpboot/pxelinux.cfg

2. 装需要的软件
#apt-get install dhcp3-server
#apt-get install tftpd-hpa
#apt-get install nfs-kernel-server
#apt-get install syslinux
#apt-get install debootstrap

3. 建无盘机用的根文件系统
#debootstrap lenny /diskless/nfsroot http://mirrors.163.com/debian
#chroot /diskless/nfsroot
#apt-get install linux-image-2.6.26-2-686
#exit

4. 配置 DHCP 服务
#nano /etc/dhcp3/dhcpd.conf

/etc/dhcp3/dhcpd.conf 文件加上如下内容:
subnet 192.168.1.0 netmask 255.255.255.0 {
        range 192.168.1.2 192.168.1.254;
        next-server 192.168.1.1;
        filename "pxelinux.0";
        option domain-name "diskless.abc.com";
        option domain-name-servers 202.88.124.188;
        option routers 192.168.1.1;
}


#/etc/init.d/dhcp3-server restart


5. 配置 TFTP 服务
#cp /diskless/nfsroot/boot/vmlinuz-2.6.26-2-686 /diskless/tftpboot/vmlinuz
#cp /diskless/nfsroot/boot/initrd.img-2.6.26-2-686 /diskless/tftpboot/initrd.img
#cp /usr/lib/syslinux/pxelinux.0 /diskless/tftpboot
#nano /diskless/tftpboot/pxelinux.cfg/default

/diskless/tftpboot/pxelinux.cfg/default 文件内容如下:
label Debian Linux
kernel vmlinuz
append initrd=initrd.img boot=nfs nfsroot=/diskless/nfsroot ip=dhcp rw

#nano /etc/default/tftpd-hpa

/etc/default/tftpd-hpa 文件内容如下:
RUN_DAEMON="yes"
OPTIONS="-l -s /diskless/tftpboot"

#/etc/init.d/tftpd-hpa restart

6. 配置 NFS 服务
#nano /etc/exports

/etc/exports 文件内容如下:


 

文章评论