PXE装机和kickstart无人值守技术

 

PXE:通过网卡引导的技术
1.BIOS支持
2.网卡支持
3.需要在BIOS中开启(服务器在BMC界面打开)
4.部署一台服务器,安装DHCP和tftp(内存需要大于2G)
5.VM新加一块网卡选择仅主机模式,并且关闭dhcp

[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-ens37
[root@localhost network-scripts]# vim ifcfg-ens37
[root@localhost network-scripts]# systemctl restart netwoek

6.安装和配置dhcp

[root@localhost ~]# yum -y install dhcp 
[root@localhost ~]# cd /etc/dhcp/ 
[root@localhost dhcp]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf 
cp:是否覆盖"/etc/dhcp/dhcpd.conf"? y
[root@localhost dhcp]# vim dhcpd.conf 
subnet 192.168.6.0 netmask 255.255.255.0 {   #分配的网段与子网掩码
  range 192.168.6.11 192.168.6.253;          #分配的IP地址范围
  option domain-name-servers 192.168.6.1;   #DNS服务器的IP地址
# option domain-name "example.com";          #DNS服务器的域名
  option routers 192.168.6.1;               #网关地址
  next-server 192.168.6.10;                  #指向TFTP路径
  filename "pxelinux.0";                     #引导文件
# option broadcast-address 192.168.6.255;    #广播地址
# default-lease-time 600;
# max-lease-time 7200;
}

7.安装和配置syslinux和tftp

[root@localhost ~]# yum -y install syslinux tftp-server

[root@localhost ~]# rpm -ql syslinux|grep pxelinux.0
/usr/share/syslinux/pxelinux.0         #pxelinux.0引导文件位置
[root@localhost ~]# rpm -ql tftp-server
/etc/xinetd.d/tftp    #配置文件
/var/lib/tftpboot     #tftp站点       
[root@localhost ~]# vim /etc/xinetd.d/tftp 
        disable                 = no    #改成no

8.复制引导文件pxelinux.0到/var/lib/tftpboot

[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
[root@localhost ~]# cd /var/lib/tftpboot/
[root@localhost tftpboot]# ls
pxelinux.0

9.安装vsftp服务,并将内核和初始化文件复制到tftp站点中

[root@localhost tftpboot]# yum -y install vsftpd
[root@localhost tftpboot]# cd /var/ftp/
[root@localhost ftp]# mkdir centos7
[root@localhost ftp]# mount /dev/cdrom centos7/
[root@localhost ftp]# cd centos7/images/pxeboot/
[root@localhost pxeboot]# cp initrd.img vmlinuz /var/lib/tftpboot/
[root@localhost pxeboot]# ls /var/lib/tftpboot/
initrd.img  pxelinux.0  vmlinuz

10.编辑启动菜单default配置文件,关闭防火墙和SELinux,并开启三个服务

[root@localhost pxeboot]# cd /var/lib/tftpboot/
[root@localhost tftpboot]# mkdir pxelinux.cfg
[root@localhost tftpboot]# ls
initrd.img  pxelinux.0  pxelinux.cfg  vmlinuz
[root@localhost tftpboot]# cd pxelinux.cfg/
[root@localhost pxelinux.cfg]# vim default


default auto   #默认自动
prompt 0       #设置用户是否等待选择,1选择。0不选择

label auto
        kernel vmlinuz
        append initrd=initrd.img method=ftp://192.168.6.10/centos7

label linux text              #文本模式
        kernel vmlinuz
        append text initrd=initrd.img method=ftp://192.168.6.10/centos7
                              #急救模式
label linux rescue
        kernel vmlinuz
        append rescue text initrd=initrd.img method=ftp://192.168.6.10/centos7

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl start tftp
[root@localhost ~]# systemctl start dhcpd
[root@localhost ~]# systemctl start vsftpd
[root@localhost ~]# systemctl enable tftp
[root@localhost ~]# systemctl enable dhcpd
[root@localhost ~]# systemctl enable vsftpd

kickstart无人值守技术

1.安装kickstart软件

[root@localhost ~]# yum -y install system-config-kickstart 

2.对kickstart进行设置(保存文件可以先保存在别处,在移动到/var/ftp目录下)

 

3.将安装软件包的模板复制到ks.cfg中,并在/var/lib/tftproot中引导加载模板,让其生效

[root@localhost ~]# ls /var/ftp/
centos7  ks.cfg  pub
[root@localhost ~]# cd /root/
[root@localhost ~]# ls
anaconda-ks.cfg  initial-setup-ks.cfg
[root@localhost ~]# cat anaconda-ks.cfg  #将anaconda-ks.cfg的安装软件包模板复制到/var/ftp下的ks.cfg中
%packages
@^gnome-desktop-environment
@base
@core
@desktop-debugging
@dial-up
@directory-client
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@input-methods
@internet-browser
@java-platform
@multimedia
@network-file-system-client
@networkmanager-submodules
@print-client
@x11
chrony
kexec-tools

%end
[root@localhost ~]# vim /var/ftp/ks.cfg #将以上内容插入文件末尾

4.引导加载ks.cfg模板到/var/lib/tftproot/pxelinux.cfg/下的default文件中

[root@localhost ~]# vim /var/lib/tftpboot/pxelinux.cfg/default 
default auto
prompt 0

label auto
        kernel vmlinuz
        append initrd=initrd.img method=ftp://192.168.6.10/centos7 ks=ftp://192.
168.6.10/ks.cfg

label linux text
        kernel vmlinuz
        append text initrd=initrd.img method=ftp://192.168.6.10/centos7

label linux rescue
        kernel vmlinuz
        append rescue text initrd=initrd.img method=ftp://192.168.6.10/centos7

5.新建虚拟机,然后选择仅主机模式进行安装

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值