免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1788 | 回复: 2
打印 上一主题 下一主题

Linux无盘工作站架设实例 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-02-12 11:20 |只看该作者 |倒序浏览
客户端是支持PXE方式启动的刀片,用Linux作为服务器,服务器配置如下:


1) 安装DHCP服务器dhcpd


2) 配置/etc/dhcpd.conf文件,下面是我机器上的文件


max-lease-time -1;
default-lease-time -1; #注:IP地址永不过期
option subnet-mask 255.0.0.0;
option routers 10.0.0.1;
option domain-name-servers 10.10.10.10;
# option netbios-name-servers 10.10.10.10;
option broadcast-address 10.255.255.255;
# option dhcp-class-identifier "PXEClient";
# option vendor-encapsulated-options 01:04:00:00:00:00:ff;
# option option-135 "start";

subnet 10.0.0.0 netmask 255.0.0.0 {
range 10.10.12.131 10.10.12.150;

host blade01 {
hardware ethernet 00:e0:43:00:02:00;
fixed-address 10.10.12.131;
filename "/tftpboot/pxelinux.0"; #注:启动映象文件
}

host blade02 {
hardware ethernet 00:e0:43:00:02:02;
fixed-address 10.10.12.132;
filename "/tftpboot/pxelinux.0";
}

host blade03 {
hardware ethernet 00:e0:43:00:02:04;
fixed-address 10.10.12.133;
filename "/tftpboot/pxelinux.0";
}

host blade04 {
hardware ethernet 00:e0:43:00:02:06;
fixed-address 10.10.12.134;
filename "/tftpboot/pxelinux.0";
}

host blade05 {
hardware ethernet 00:e0:43:00:02:08;
fixed-address 10.10.12.135;
filename "/tftpboot/pxelinux.0";
}
}



  说明:dhcp客户得到IP地址后用TFTP协议从服务器上下载启动映象文件。我用syslinux

  工具包里边的pxelinux来作为远程启动的loder.

3) 配置tftp server

  使用pxelinux作引导工具需要支持TSIZE参数的tftp server。可从http://www.kernel.org/pub/software/network/tftp/下载。

  通过xinetd来使用tftp服务,我的/etc/xinetd.conf文件如下


......
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
}



4) 配置PXELINUX

  先安装syslinux软件包。可从http://www.kernel.org/pub/linux/utils/boot/syslinux/下载。

  将pxelinux.0拷贝到/tftpboot/目录下,然后建立/tftpboot/syslinux.cfg/目录。该目录下存放配置文件。

  pxelinux使用ip地址的十六进制表示来作为该ip地址的配置文件的文件名。如blade01的

  ip地址为10.10.12.131,配置文件名为0A0A0C83,内容为:


default linux

label linux
kernel vmlinuz
append ip=dhcp root=/dev/nfsroot nfsroot=10.10.11.120:/remote/blade01 vga=normal



5) 配置nfs

  为每个刀片建立一个根目录,在该刀片的pxelinux配置文件里指定了从这个nfs export的目录启动。

  该根目录里应把标准的目录都建好,另外需要重新mount的usr, home, public等目录也要export。

  我的 /etc/exports文件:


# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).

/remote/blade01 blade01(rw,async,no_root_squash)
/remote/blade02 blade02(rw,async,no_root_squash)
/remote/blade03 blade03(rw,async,no_root_squash)
/remote/blade04 blade04(rw,async,no_root_squash)
/remote/blade05 blade05(rw,async,no_root_squash)
/remote/root *(rw,async,no_root_squash)
/remote/home *(rw,async,no_root_squash)
/usr *(ro,async,no_root_squash)
/sbin *(ro,async,no_root_squash)
/bin *(ro,async,no_root_squash)
/lib *(ro,async,no_root_squash)
/home *(ro,async,no_root_squash)


6)为每个刀片修改它的/etc/fstab文件,以blade01为例,它的nfs root是/remote/blade01
/remote/blade01/etc/fstab文件如下:
# /etc/fstab: static file system information.
#
#
10.10.11.120:/remote/blade01 / nfs defaults,intr 0 1
10.10.11.120:/remote/root /root nfs defaults,intr 0 1
10.10.11.120:/remote/home /home nfs defaults,intr 0 1
10.10.11.120:/bin /bin nfs defaults,intr 0 1
10.10.11.120:/usr /usr nfs defaults,intr 0 1
10.10.11.120:/sbin /sbin nfs defaults,intr 0 1
10.10.11.120:/lib /lib nfs defaults,intr 0 1
none /proc proc defaults,intr 0 1



  同时还要为每个刀片修改它的网络配置文件,配置ip地址,启动两块网卡等等。。

7) 编译内核

  刀片用的内核,应该支持Kernel Level Auto Configuration的DHCP协议,支持NFS,支持NFS ROOT,

  假设编译好的内核为vmlinuz,将它拷贝到/tftpboot/目录下。

