歡迎您光臨本站 註冊首頁

pxe (網路引導 dhcp ftp )

準備工作

伺服器 :ftp (放置安裝文件) yum (system-config-kickstart) dhcp (客戶動態得到地址) tftp (pxe 所需文件)

機器名稱:stationx.abc.com

伺服器 dhcp ftp tftp yum

tftp

cd /tftpboot

拷貝 /mnt/cdrom/images/pxeboot/vmlinuz ./

.............../images/pxeboot/initrd.d ./

cp /usr/lib/syslinux/pxelinux.0 ./

mkdir pxelinux.cfg

cp /mnt/cdrom/isolinux/isolinux.cfg pxelinux.cfg/default

編輯default

12行 append之後 ks= ksdevice=eth0

安裝dhcp伺服器

next-server 伺服器地址

filename “prelinux.0"

1:安裝ftp伺服器,並設置

[root@zzu ~]# cd /var/ftp/pub/

[root@zzu pub]#cp -a -r /mnt/cdrom/.* ./

[root@zzu pub]# ll

?昏. 5752

dr-xr-xr-x 3 root root 4096 2009-08-19 Cluster

dr-xr-xr-x 3 root root 4096 2009-08-19 ClusterStorage

-r--r--r-- 1 root root 8445 2008-09-03 EULA

-r--r--r-- 1 root root 8445 2009-08-04 eula.en_US

-r--r--r-- 1 root root 18416 2006-12-01 GPL

dr-xr-xr-x 4 root root 4096 2009-08-19 images

dr-xr-xr-x 2 root root 4096 2009-08-19 isolinux

[root@zzu ~]# service vsftpd start

涓?vsftpd ?.. vsftpd錛 [紜..]

[root@zzu ~]# chkconfig vsftpd on

root@zzu ~]# chkconfig --list|grep vsftpd

vsftpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

2:配置yum

[root@zzu ~]# vim /etc/yum.repos.d/server.repo

1 [rhel-server]

2 name=Red Hat Enterprise Linux server

3 baseurl=file:///mnt/cdrom/Server

4 enabled=1

5 gpgcheck=1

6 gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release

7 [rhel-vt]

8 name=Red Hat Enterprise Linux vt

9 baseurl=file:///mnt/cdrom/VT

10 enabled=1

11 gpgcheck=1

12 gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release

13

14 [rhel-cluster]

15 name=Red Hat Enterprise Linux cluster

16 baseurl=file:///mnt/cdrom/Cluster

17 enabled=1

18 gpgcheck=1

19 gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release

20

21 [rhel-clusterstorage]

22 name=Red Hat Enterprise Linux clusterstorage

23 baseurl=file:///mnt/cdrom/ClusterStorage

24 enabled=1

25 gpgcheck=1

[root@zzu ~]# yum repolist

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

repo id repo name

rhel-cluster Red Hat Enterpris

rhel-clusterstorage Red Hat Enterpris

rhel-server Red Hat Enterpris

rhel-vt Red Hat Enterpris

repolist: 2,399

[root@zzu ~]#

3:安裝dhcp

[root@zzu ~]# yum install dhcp*

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

Setting up Install Process

Package dhcpv6-client-1.0.10-17.el5.i386 already installed and latest version

Resolving Dependencies

There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.

The program yum-complete-transaction is found in the yum-utils package.

--> Running transaction check

---> Package dhcp.i386 12:3.0.5-21.el5 set to be updated

---> Package dhcp-devel.i386 12:3.0.5-21.el5 set to be updated

---> Package dhcpv6.i386 0:1.0.10-17.el5 set to be updated

--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================

Package Arch Version Repository Size

======================================================================================================================================

Installing:

dhcp i386 12:3.0.5-21.el5 rhel-server 866 k

dhcp-devel i386 12:3.0.5-21.el5 rhel-server 131 k

dhcpv6 i386 1.0.10-17.el5 rhel-server 192 k

Transaction Summary

======================================================================================================================================

Install 3 Package(s)

Update 0 Package(s)

Remove 0 Package(s)

Total download size: 1.2 M

Is this ok [y/N]: y

Downloading Packages:

--------------------------------------------------------------------------------------------------------------------------------------

Total 389 MB/s | 1.2 MB 00:00

Running rpm_check_debug

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

Installing : dhcp 1/3

Installing : dhcp-devel 2/3

Installing : dhcpv6 3/3

Installed:

dhcp.i386 12:3.0.5-21.el5 dhcp-devel.i386 12:3.0.5-21.el5 dhcpv6.i386 0:1.0.10-17.el5

Complete!

[root@zzu ~]# vim /etc/dhcpd.conf

1 #

2 # DHCP Server Configuration file.

3 ddns-update-style interim;

4 ignore client-updates;

