Linux 无盘服务器简明架设指南
时间:2009-06-21 17:08:00
来源:UltraLAB图形工作站方案网站
人气:8248
作者:admin
假设有一台服务器装有 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 文件内容如下: #p#page_title#e#
/diskless/nfsroot *(rw,async,no_subtree_check,no_root_squash)
#/etc/init.d/nfs-kernel-server restart
7. OK! 无盘机可以通过 PXE 启动了。
实现以下菜单功能只要修改一下 /diskless/tftpboot/pxelinux.cfg/default
就可以了。详情可参考网上资料。
网卡 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 文件内容如下: #p#page_title#e#
/diskless/nfsroot *(rw,async,no_subtree_check,no_root_squash)
#/etc/init.d/nfs-kernel-server restart
7. OK! 无盘机可以通过 PXE 启动了。
实现以下菜单功能只要修改一下 /diskless/tftpboot/pxelinux.cfg/default
就可以了。详情可参考网上资料。