参考文档:

http://syslinux.zytor.com/pxe.php
http://syslinux.zytor.com/faq.php
http://www.cn-cio.org/xx/show.php?article_id=1680
http://www-900.ibm.com/developerWorks/cn/linux/l-tip-prompt/l-pex/index.shtml

论坛徽章:
0
2 [报告]
发表于 2007-02-12 11:31 |只看该作者
如何远程安装Linux  
级别: 初级
汤凯 (tangk73@hotmail.com),
2002 年 12 月 09 日
本文介绍了在不需要光驱和软驱的情况下,如何通过PXE协议快速安装Linux的原理和步骤,这对于提高安装Linux的效率非常有帮助;同时,PXE协议也可以作为无盘linux技术,用于引导远程的Linux启动。
1. 引言
一般情况下,我们都是利用软驱或光驱引导Linux后,再通过本地的光驱安装Linux。但是,这种安装方法在以下的几种情况下就不能适用:
  • 无软驱和光驱:很多公司为了节省成本,计算机一般都不带光驱或软驱,这样就无法通过本地安装Linux;
  • 非标准的软驱和光驱:虽然笔记本都会配置光驱,但是并不一定都是标准的IDE设备,有些是通过USB接口,有些是通过1394接口(例如Samsung的Q10)。在Linux安装时所引导的Linux内核一般都不会带这些接口的驱动,所以也无法通过本地安装Linux;
  • 另外,在一些场合,如机房中,有大量的计算机需要同时安装Linux,如果通过光驱的方式一个个安装,不仅效率低,也不利于维护。
笔者在工作过程中,就遇到过第二种情况。一台Samsung的Q10笔记本需要安装Redhat Linux 8.0,但是通过光驱引导后发现,安装程序无法访问光盘。针对这个问题,笔者经过查阅资料和摸索,找到了在Q10上安装Linux的方法。在下面的讨论中,如不做特别声明,都将以Q10为例,介绍如何通过PXE Bootrom来远程安装Linux。




回页首



2. 基本原理
1) 什么是PXE
PXE(Pre-boot Execution Environment)是由Intel设计的协议,它可以使计算机通过网络启动。协议分为client和server两端,PXE client在网卡的ROM中,当计算机引导时,BIOS把PXE client调入内存执行,并显示出命令菜单,经用户选择后,PXE client将放置在远端的操作系统通过网络下载到本地运行。
PXE协议的成功运行需要解决以下两个问题:
  • 既然是通过网络传输,那么计算机在启动时,它的IP地址由谁来配置;
  • 通过什么协议下载Linux内核和根文件系统
对于第一个问题,可以通过DHCP Server解决,由DHCP server来给PXE client分配一个IP地址,DHCP Server是用来给DHCP Client动态分配IP地址的协议,不过由于这里是给PXE Client分配IP地址,所以在配置DHCP Server时,需要增加相应的PXE特有配置。
至于第二个问题,在PXE client所在的ROM中,已经存在了TFTP Client。PXE Client使用TFTP Client,通过TFTP协议到TFTP Server上下载所需的文件。
这样,PXE协议运行的条件就具备了,下面我们就来看看PXE协议的工作过程。
2) 工作过程




在上图中,PXE client是需要安装Linux的计算机,TFTP Server和DHCP Server运行在另外一台Linux Server上。Bootstrap文件、配置文件、Linux内核以及Linux根文件系统都放置在Linux Server上TFTP服务器的根目录下。
PXE client在工作过程中,需要三个二进制文件:bootstrap、Linux 内核和Linux根文件系统。Bootstrap文件是可执行程序,它向用户提供简单的控制界面,并根据用户的选择,下载合适的Linux内核以及Linux根文件系统。




回页首