5

6 subnet 192.168.6.0 netmask 255.255.255.0 {

7

8 # --- default gateway

9 option routers 192.168.6.254;

10 option subnet-mask 255.255.255.0;

11

12 option nis-domain "domain.org";

13 option domain-name "domain.org";

14 option domain-name-servers 192.168.1.1;

15 next-server 192.168.6.100;

16 filename "pxelinux.0";

17

18 option time-offset -18000; # Eastern Standard Time

19 # option ntp-servers 192.168.1.1;

20 # option netbios-name-servers 192.168.1.1;

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

22 # -- you understand Netbios very well

23 # option netbios-node-type 2;

24

25 range dynamic-bootp 192.168.6.120 192.168.6.150;

26 default-lease-time 21600;

27 max-lease-time 43200;

[root@zzu ~]# service dhcpd start

啟動 dhcpd: [確定]

[root@zzu ~]# chkconfig dhcpd on

-- INSERT --

4:安裝tftp伺服器

[root@zzu ~]# yum install tftp*

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

Setting up Install Process

Package tftp-0.49-2.i386 already installed and latest version

Package tftp-server-0.49-2.i386 already installed and latest ve

[root@zzu ~]# service xinetd start

?.. xinetd錛

[root@zzu ~]# chkconfig xinetd on

[root@zzu ~]# chkconfig --list|grep xinetd

xinetd 0:off 1:off 2:on 3:on 4:on 5:on 6:o

xinetd based services:

[root@zzu ~]#

Vim /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

per_source = 11

cps = 100 2

flags = IPv4

}

Cd /tftproot

[root@zzu tftpboot]# cp /mnt/cdrom/images/pxeboot/initrd.img ./

[root@zzu tftpboot]# cp /mnt/cdrom/images/pxeboot/vmlinuz ./

[root@zzu tftpboot]# cp /usr/lib/syslinux/pxelinux.0 ./ 驅動模塊

[root@zzu tftpboot]# ll

total 8552

-r--r--r-- 1 root root 6855881 Feb 7 21:52 initrd.img

drwxr-xr-x 4 root root 4096 Feb 8 2012 linux-install

-rw-r--r-- 1 root root 13148 Feb 7 21:52 pxelinux.0

-r--r--r-- 1 root root 1855956 Feb 7 21:49 vmlinuz

[root@zzu tftpboot]# mkdir pxelinux.cfg

[root@zzu tftpboot]# ll

total 8556

-r--r--r-- 1 root root 6855881 Feb 7 21:52 initrd.img

drwxr-xr-x 4 root root 4096 Feb 8 2012 linux-install

-rw-r--r-- 1 root root 13148 Feb 7 21:52 pxelinux.0

drwxr-xr-x 2 root root 4096 Feb 7 21:55 pxelinux.cfg

-r--r--r-- 1 root root 1855956 Feb 7 21:49 vmlinuz

[root@zzu tftpboot]# cp /mnt/cdrom/isolinux/isolinux.cfg pxelinux.cfg/default

[root@zzu tftpboot]# vim pxelinux.cfg/default

1 default linux

2 prompt 1

3 timeout 5

4 display boot.msg

5 F1 boot.msg

6 F2 options.msg

7 F3 general.msg

8 F4 param.msg

9 F5 rescue.msg

10 label linux

11 kernel vmlinuz

12 append ks=ftp://192.168.6.100/pub/ks.cfg ksdevice=eth0 initrd=initrd.img

13 label text

14 kernel vmlinuz

15 append initrd=initrd.img text

16 label ks

17 kernel vmlinuz

18 append ks initrd=initrd.img

19 label local

20 localboot 1

21 label memtest86

22 kernel memtest

23 append -

24[root@zzu tftpboot]# service xinetd start

?.. xinetd錛

[root@zzu tftpboot]# chkconfig xinetd on

其他

[root@zzu tftpboot]# yum install system-config-kick*

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

Setting up Install Process

Resolving Dependencies

There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.

The program yum-complete-transaction is found in the yum-utils package.

--> Running transaction check

---> Package system-config-kickstart.noarch 0:2.6.19.8-2.el5 set to be updated

--> Processing Dependency: pykickstart for package: system-config-kickstart

--> Running transaction check

---> Package pykickstart.noarch 0:0.43.5-1.el5 set to be updated

--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================

Package Arch Version Repository Size

======================================================================================================================================

Installing:

system-config-kickstart noarch 2.6.19.8-2.el5 rhel-server 985 k

Installing for dependencies:

pykickstart noarch 0.43.5-1.el5 rhel-server 128 k

Transaction Summary

======================================================================================================================================

Install 2 Package(s)

Update 0 Package(s)

Remove 0 Package(s)

Total download size: 1.1 M

Is this ok [y/N]: y

