Kickstart是Linux下自动安装操作系统的工具,配合其它服务与工具,可以实现远程自动安装Linux系统。以下是大致步骤:
0、准备yum源
<略>
1、安装DHCP,为target机器提供IP,netmask,gateway等信息。
# yum install dhcp\* -y
# 编辑配置
# cd /etc/dhcp/
# cat dhcpd.conf
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
# rpm -ql dhcp | grep dhcpd.conf
# cat /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example > dhcpd.conf
# vim dhcpd.conf
subnet 192.168.36.0 netmask 255.255.255.0 {
range 192.168.36.50 192.168.36.100;
option domain-name-servers 192.168.36.129; #DNS
option domain-name "example.com";
option routers 192.168.36.129;
option broadcast-address 192.168.36.255;
next-server 192.168.36.129; #tfpt-server
filename "/pxelinux.0"; #tftp's root directory
default-lease-time 600;
max-lease-time 7200;
}
# systemctl restart dhcpd
# systemctl enable dhcpd
# systemctl is-active dhcpd
2、安装tftp-server,组织引导程序及配置
# yum install tftp-server -y
# yum provides */pexlinux.0
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
local/filelists_db | 3.1 MB 00:00
No matches found
# yum provides */pxelinux.0
# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
# cd /cdrom/images/pxeboot/
# ls
initrd.img TRANS.TBL upgrade.img vmlinuz
# cp initrd.img vmlinuz /var/lib/tftpboot/
# mkdir /var/lib/tftpboot/pxelinux.cfg
# cd /cdrom/isolinux/
# cp isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
# chmod u+w /var/lib/tftpboot/pxelinux.cfg/default
# cp /cdrom/isolinux/boot.msg /var/lib/tftpboot/
# cd /var/lib/tftpboot/
# ls
boot.msg initrd.img pxelinux.0 pxelinux.cfg vmlinuz
# ll pxelinux.cfg/
-rw-r--r--. 1 root root 3166 11月 3 10:16 default #需要配置此文件
# vim default
#修改成以下内容
default linux
……
label linux
menu label ^Install Red Hat Enterprise Linux 7.1
kernel vmlinuz
append initrd=initrd.img inst.repo=http://192.168.36.129/rhel71 #inst.repo仅是网络安装库,kickstart为inst.ks
# vim /etc/xinetd.d/tftp
#将disable=yes改为disable=yes
# systemctl start xinetd.service
# systemctl enable xinetd.service
# systemctl is-active xinetd.service
3、安装http,配置安装包repo
# yum group install web*
# cd /var/www/html/
# mkdir rhel71
# cp -ar /cdrom/* rhel71/
# systemctl enable httpd
# systemctl start httpd
# systemctl status httpd
到目前为止,已经可以支持通过网路安装Linux系统。
4、制作kickstart文件,支持远程自动安装。
# yum install system-config-kickstart -y
# system-config-kickstart &
保存到/var/www/html目录下。
修改/var/lib/tftpboot/pxelinux.cfg/default
# vim /var/lib/tftpboot/pxelinux.cfg/default
label linux
menu label ^Install Red Hat Enterprise Linux 7.1
kernel vmlinuz
append initrd=initrd.img inst.ks=http://192.168.36.129/ks.cfg
5、测试kickstart自动安装。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26812308/viewspace-2081160/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26812308/viewspace-2081160/