1. 程式人生 > 實用技巧 >dhcp+tftp+pxe+kickstart網路引導與無人值守安裝

dhcp+tftp+pxe+kickstart網路引導與無人值守安裝

dhcp+tftp+pxe+kickstart網路引導與無人值守安裝

環境為:Red Hat Enterprise Linux Server 5 Update 4 (rhel5.4)

server(server1.example.com:192.168.10.254)

client(stationX.example.com:192.168.10.X)

1,配置yum本地庫,搭nfs server,目的是共享安裝源

把RHEL5的光碟的所有東西拷到/var/ftp/pub

[[email protected] ~]#mount –t iso9660 /dev/cdrom /media/cdrom

[[email protected]

~]# cp -r /media/cdrom/* /var/ftp/pub/

設定nfs 配置檔案

[[email protected] ~]# vim /etc/exports

/var/ftp/pub 192.168.10.0/24(ro,sync)

[[email protected] ~]# service nfs restart

再做個http server

[[email protected] ~]# yum install -y httpd

[[email protected] ~]# cd /var/www/html/

[[email protected] html]# ln -s /var/ftp/pub/ pub

[[email protected] html]# ls -l

lrwxrwxrwx 1 root root 13 Sep 4 02:21 pub -> /var/ftp/pub/

配置yum本地庫:

[[email protected] ~]# vim /etc/yum.repos.d/server1.repo

[base] ---->倉庫名字一定為"base”

name=server1

baseurl=file:///media/cdrom/Server

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

清除yum快取

[[email protected] ~]# yum clean all

2,製作kickstart指令碼檔案

[[email protected] ~]# yum list | grep kickstart

This system is not registered with RHN.

RHN support will be disabled.

pykickstart.noarch 0.43.5-1.el5 installed

system-config-kickstart.noarch 2.6.19.8-2.el5 installed

[[email protected] ~]# yum install -y system-config-kickstart

[[email protected] ~]# system-config-kickstart

會彈出圖形介面,相信大家都會的.

clip_p_w_picpath002

完成後儲存成檔案

clip_p_w_picpath004

開啟這個檔案看看效果(也可以直接在這個檔案裡編輯)

[[email protected] ~]# vim /var/ftp/pub/ksfile/ks_32.cfg

auth --useshadow --enablemd5

bootloader --location=mbr

zerombr

clearpart --all --initlabel

graphical

firewall --disabled

firstboot --disable

key --skip

keyboard us

lang en_US

logging --level=info

nfs --server=192.168.10.254 --dir=/var/ftp/pub

network --bootproto=dhcp --device=eth0 --onboot=on

reboot

rootpw --iscrypted $1$rj5p8xZ3$OnS8CeYJHecHLvOkykJZ91

selinux --enforcing

timezone Asia/Shanghai

install

xconfig --defaultdesktop=GNOME --depth=16 --resolution=800x600 --startxonboot

part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100

part / --bytes-per-inode=4096 --fstype="ext3" --size=5000

part swap --bytes-per-inode=4096 --fstype="swap" --size=512

part /home --bytes-per-inode=4096 --fstype="ext3" --size=512

%post

%packages

@base

@gnome-desktop

@system-tools

@sound-and-video

@graphical-internet

@graphics

@office

@text-internet

@printing

@games

@chinese-support

@editors

@base-x

2,配製DHCP server,

[[email protected] ~]# yum install -y dhcp

[[email protected] ~]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf

[[email protected] ~]# vim /etc/dhcpd.conf

ddns-update-style interim;

ignore client-updates;

next-server 192.168.10.254; --->指定tftp server

filename "pxelinux.0"; --->指定filename

subnet 192.168.10.0 netmask 255.255.255.0 {

# --- default gateway

option routers 192.168.10.254;

option subnet-mask 255.255.255.0;

option nis-domain "notexample";

option domain-name "example.com";

option domain-name-servers 192.168.10.254;

option time-offset -18000; # Eastern Standard Time

option ntp-servers 192.168.10.254;

# option netbios-name-servers 192.168.1.1;

# --- Selects point-to-point node (default is hybrid). Don't change this unless

# -- you understand Netbios very well

# option netbios-node-type 2;

range dynamic-bootp 192.168.10.10 192.168.10.20;

default-lease-time 21600;

max-lease-time 86400;

# we want the nameserver to appear at a fixed address

host ns {

hardware ethernet 12:34:56:78:AB:CD;

fixed-address 207.175.42.254;

}

}

3,設定tftp server

tftp-server預設系統已經安裝

[[email protected] ~]# rpm -qa |grep tftp

tftp-server-0.49-2

[[email protected] ~]# cd /tftpboot/

[[email protected] tftpboot]# locate pxelinux.0

/usr/lib/syslinux/pxelinux.0

[[email protected] tftpboot]# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/

[[email protected] tftpboot]# cp /var/ftp/pub/isolinux/* /tftpboot/

[[email protected] tftpboot]# mkdir pxelinux.cfg

[[email protected] tftpboot]# cp isolinux.cfg pxelinux.cfg/default

[[email protected] tftpboot]# chmod 644 pxelinux.cfg/default

[[email protected] tftpboot]# vim pxelinux.cfg/default

default linux

prompt 1

timeout 600 --->這個是等待時間預設為60秒,可以自行修改

display boot.msg

F1 boot.msg

F2 options.msg

F3 general.msg

F4 param.msg

F5 rescue.msg

label linux

kernel vmlinuz

append initrd=initrd.img ks=http://192.168.10.254/pub/ksfile/ks_32.cfg --->加上剛才的指令碼

label text

kernel vmlinuz

append initrd=initrd.img text

label ks

kernel vmlinuz

append ks initrd=initrd.img

label local

localboot 1

label memtest86

kernel memtest

append -

伺服器基本配置完成!

client開始驗證

開機時按F12就可以了進入網路引導了

又到了熟悉的介面了,直接回車

clip_p_w_picpath006

等!

clip_p_w_picpath008

等!

clip_p_w_picpath010

等!

clip_p_w_picpath012

等待全自動完成!無人值守的步驟就完成了!

轉載於:https://blog.51cto.com/masondong/401085