免费注册 查看新帖 |

Chinaunix

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

网络无人职守安装linux PXE [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-12-04 10:55 |只看该作者 |倒序浏览

网络无人职守安装linux
Writen BY HPLJ-2007.12.4


1 配置启动安装服务器

1)install and configure dhcp service
/etc/dhcpd.conf
such as


option domain-name "mydomain";
ddns-update-style none;

max-lease-time 7200;
server-name "bootserver";
default-lease-time 600;

allow booting;
allow bootp;

subnet 192.168.138.0 netmask 255.255.255.0 {
    range 192.168.138.1 192.168.138.254;
   
}

group pxe {
    filename "/pxelinux.0";
    host client1 { hardware ethernet 00:0C:29:70:24:5B;              
                       fixed-address    192.168.138.30;
                    }
}


#文件 pxelinux.0(在 TFTP 服务器的根目录中)将作为启动映像被网卡ROM里的PXE客户端载入内存并运行。

每增加一台需安装的机器,我们需在dhcpd.conf中增加一条host条目,将客户机的MAC地址输入进去,同时分配一个IP地址,如果
不输入MAC地址,客户机将无法通过DHCP取的IP地址。


2)install and configure tftp service

/etc/xinetd.d/tftp

service tftp
{
    socket_type     = dgram
    protocol        = udp
    wait            = yes
    user            = root
    server          = /usr/sbin/in.tftpd
    server_args     = -s /tftpboot
    disable         = no
}

#将disable = yes 改成disable = no
重启xinetd服务,以使tftp服务生效;

#service xinetd restart

2 将启动镜像文件pxelinux.0复制到TFTP服务器根目录,这是客户端机器刚开始启动的时候,pxe协议的引导文件。
启动镜像pxelinux.0可以在syslinux安装包里获得。安装好syslinux安装包后,将pxelinux.0复制到TFTP服务器根目录。
[root@bsvr]#cp /usr/lib/syslinux/pxelinux.0 /tftpboot/

3   将Linux安装程序的内核/根文件系统文件复制到 TFTP 服务器的根目录。对于每一个要被安装的Red Hat Linux版本,都需要执行一次该操作。
Red Hat Linux第一张安装光盘/isolinux目录下会包含Linux安装程序的内核/根文件系统文件。下面一段命令将这些文件复制到TFTP服务器的根目录下,并按照版本重新命名。initrd.img和vmlinuz,这两个文件是用来引导机器的内核和ramdisk文件,这两个文件可以改成别的文件名,需要在第五步中提高的/tftpboot/pxelinux.cfg/default文件中指定文件名即可;
[root@bsvr]#mkdir /mnt/iso
[root@bsvr]#mount -o loop,ro RHEL4-U2-i386-AS-disc1.iso  /mnt/iso
[root@bsvr]#cp /mnt/iso/isolinux/initrd.img /tftpboot
[root@bsvr]#cp /mnt/iso/isolinux/vmlinuz /tftpboot

4  nfs install
  cp linux iso file to nfs-path
#cp disk1.iso /tftpboot/iso/rhel4u3/
#cp disk2.iso /tftpboot/iso/rhel4u3/
#cp disk3.iso /tftpboot/iso/rhel4u3/
#cp disk4.iso /tftpboot/iso/rhel4u3/

vi /etc/exports
/tftp/iso/thel4u3/  *(r0,no_root-squash)

#service nfs restart

#service nfs reload
#检查共享时候已经正确输出
#showmount –e

5 编辑启动菜单,或安装多个版本的linux
客户端通过pxe协议引导起来之后,会在服务器的/tftpboot/pxelinux.cfg/目录(该目录需要手工建立)下寻找启动配置文件,启动配置文件中定义了应该引导哪个版本的Linux,文件名默认为default,可以将第一张安装光盘中的 /isolinux/isolinux.cfg文件复制到/tftpboot/pxelinux.cfg/,并改名为default,格式写法请参考里面已有的格式。

default  rhel4u3            默认启动项
display pxelinux.cfg/list       显示的启动菜单,供用户选择
prompt 1
timeout 30
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
F7 snake.msg
label  rhel4r3           具体的启动项目名称,一个label对应一个linux版本
  kernel vmlinuzrhel4r3   #这个文件对应的是/tftpboot目录下的相应版本的linux “vmlinuz”
  append ks=nfs:172.16.201.25:/tftpboot/iso/rhel4r3/ks-rhel4r3.cfg initrd=initrdrhel4r3.img ramdisk_size=8192            #initrd的文件对应的是/tftpboot/目录下相应的Linux版本的“initrd.img”文件,
label  rhel5r1           具体的启动项目名称,一个label对应一个linux版本
  kernel vmlinuzrhel5r1   #这个文件对应的是/tftpboot目录下的相应版本的linux “vmlinuz”
  append ks=nfs:172.16.201.25:/tftpboot/iso/rhel5r1/ks-rhel5r1.cfg initrd=initrdrhel5r1.img ramdisk_size=8192            #initrd的文件对应的是/tftpboot/目录下相应的Linux版本的“initrd.img”文件,
#在/tftpboot目录下应该存在以下5个文件(这五个文件名中不能有大写的,否则客户端在启动的时候会报找不到相应的文件):pxelinux.0 、vmlinuzrhel4r3和initrdrhel4r3.img、
vmlinuzrhel5r1和initrdrhel5r1.img

在/tftpboot/pxelinux.cfg目录下手工建立list文件,如下:
choose one name of the following linux distribution for your installation
Name     Distribution      Install location
rhel4r3    rhel4           172.16.201.25:/tftpboot/iso/rhel4r3/
rhel5r1    rhel5           172.16.201.25:/tftpboot/iso/rhel5r1/

这里的name 的名字要和default文件中的label相对应,大小写应一致。


6 制作ks.cfg文件,在服务器上有个图形界面的程序可以制作,如果没有可以在第二张光盘中找到这个包:system-config-kickstart-2.5.16.1-1.noarch.rpm,安装一下即可;

可以定义语言选项,网卡IP,分区信息,安装的软件包,安装选项选择NFS,输入nfs服务器的IP,路径,最后保存文件,复制到/tftpboot/iso/rhel4r3目录下,其他相应版本的linux的ks.cfg文件也要复制到相应的目录下,然后在default文件中指定该文件即可。

7 将客户机从网卡启动,安装linux。





本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/15680/showart_435499.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP