红联Linux门户
Linux帮助

KickStart+PXE+HTTPd+DHCP+TFTP自动安装Ubuntu 12.04

发布时间:2014-11-08 09:31:27来源:linux网站作者:wgkgood

前言

KickStart很多运维人员都非常熟悉,我们大多数都用它来实现自动安装系统,常见的用自动安装RedHat Linux,最近由于业务需求,需要安装Ubuntu,跟Redhat Linux还是有一些区别,记录安装步骤,供大家相互交流和学习!


一、环境及软件

系统:CentOS 6.0、Ubuntu 12.04

软件:KickStart、PXE、HTTPd、TFTPp、DHCP


二、正式安装

本环境是基于在CentOS系统上搭建KickStart Ubuntu自动安装服务端。

在服务器端执行:yum install dhcp* tftp* httpd* -y

安装完后然后配置

1、配置ftfp:

# default: off 
 
# description: The tftp server serves files using the trivial file transfer \ 
 
#   protocol.  The tftp protocol is often used to boot diskless \ 
 
#   workstations, download configuration files to network-aware printers, \ 
 
#   and to start the installation process for some operating systems. 
 
service tftp 
 

 
disable = no 
 
socket_type = dgram 
 
protocol= udp 
 
wait= yes 
 
user= root 
 
server  = /usr/sbin/in.tftpd 
 
server_args = -s /var/lib/tftpboot 
 
per_source  = 11 
 
cps = 100 2 
 
flags   = IPv4 
 
}

把disable=yes改成disable=no即可!

安装完tftp后,默认在/根目录会生成/tftpboot文件夹,如果没有请链接ln –s /var/lib/tftboot  /即可。

挂载ubuntu12.04.iso文件

Mount /dev/cdrom /mnt &&cp /mnt/install/netboot/*  /tftboot/下

然后修改vi  /tftboot/ubuntu-installer/amd64/boot-screens/txt.cfg

2、配置httpd、kickstart:

正如第二步里面有一个http://192.9.117.143/ubuntu/ks.cfg

默认安装完后apache的发布目录为/var/www/html

在/var/www/html下建立安装源:

mkdir  -p /var/www/html/ubuntu

然后将ubuntu光盘所有文件拷贝到/var/www/html/ubuntu下

cp -a  /mnt/* /var/www/html/ubuntu

然后在/var/www/html/ubuntu目录下新建ks.cfg文件,权限设置为chmod 777 ks.cfg

ks.cfg内容如下:

install 
text 
lang en_US 
langsupport en_US 
keyboard us 
mouse 
timezone --utc Asia/Chongqing 
rootpw --disabled 
user tdt --fullname="tdt" --password wuguangke 
reboot 
url --url http://192.9.117.143/ubuntu 
bootloader --location=mbr
zerombr yes 
clearpart --all --initlabel 
part /boot --fstype ext4 --size 200 
part swap --size 1024 
part / --fstype ext4 --size 1 --grow 
auth --useshadow --enablemd5 
network --bootproto=dhcp --device=eth0
firewall --disabled 
skipx 
%packages 
penssh-server 
openssh-client 
nfs-kernel-server 
vim

3、配置dhcp:

下面贴出我真实环境的DHCP配置内容:

ddns-update-style interim; 
ignore client-updates; 
next-server 192.9.117.143; 
filename "pxelinux.0"; 
allow booting; 
allow bootp; 
subnet 192.9.117.0 netmask 255.255.255.0 { 
# — default gateway 
 
option routers 192.9.117.254; 
 
option subnet-mask 255.255.255.0; 
 
# option nis-domain “domain.org”; 
 
option domain-name "tdt.com"; 
 
option domain-name-servers 202.106.0.20; 
 
option time-offset -18000; # Eastern Standard Time 
 
range 192.9.117.140 192.9.117.160; 
}


三、启动服务

以上所有配置完毕,启动所有相关服务

/etc/init.d/dhcpd  start ;/etc/init.d/xinetd start ;/etc/init.d/httpd start 即可!


四、测试kickstart是否成功

找一台客户机,BIOS修改成网卡启动即可!