第九周笔记

实验:实现CENTOS7 PXE安装
0 selinux ,firewall 关闭
1 安装包
yum install dhcp tftp-server httpd syslinux
systemctl enable dhcpd httpd tftp.socket
systemctl start httpd
2 准备YUM源
mkdir /var/www/html/centos/{6,7}/ -pv
vim /etc/fstab 加下面行
/dev/sr0 /var/www/html/centos/7 iso9660 defaults 0 0
mount -a
df
3 准备ks文件
mkdir /var/www/html/ksdir/{6,7} -pv
cp /root/anaconda-ks.cfg /var/www/html/ksdir/7/ks7_desktop.cfg
chmod +r /var/www/html/ksdir/7/ks7_desktop.cfg
vim /var/www/html/ksdir/7/ks7_desktop.cfg
url –url=http://192.168.30.7/centos/7
text
reboot
network –bootproto=dhcp –device=ens33 –onboot=on –ipv6=auto –activate
network –hostname=centos7.magedu.com
# Root password
zerombr
%packages
@base
@core
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@print-client
@x11
autofs
%end
%addon com_redhat_kdump –enable –reserve-mb=’auto’
%end
%post
systemctl enable autofs
systemctl disable initial-setup.service
systemctl set-default multi-user.target
mkdir /root/.ssh
cat > /root/.ssh/authorized_keys <<EOF
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCn7U/0bi4xPrC9ClfTC+VAHtfL37Djh22tfM9ebR1/rC9PMGGmm1oiaoLx7ltgNtJGUZEWLrvrgLmJEsv6V+89O8dROcysSSGkbiXJVMbb6Y6spHNVQBEiw30sNs8JyiWzWQJKrNyDj5WBTHDGFEzmhSP1+gZxLrwd/oZSvGL2KPzmznKfQ3P6lEWAAlsdkqB5pLLhVs55KlNo1pAF+nQ06VxYbETqEUyUZ37FqVGFdmU+tPjvLOfB0z0ufycenQSXJCnJB797yJMdqWlweAo9QmYyPFmGoPrqWVaIc/jA6b9JwMMY/Vb8SsYcBlvs3DxSfV84m27BNWb1w4Ai/P4D root@centos7.localdomain
EOF
rm -rf /etc/yum.repos.d/*
cat > /etc/yum.repos.d/base.repo <<EOF
[base]
name=base
baseurl=file:///misc/cd
gpgcheck=0
EOF
%end
4 配置dhcp服务
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf
[root@centos7 tftpboot]#cat /etc/dhcp/dhcpd.conf
option domain-name “magedu.org”;
option domain-name-servers 114.114.114.114,1.1.1.1;
option routers 192.168.30.200;
default-lease-time 86400;
max-lease-time 100000;
subnet 192.168.30.0 netmask 255.255.255.0 {
range 192.168.30.10 192.168.30.100;
option routers 192.168.30.254;
option domain-name-servers 8.8.8.8;
next-server 192.168.30.7;
filename “pxelinux.0”;
}
systemctl start dhcpd
5 准备PXE相关文件
rpm -ql syslinux
mkdir /var/lib/tftpboot/pxelinux.cfg/
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
cp /misc/cd/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/
cp /misc/cd/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
vim /var/lib/tftpboot/pxelinux.cfg/default
cat /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
timeout 600
menu title Auto Install CentOS
label desktop
menu label Install ^Desktop CentOS 7
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.30.7/ksdir/7/ks7_desktop.cfg
label mini
menu label Install ^Mini CentOS 7
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.30.7/ksdir/7/ks7_mini.cfg
label local
menu default
menu label Boot from ^local drive
localboot 0xffff
menu end
[root@centos7 tftpboot]#tree /var/lib/tftpboot/
/var/lib/tftpboot/
├── initrd.img
├── menu.c32
├── pxelinux.0
├── pxelinux.cfg
│?? └── default
└── vmlinuz

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/99613

发表评论

登录后才能评论

This site uses Akismet to reduce spam. Learn how your comment data is processed.

联系我们

400-080-6560

在线咨询:点击这里给我发消息

邮件:1823388528@qq.com

工作时间:周一至周五,9:30-18:30,节假日同时也值班