3. 步骤
有了前面的背景知识,接下来就可以正式操作了,下面按照顺序给出了操作步骤:
1) 配置DHCP Server
选用ISC dhcp-3.0,DHCP Server的配置文件是/etc/dhcpd.conf,配置文件的内容如下:
option space PXE;option PXE.mtftp-ip               code 1 = ip-address;  option PXE.mtftp-cport            code 2 = unsigned integer 16;option PXE.mtftp-sport            code 3 = unsigned integer 16;option PXE.mtftp-tmout            code 4 = unsigned integer 8;option PXE.mtftp-delay            code 5 = unsigned integer 8;option PXE.discovery-control      code 6 = unsigned integer 8;option PXE.discovery-mcast-addr   code 7 = ip-address;class "pxeclients" {    match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";    option vendor-class-identifier "PXEClient";    vendor-option-space PXE;    # At least one of the vendor-specific PXE options must be set in    # order for the client boot ROMs to realize that we are a PXE-compliant    # server.  We set the MCAST IP address to 0.0.0.0 to tell the boot ROM    # that we can't provide multicast TFTP (address 0.0.0.0 means no    # address).    option PXE.mtftp-ip 0.0.0.0;    # This is the name of the file the boot ROMs should download.    filename "pxelinux.0";    # This is the name of the server they should get it from.    next-server 192.168.0.1;}ddns-update-style interim;ignore client-updates;default-lease-time 1200;max-lease-time 9200;option subnet-mask 255.255.255.0;option broadcast-address 192.168.0.255;option routers 192.168.0.254;option domain-name-servers 192.168.0.1,192.168.0.2;option domain-name "mydomain.org";subnet 192.168.0.0 netmask 255.255.255.0 {range 192.168.0.10 192.168.0.100;} host q10 {hardware ethernet 00:00:F0:6B:38:5B;        fixed-address 192.168.0.22;}

dhcpd.conf配置文件中几个关键部分说明如下:host q10{…}定义了笔记本Q10网卡的MAC地址与IP地址的对应关系,表明DHCP Server为Q10分配一个固定的IP:192.168.0.22;filename ""指定bootstrap的文件名;netx-server指定TFTP Server的地址。其它的配置请读者参考DHCP Server的手册。
2) 配置TFTP server
选用tftp-hpa,TFTP Server的配置文件是/etc/xinetd.d/tftp,配置文件的内容如下:
        service tftp{        socket_type             = dgram        protocol                = udp        wait                    = yes        user                    = root        server                  = /usr/sbin/in.tftpd        server_args             = -u nobody -s /tftpboot        disable                 = no        per_source              = 11        cps                     = 100 2        }       

这里制定了/tftpboot为TFTP Server的根目录位置。
3) 配置bootstrap
bootstrap文件在dhcpd.conf中被指定为pxelinux.0文件,放置在/tftpboot。Linux内核以及Linux根文件系统也放置在/tftpboot。pxelinux.0在执行过程中,要读配置文件,所有的配置文件都放在/tftpboot/pxelinux.cfg/目录下。由于PXElinux具有为不同的PXE Client提供不同的Linux内核以及根文件系统的功能,所以要通过不同的配置文件名来区分出不同的PXE Client的需求。比如一个PXE Client由DHCP Server分配的IP地址为192.168.0.22,那么相对应的配置文件名为/tftpboot/pxelinux.cfg/C0A80016(注:C0A80016为IP地址192.168.0.22的十六进制表示)。如果找不到,就按照顺序C0A80016-> C0A8001-> C0A800-> C0A80-> C0A8-> C0A-> C0-> C->default查找配置文件。
/tftpboot/pxelinux.cft/C0A80001配置文件的具体内容如下:
DEFAULT install
PROMPT 1
LABEL install
KERNEL vmlinuz
APPEND initrd=initrd.img devfs=nomount ramdisk_size=16384
此配置文件指定了Linux内核以及根文件系统的名称,并给内核传递了一些参数,其中ramdisk_size参数要非常注意,它指定Linux内核启动后建立ramdisk的大小,如果设置太小,Linux的安装过程就可能无法进行。
4) 制作Linux内核/根文件系统
因为需要通过网络安装,所有选择Redhat Linux 8.0安装盘(disk #1)中E:\images\bootnet.img(光驱的盘符为E:)。bootnet.img包括Linux内核、Linux根文件系统(有安装程序在内)。用bootnet.img制作一张引导软盘,方法在DOS命令行运行E:\dosutils\rawrite E:\images\bootnet.img,根据提示制作。制作完毕后,将引导软盘中的vmlinuz(Linux内核)和initrd.img(Linux根文件系统)拷贝到Linux Server的/tftpboot下。
5) 启动DHCP Server/TFTP Server
在Linux Server上,运行service dhcpd start和service xinetd restart。
6) 启动Q10
Q10加电后,在出现Samsung公司徽标时,在左下角会提示用户按F12进入网络引导。按F12后,Q10进入网络引导过程。首先通过DHCP Server获得了IP地址,然后下载并执行bootstrap文件pxelinux.0;在执行中,读入配置文件/tftpboot/pxelinux.cfg/C0A80016。此时屏幕上出现boot:,敲入install,就进入了Redhat Linux 8.0的网络安装界面,一切OK!




回页首



4. 结束语
虽然以上的讨论是针对Samsung Q10笔记本,但是工作原理和安装方法对于其它类型的计算机也是适用的,不过要记住,计算机的网卡中必须要有BootROM--PXE Client。同时,PXE协议也可作为无盘Linux技术,用于引导放置在远程的Linux。实际上,只要根据需要,在Pxelinux的配置文件的APPEND选项中,为Linux内核传进需要mount的文件系统的位置参数即可。



参考资料

1.gif (11.49 KB, 下载次数: 33)

1.gif

论坛徽章:
0
3 [报告]
发表于 2007-02-13 13:55 |只看该作者
高手!
收藏了!
谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP