PXE+DHCP+TFTP+VSFTP+NFS 實現linux通過網絡自動安裝

 唉 昨天做了一次 沒有成功 問了一下老師 老師也不知道。。。我那個汗啊

今天又試驗了一個上午 終於 功夫不負有心人啊 成功了!下面記錄我的詳細步驟:
準備工作:
1.搭建DHCP
2.搭建TFTP
3.搭建FTP
4.搭建NFS
過程我不多說了 假設我都已經搭建完成 並且開啓了各個服務(讓這幾個服務在開機時開啓)
下面要修改各個配置文件了
一、/etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0 {
           
# --- default gateway
        option routers                  192.168.0.254;
        option subnet-mask              255.255.255.0;
#       option nis-domain               "domain.org";
#       option domain-name              "domain.org";
#       option domain-name-servers      192.168.1.1;
        option time-offset              -18000; # Eastern Standard Time
        filename "pxelinux.0";
        next-server 192.168.1.88;
#       option ntp-servers              192.168.1.1;
#       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  192.168.0.1 192.168.0.200;
        default-lease-time 21600;
max-lease-time 43200;
        # we want the nameserver to appear at a fixed address
        #host ns {
        #        next-server marvin.redhat.com;
        #      hardware ethernet 00:16:D3:07:68:27;
        #       fixed-address 192.168.0.88;
        # }
}
紅色的地方就是要修改的
 
二、/etc/xinetd.d/tftp
把disable = yes 改成 disable = no
 
三、/etc/exports
/var/ftp/pub     192.168.0.0/24(ro,sync)
/tftpboot/         192.168.0.0/24(ro,sync)
好了配置文件就改這麼多
下面去/tftpboot/文件下做修改 拷貝必要的文件
cd /tftpboot
cp /usr/lib/syslinux/pxelinux.0 /tftpboot
cp /光盤/p_w_picpath/pxeboot/initrd.img
cp /光盤/p_w_picpath/pxeboot/vmlinuz
cp /光盤/isolinux/*.msg /tftpboot
mkdir /tftpboot/pxelinux.cfg
cp /光盤/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
編輯default文件,如下:
default linux
prompt 1
timeout 600
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label 0
  localboot 1
label 1
  kernel vmlinuz
  append  ks=nfs:192.168.0.254:/var/ftp/pub/Kickstart/ks.cfg initrd=initrd.img
保存退出
編輯boot.msg
  1 ^L
  2
  3                 ^O09Welcome to ^O0cRed Hat Network^O09 Installer!^O07
  4 ^O0a
  5                           .-=-.          .--.
  6               __        .'     '.       /  " )
  7       _     .'  '.     /   .-.   \     /  .-'^O0c\^O0a
  8      ( \   / .-.  \   /   /   \   \   /  /    ^O0c^^O0a
  9       \ `-` /   \  `-'   /     \   `-`  /
 10        `-.-`     '.____.'       `.____.'
 11 ^O07
 12
 13
 14
 15 Enter number of the Operation System you wish to install:
 16
 17 0          Local OS restart
 18 1          Red Hat Enterprise Linux 5.4
 19 [F1-Main] [F2-General] [F3-Expert] [F4-Kernel] [F5-Rescue] [F7-Snake]

保存退出
 
製作kickstart文件
從網上找了一個又做了點修改,如下:
#Generated by Kickstart Configurator
#platform=x86, AMD64, or Intel EM64T
#System  language
key --skip
lang en_US
#Language modules to install
langsupport zh_CN en_SG --default=en_US
#System keyboard
keyboard us
#System mouse
mouse
#Sytem timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $1$0EvlSAB2$54bA8hII0o5cH04Gonjns0
#Reboot after installation
reboot
#Use text mode install
text
#Install OS instead of upgrade
install
#Use NFS installation Media
nfs --server=192.168.0.254  --dir=/var/ftp/pub/
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr yes
#Partition clearing information
clearpart --linux --initlabel
#Disk partitioning information
autopart
selinux --enforcing
#System authorization infomation
auth  --useshadow  --enablemd5
#Network information
network --bootproto=dhcp --device=eth0
#Firewall configuration
firewall --disabled
#XWindows configuration information
xconfig --depth=16 --resolution=1024x768 --defaultdesktop=GNOME --startxonboot
#Package install information
%packages
@admin-tools
@base
@chinese-support
@core
@dialup
@editors
@gnome-desktop
@games
@graphical-internet
@graphics
@java
@legacy-software-support
@office
@printing
@sound-and-video
@text-internet
@base-x
kexec-tools
fipscheck
device-mapper-multipath
sgpio
emacs
libsane-hpaio
xorg-x11-utils
xorg-x11-server-Xnest
關於package那部分 這裏是最小化安裝(分區按系統默認)
如果要安裝所有包的話
#Package install information
%packages
@ everything
@ chinese-support
kernel
lvm2
grub
kernel-devel
e2fsprogs
%post
這樣就可以了
 
重新啓動各個服務
service  dhcpd restart
service xinetd restart
service nfs restart
service vsftpd restart
OK!可以測試了
開啓另外一個機子 如果是臺式機F8->LAN
然後有界面可以選擇0 還是1   
0就是本地啓動了 1就是網絡安裝 當然也可以在default中修改下timeout值 讓它等上幾秒就自動進入無人值守安裝~~~
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章