PXE 安装Linux服务器

最近遇到一个问题,公司内部的Linux服务器由于比较老,光驱坏了,也不支持U盘启动,所以没办法,只能用pxe来安装操作系统。网上教程很多,但是不够清晰,下来我来写一下我的安装过程。

A.安装dhcp服务器
yum install dhcp
vim /etc/dhcp/dhcpd.conf
#可以直接拷贝我的下列配置,修改子网即可
ddns-update-style interim;
ignore client-updates;
allow booting;
allow bootp;
subnet 192.168.2.0 netmask 255.255.255.0 {
    range 192.168.2.250 192.168.2.253;
    option routers 192.168.2.1;
    option subnet-mask 255.255.255.0;
    default-lease-time 21600;
    max-lease-time 43200;
    next-server 192.168.2.136;
    filename "pxelinux.0";
}

备注:
next-server:指定的地址是你启动文件存放的那个服务器,一般是tftp服务器地址。

启动dhcp服务器,如果报错,查看/var/log/message
chkconfig --add dhcpd
service dhcpd start

B.安装tftp服务器
yum install tftp-server
/etc/xinetd.d/tftp
#直接拷贝即可
service tftp
{
        socket_type            = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args            = -s /var/lib/tftpboot
        disable                = no
        per_source              = 11
        cps                    = 100 2
        flags                  = IPv4
}

启动
/etc/init.d/xinetd restart

C.安装一个http/nfs/ftp 中的任意一个即可,用来存放ks.cfg和iso镜像文件。
我选用http
yum install httpd 
/etc/init.d/httpd start
chkconfig httpd on

E.配置kickstart
#安装镜像位置
mkdir /var/www/html/dvd
cp -r /mnt/*  /var/www/html/dvd
#配置kickstart文件
yum install system-config-kickstart
cp /root/anaconda-ks.cfg /var/www/html/ks.cfg 
vi ks.cfg
#可以直接拷贝下列文件,注意http服务器修改为自己的即可。
# Install OS instead of upgrade
install
# Use network installation
url --url="http://192.168.2.136/dvd"
# Root password
rootpw --iscrypted $1$t8TZKP5c$0OdX9sWkdoYuZlIXBkU8R.
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone --isUtc Asia/Shanghai
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all
 
%packages
@base
 
%end

F.配置结束,可以找一台主板具有pxe的功能机子测试即可。
据我所知,目前大部分PC机就支持的。

推荐阅读

猜你喜欢

转载自www.linuxidc.com/Linux/2015-07/120291.htm