[无人值守安装操作系统]__RHEL6__FTP+TFTP+DHCP+Kickstart+PXE
实验环境
1.实验平台:VMware Workstation 10
2.实验OS:RHEL6
3.服务器A:
(1) 10.0.10.158
(2) DHCP/FTP/TFTP
(3) 有可使用的yum源
(4) 关闭防火墙和SELinux
4.服务器B:
(1) 为RHEL6被安装端
(2) 设置为网络引导安装
(3) 在VM中设置A和B连接在同一个LAN segement
准备工作
生成ks.cfg 文件需要system-config-kickstart 工具,而此工具依赖于X Windows。所以我们需要在服务器A安装X Windows 和Desktop(图形界面支持):
# yum groupinstall Desktop # yum groupinstall "X Window System" # startx ----->#可启动图形界面
FTP的安装与配置
# yum install vsftp* -y ------>#安装ftp # service vsftpd start ------>#启动ftp服务 # chkconfig vsftpd on ------>#设置为开机自动启动
注意:FTP的配置,一定要保证anonymous匿名用户可以登录!
TFTP的安装与配置
1.安装tftp服务
# yum install tftp -y # yum install tftp-server -y
2.修改配置文件中13、14行的内容
# vim /etc/xinetd.d/tftp
1 # default: off
2 # description: The tftp server serves files using the trivial file transfer \
3 # protocol. The tftp protocol is often used to boot diskless \
4 # workstations, download configuration files to network-aware printers, \
5 # and to start the installation process for some operating systems.
6 service tftp
7 {
8 socket_type = dgram
9 protocol = udp
10 wait = yes
11 user = root
12 server = /usr/sbin/in.tftpd
13 server_args = -s /tftpboot #修改
14 disable = no #修改
15 per_source = 11
16 cps = 100 2
17 flags = IPv4
18 }
3.重启xinetd服务,检查端口(xinetd本来就是开机自启的),则TFTP服务可正常启动了
# /etc/init.d/xinetd start # lsof -i:69 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME xinetd 16111 root 5u IPv4 76202 0t0 UDP *:tftp
DHCP的安装与配置
1.安装DHCP,修改配置文件
# yum install dhcp -y
# vim /etc/dhcp/dhcpd.conf
ddns-update-style none;
ignore client-updates;
log-facility local7;
default-lease-time 3600;
max-lease-time 72000;
subnet 10.0.10.0 netmask 255.255.255.0 {
range 10.0.10.1 10.0.10.200;
option routers 10.0.10.158;
option subnet-mask 255.255.255.0;
}
filename "pxelinux.0"; ------>#这是网络引导必须有的配置
next-server 10.0.10.158; ------>#这是网络引导必须有的配置
2.重启服务,设置为开机自启
# service dhcpd restart
# chkconfig dhcpd on
配置Kicksart
# mkdir /tftpboot ------>#这对应了我们之前在xinetd.d/tftp配置文件中的设置(13行) # mkdir /tftpboot/pxelinux.cfg # yum install system-config-kickstart.noarch –y # cp /usr/share/syslinux/pxelinux.0 /tftpboot/ ------>#要安装system-config-kickstart.noarch才找得到syslinux这个目录的
# mount /dev/sr0 /mnt ------>挂载光盘到/mnt下,就可以拷贝光盘中需要的文件了 # cp /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default # cp /mnt/images/pxeboot/initrd.img /tftpboot/ # cp /mnt/images/pxeboot/vmlinuz /tftpboot/ # chmod 644 /tftpboot/pxelinux.cfg/default
# vim /tftpboot/pxelinux.cfg/default
1 default linux ------>#修改这里为linux,表示寻找18行的label linux
2 #prompt 1
3 timeout 600
4
5 display boot.msg
6
7 menu background splash.jpg
8 menu title Welcome to Red Hat Enterprise Linux 6.4!
9 menu color border 0 #ffffffff #00000000
10 menu color sel 7 #ffffffff #ff000000
11 menu color title 0 #ffffffff #00000000
12 menu color tabmsg 0 #ffffffff #00000000
13 menu color unsel 0 #ffffffff #00000000
14 menu color hotsel 0 #ff000000 #ffffffff
15 menu color hotkey 7 #ffffffff #ff000000
16 menu color scrollbar 0 #ffffffff #00000000
17
18 label linux
19 menu label ^Install or upgrade an existing system
20 menu default
21 kernel vmlinuz
22 append initrd=initrd.img ks=ftp://10.0.10.158/ks.cfg ------>#修改这里(我们后面会生成ks.cfg这个文件的)------>如果要做成有人值守安装这行应该注释掉
23 label vesa
24 menu label Install system with ^basic video driver
25 kernel vmlinuz
26 append initrd=initrd.img xdriver=vesa nomodeset
27 label rescue
28 menu label ^Rescue installed system
29 kernel vmlinuz
30 append initrd=initrd.img rescue
31 label local
32 menu label Boot from ^local drive
33 localboot 0xffff
34 label memtest86
35 menu label ^Memory test
36 kernel memtest
37 append -
制作无人值守安装文件
1.在图形界面下,打开终端输入system-config-kickstart,弹出界面
(1)基本配置:
设置下默认安装的语言,时区,根口令,然后勾选下面的安装后重新引导

选择执行新安装,配置ftp服务器的安装方法。


(4).分区信息
根据需要规划分区大小

(5).网络配置
选择DHCP方式

(6).验证

(7).防火墙配置
根据需求选择开启或关闭防火墙和SELinux

(8).显示配置(再次盗图...)

(9).软件包选择
根据需求选择

(10).预安装脚本和安装后脚本
根据需求配置


2.左上角file,点击保存,命令为ks.cfg

最后一点步骤~
1.记得我们的在/tftpboot/pxelinux.cfg/default文件的22行中写过:
append initrd=initrd.img ks=ftp://10.0.10.158/ks.cfg
我们告诉了被安装机子要去哪里找这个安装文件,所以得把ks.cfg这个安装文件放到/var/ftp下,让它到时候可以去FTP服务器下载到这个安装文件
# cp /root/ks.cfg /var/ftp
2.记得我们在制作安装文件ks.cfg时,对于第(2)安装方法的配置吗。我们的安装源设置成了FTP方式,目录写了/pub
所以,要把光盘挂到/var/ftp/pub下,被安装机子需要的安装光盘里面的内容,就是到这里去找的
# mount /dev/sr0 /var/ftp/pub
补充
1.可以查看一下安装文件ks.cfg的内容,会发现实质就是我们在制作过程中选择的那些设置
#platform=x86, AMD64, or Intel EM64T #version=DEVEL # Firewall configuration firewall --disabled # Install OS instead of upgrade install # Use network installation url --url="ftp://10.0.10.158/pub" # Root password rootpw --iscrypted $1$4mwMdVVg$x40MwRz3xD13hzBGOIwUs0 # System authorization information auth --useshadow --passalgo=md5 # Use graphical install graphical firstboot --disable # System keyboard keyboard us # System language lang zh_CN # SELinux configuration selinux --disabled # Installation logging level logging --level=info # Reboot after installation reboot # System timezone timezone Africa/Abidjan # Network information network --bootproto=dhcp --device=eth0 --onboot=on # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part /boot --fstype="ext4" --size=200 part /home --fstype="ext4" --size=500 part swap --fstype="swap" --size=1024 part / --fstype="ext4" --grow --size=1 %packages @additional-devel @base @basic-desktop @chinese-support @console-internet @desktop-debugging @desktop-platform @development @emacs @fonts @general-desktop @graphical-admin-tools @graphics @input-methods @internet-applications @internet-browser @kde-desktop @network-tools @nfs-file-server @office-suite @remote-desktop-clients @system-admin-tools @system-management @system-management-snmp @system-management-wbem @tex @x11 git ftp tftp wget xsettings-kde -ibus-table-cangjie -ibus-table-erbi -ibus-table-wubi %end %post chkconfig NetworkManager off ------>#所以可以在其中添加一些脚本来实现一些自定义的设置 sed -i '/NM/s/yes/no/' /etc/sysconfig/network-scripts/ifcfg-eth0 mkdir /myfile wget ftp://10.0.0.254/pub/service.txt -O /myfile chmod 600 /myfile/service.txt useradd user01 echo "aixocm" | passwd --stdin user01 %end
2.实验过程遇到的错误
见博文:http://www.cnblogs.com/snsdzjlz320/p/5630268.html

浙公网安备 33010602011771号