Linux PXE + Kickstart 自动装机
发布时间:2020-12-14 00:18:19 所属栏目:Linux 来源:网络整理
导读:大规模装机时,使用无人值守装机便可大大简便人工操作,提高效率。 PXE 网络安装 配置双网卡 这里 ens33 为 nat 网络, ens37 为仅主机网络,配置 ens37 [[email?protected] ~]# cd /etc/sysconfig/network-scripts/[[email?protected] network-scripts]# cp
大规模装机时,使用无人值守装机便可大大简便人工操作,提高效率。 PXE 网络安装配置双网卡
[[email?protected] ~]# cd /etc/sysconfig/network-scripts/ [[email?protected] network-scripts]# cp ifcfg-ens33 ifcfg-ens37 [[email?protected] network-scripts]# vim ifcfg-ens37 TYPE=Ethernet BOOTPROTO=static DEVICE=ens37 ONBOOT=yes IPADDR=192.168.100.100 NETMASK=255.255.255.0 GATEWAY=192.168.100.1
[[email?protected] ~]# service network restart Restarting network (via systemctl): [ OK ]
[[email?protected] ~]# ifconfig ens33 ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.28.128 netmask 255.255.255.0 broadcast 192.168.28.255 inet6 fe80::605e:3c48:bafd:e550 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:bc:ab:96 txqueuelen 1000 (Ethernet) RX packets 635342 bytes 935571060 (892.2 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 288265 bytes 17505470 (16.6 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [[email?protected] ~]# ifconfig ens37 ens37: flags=4163<UP,MULTICAST> mtu 1500 inet 192.168.100.100 netmask 255.255.255.0 broadcast 192.168.100.255 inet6 fe80::20c:29ff:febc:aba0 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:bc:ab:a0 txqueuelen 1000 (Ethernet) RX packets 1514 bytes 461770 (450.9 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 186 bytes 31726 (30.9 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 DHCP 服务
[[email?protected] ~]# yum install dhcp -y
[[email?protected] ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf cp: overwrite ‘/etc/dhcp/dhcpd.conf’? y [[email?protected] ~]# vim /etc/dhcp/dhcpd.conf
subnet 192.168.100.0 netmask 255.255.255.0 { range 192.168.100.20 192.168.100.50; option routers 192.168.100.100; option domain-name-servers 114.114.114.114; next-server 192.168.100.100; filename "pxelinux.0"; }
[[email?protected] ~]# yum install syslinux -y
[[email?protected] ~]# rpm -ql syslinux | grep pxelinux.0 /usr/share/syslinux/gpxelinux.0 /usr/share/syslinux/pxelinux.0 TFTP 服务
[[email?protected] ~]# yum install tftp-server -y
[[email?protected] ~]# rpm -ql tftp-server /etc/xinetd.d/tftp /usr/lib/systemd/system/tftp.service /usr/lib/systemd/system/tftp.socket /usr/sbin/in.tftpd /usr/share/doc/tftp-server-5.2 /usr/share/doc/tftp-server-5.2/CHANGES /usr/share/doc/tftp-server-5.2/README /usr/share/doc/tftp-server-5.2/README.security /usr/share/man/man8/in.tftpd.8.gz /usr/share/man/man8/tftpd.8.gz /var/lib/tftpboot
[[email?protected] ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[[email?protected] ~]# vim /etc/xinetd.d/tftp
disable = no FTP 服务
[[email?protected] ~]# yum install vsftpd -y
[[email?protected] ~]# mkdir /var/ftp/centos7 [[email?protected] ~]# mount /dev/cdrom /var/ftp/centos7/ mount: /dev/sr0 is write-protected,mounting read-only [[email?protected] ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/sda2 xfs 20G 4.3G 16G 22% / devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs tmpfs 1.9G 9.0M 1.9G 1% /run tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda5 xfs 10G 37M 10G 1% /home /dev/sda1 xfs 2.0G 174M 1.9G 9% /boot tmpfs tmpfs 378M 40K 378M 1% /run/user/0 /dev/sr0 iso9660 4.3G 4.3G 0 100% /var/ftp/centos7
[[email?protected] ~]# cd /var/ftp/centos7/images/pxeboot/ [[email?protected] pxeboot]# cp initrd.img vmlinuz /var/lib/tftpboot/
[[email?protected] ~]# mkdir /var/lib/tftpboot/pxelinux.cfg [[email?protected] ~]# vim /var/lib/tftpboot/pxelinux.cfg/default default auto prompt 1 label auto kernel vmlinuz append initrd=initrd.img method=ftp://192.168.100.100/centos7 label linux text kernel vmlinuz append text initrd=initrd.img method=ftp://192.168.100.100/centos7 label linux rescue kernel vmlinuz append rescue initrd=initrd.img method=ftp://192.168.100.100/centos7
[[email?protected] ~]# tree /var/lib/tftpboot/ /var/lib/tftpboot/ ├── initrd.img ├── pxelinux.0 ├── pxelinux.cfg │?? └── default └── vmlinuz 1 directory,4 files
[[email?protected] ~]# systemctl enable dhcpd Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/systemd/system/dhcpd.service. [[email?protected] ~]# systemctl enable tftp Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket. [[email?protected] ~]# systemctl enable vsftpd Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service. [[email?protected] ~]# systemctl start dhcpd [[email?protected] ~]# systemctl start tftp [[email?protected] ~]# systemctl start vsftpd 关闭防火墙[[email?protected] ~]# systemctl stop firewalld [[email?protected] ~]# setenforce 0
PXE 装机验证
kickstart 无人值守安装安装软件包[[email?protected] ~]# yum install system-config-kickstart -y 启动程序[[email?protected] ~]# system-config-kickstart 创建自动应答文件
编辑 ks.cfg[[email?protected] ~]# ls /var/ftp/ centos7 ks.cfg pub
[[email?protected] ~]# vim /root/anaconda-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
[[email?protected] ~]# vim /var/ftp/ks.cfg #platform=x86,AMD64,or Intel EM64T #version=DEVEL # Install OS instead of upgrade install # Keyboard layouts keyboard 'us' # Root password rootpw --iscrypted $1$MzI8tkpP$whWLRJqNdsvOMTgOewQ0i1 # Use network installation url --url="ftp://192.168.100.100/centos7" # System language lang en_US # Firewall configuration firewall --disabled # System authorization information auth --useshadow --passalgo=sha512 # Use graphical install graphical firstboot --disable # SELinux configuration selinux --disabled # Network information network --bootproto=dhcp --device=ens33 # Reboot after installation reboot # System timezone timezone Asia/Shanghai # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all # Disk partitioning information part /boot --fstype="xfs" --size=1024 part /home --fstype="xfs" --size=5120 part swap --fstype="swap" --size=4096 part / --fstype="xfs" --grow --size=1 %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 编辑启动菜单[[email?protected] ~]# vim /var/lib/tftpboot/pxelinux.cfg/default default auto prompt 1 label auto kernel vmlinuz append initrd=initrd.img method=ftp://192.168.100.100/centos7 ks=ftp://192.168.100.100/ks.cfg label linux text kernel vmlinuz append text initrd=initrd.img method=ftp://192.168.100.100/centos7 label linux rescue kernel vmlinuz append rescue initrd=initrd.img method=ftp://192.168.100.100/centos7
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- linux – 错误:RPC失败; result = 6,HTTP代码= 0
- Linux如何查看与测试磁盘IO性能
- Linux 下的 python 虚拟环境 + vim快捷方式
- linux – 使用LDAP进行身份验证的Samba独立服务器:SID不匹
- R vs sed正则表达式贪婪
- 如何在linux上的eclipse上编译android项目之前的.sh
- linux – RTNETLINK答案:执行“服务网络重启”时存在文件
- linux – Apache可用性,两个前端位于不同的位置.可能吗?
- linux – 从网页运行bash文件
- linux – 如何防止rsync(使用ssh作为远程shell)面对密码提示