DHCP+TFTP+HTTP+Kickstart實現遠端自動安裝Linux系統

mikeliuy發表於2016-04-14

KickstartLinux下自動安裝作業系統的工具,配合其它服務與工具,可以實現遠端自動安裝Linux系統。以下是大致步驟:

 

0、準備yum

<>

 

1、安裝DHCP,為target機器提供IPnetmaskgateway等資訊。

# 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僅是網路安裝庫,kickstartinst.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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章