Downloading Packages:

--------------------------------------------------------------------------------------------------------------------------------------

Total 322 MB/s | 1.1 MB 00:00

Running rpm_check_debug

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

Installing : pykickstart 1/2

Installing : system-config-kickstart 2/2

Installed:

system-config-kickstart.noarch 0:2.6.19.8-2.el5

Dependency Installed:

pykickstart.noarch 0:0.43.5-1.el5

Complete!

[root@zzu tftpboot]# system-config-kickstart

產生ks.cfg文件

[root@zzu ~]# vim /var/ftp/pub/ks.cfg

#platform=x86, AMD64, 或 英特爾 EM64T

# System authorization information

auth --useshadow --enablemd5

key --skip

# System bootloader configuration

bootloader --append="quiet" --location=mbr

# Clear the Master Boot Record

zerombr

# Partition clearing information

clearpart --all --initlabel

# Use text mode install

text

# Firewall configuration

firewall --disabled

# Run the Setup Agent on first boot

firstboot --disable

# System keyboard

keyboard us

# System language

lang en_US

# Installation logging level

logging --level=info

# Use network installation

url --url=ftp://192.168.6.100/pub

# Network information

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

# Reboot after installation

reboot

#Root password

rootpw --iscrypted $1$19p.ehQF$ao.mnfQJO9Or5yf5h5X.a1

# SELinux configuration

selinux --permissive

# System timezone

timezone Asia/Shanghai

# Install OS instead of upgrade

install

# X Window System configuration information

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

# Disk partitioning information

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

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

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

%post --interpreter=#/bin/bash

ADDRE=`ifconfig eth0 |grep -i "bcast"|awk '{print $2}'`

NUM=${ADDRE##*.}

sed -i 's&HOSTNAME.*&HOSTNAME=station'$NUM'.abc.com&' /etc/sysconfig/network

init 6

service --disable cups,sendmail

%packages

安裝測試

Sendmail 服務的啟動很慢

後續

Ks.cfg個參數的作用

anaconda-ks.cfg詳解

2010-08-13 14:45

這個文件記錄的是安裝系統時的一些信息:
以我的虛擬機為例:

01

#—————————-引用文字-開始—————————-

02

# Kickstart file automatically generated by anaconda.

03

04

#我用的是光碟安裝

05

install

06

cdrom

07

08

#安裝時選擇的語言和鍵盤布局

09

lang en_US.UTF-8

10

keyboard us

11

12

#網路配置信息

13

network --device eth0 --bootproto static --ip 10.0.0.241 --netmask 255.255.255.0 --gateway 10.0.0.1 --nameserver 8.8.8.8

14

15

#root密碼

16

rootpw --iscrypted $1$uiEOrtaz$XFiz8psay7UuVm.2Dkt1Z1

17

18

#防火牆開啟的埠

19

firewall --enabled --port=22:tcp

20

21

#認證加密方法

22

authconfig --enableshadow --enablemd5

23

24

#selinux的配置信息

25

selinux --enforcing

26

27

#時區

28

timezone --utc Asia/Shanghai

29

30

#啟動引導分區

31

bootloader --location=mbr --driveorder=hda

32

33

# The following is the partition information you requested

34

# Note that any partitions you deleted are not expressed

35

# here so unless you clear all partitions first, this is

36

# not guaranteed to work

37

38

#磁碟配置信息

39

#clearpart --linux --drives=hda

40

#part /boot --fstype ext3 --size=100 --ondisk=hda

41

#part pv.2 --size=0 --grow --ondisk=hda

42

#volgroup VolGroup00 --pesize=32768 pv.2

43

#logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow

44

#logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=384 --grow --maxsize=768

45

46

#安裝時選擇的軟體包

47

%packages

48

@base

49

@core

50

@dialup

51

@editors

52

keyutils

53

trousers

54

fipscheck

55

device-mapper-multipath

56

#—————————-引用文字-結束—————————-

那這個文件有什麼用呢?
這個配置文件經修改之後可以用於雷同環境下,使用Kickstart來自動安裝大量同樣的操作系統,

可以把這個文件經修改之後放入U盤,命名為ks.cfg
在裝系統時,出現boot界面時就可以輸入:
#ks的路徑視你的U盤的為哪個盤而定
linux ks=/dev/sdb:/yourpath/ks.cfg

也可以放入nfs伺服器,通過網路安裝,出現boot界面時就可以輸入:
linux ks=nfs:servername:/yourpath/ks.cfg

本文出自 「心靈規劃」 博客,謝絕轉載!


[火星人 ] linux安裝方式大全2——pxe網路安裝vsftp dhcp tftp kickstart pxe裝rhel5已經有877次圍觀

http://coctec.com/docs/linux/show-post-47330.html