CentOS7 PXE安装批量安装操作系统
1、Environment CentOS7 Server VersionCentOS7 node7, IP Address 192.168.121.172、步骤如下:(1)安装需要的软件包[root@node7 ~]# yum -y install tftp-server httpd dhcp syslinux(2)配置DHCP:[root@node7 ~]#
·
1、Environment
CentOS7 Server Version
CentOS7 node7, IP Address 192.168.121.17
2、步骤如下:
(1)安装需要的软件包
[root@node7 ~]# yum -y install tftp-server httpd dhcp syslinux
(2)配置DHCP:
[root@node7 ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
[root@node7 ~]# cat /etc/dhcp/dhcpd.conf
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
# option definitions common to all supported networks...
option domain-name "galaxy.com";
option domain-name-servers 114.114.114.114;
default-lease-time 600;
max-lease-time 7200;
# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
#192.168.121.17是node7的IP地址,range表示的地址池
subnet 192.168.121.0 netmask 255.255.255.0 {
range 192.168.121.20 192.168.121.200;
option routers 192.168.121.17;
filename "pxelinux.0";
next-server 192.168.121.17;
}
# This is a very basic subnet declaration.
#subnet 10.254.239.0 netmask 255.255.255.224 {
# range 10.254.239.10 10.254.239.20;
# option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
#}
# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.
#subnet 10.254.239.32 netmask 255.255.255.224 {
# range dynamic-bootp 10.254.239.40 10.254.239.60;
# option broadcast-address 10.254.239.31;
# option routers rtr-239-32-1.example.org;
#}
# A slightly different configuration for an internal subnet.
#subnet 10.5.5.0 netmask 255.255.255.224 {
# range 10.5.5.26 10.5.5.30;
# option domain-name-servers ns1.internal.example.org;
# option domain-name "internal.example.org";
# option routers 10.5.5.1;
# option broadcast-address 10.5.5.31;
# default-lease-time 600;
# max-lease-time 7200;
#}
# Hosts which require special configuration options can be listed in
# host statements. If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.
#host passacaglia {
# hardware ethernet 0:0:c0:5d:bd:95;
# filename "vmunix.passacaglia";
# server-name "toccata.fugue.com";
#}
# Fixed IP addresses can also be specified for hosts. These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.
#host fantasia {
# hardware ethernet 08:00:07:26:c0:a5;
# fixed-address fantasia.fugue.com;
#}
# You can declare a class of clients and then do address allocation
# based on that. The example below shows a case where all clients
# in a certain class get addresses on the 10.17.224/24 subnet, and all
# other clients get addresses on the 10.0.29/24 subnet.
#class "foo" {
# match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
#}
#shared-network 224-29 {
# subnet 10.17.224.0 netmask 255.255.255.0 {
# option routers rtr-224.example.org;
# }
# subnet 10.0.29.0 netmask 255.255.255.0 {
# option routers rtr-29.example.org;
# }
# pool {
# allow members of "foo";
# range 10.17.224.10 10.17.224.250;
# }
# pool {
# deny members of "foo";
# range 10.0.29.10 10.0.29.230;
# }
#}
[root@node7 ~]# systemctl start dhcpd.service
[root@node7 ~]# cat /etc/xinetd.d/tftp #基本不用修改配置文件
# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = yes
per_source = 11
cps = 100 2
flags = IPv4
}
[root@node7 ~]# cat /usr/lib/systemd/system/tftp.service
[Unit]
Description=Tftp Server
Requires=tftp.socketDocumentation=man:in.tftpd[Service]ExecStart=/usr/sbin/in.tftpd -s /var/lib/tftpbootStandardInput=socket[Install]Also=tftp.socket
启动tftp-server服务:
[root@node7 ~]# systemctl start tftp.socket
如果UDP的69号端口启动,说明已经启动了tftp服务
设定PXE相关的文件:
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /usr/share/syslinux/{chain.c32,mboot.c32,menu.c32,memdisk} /var/lib/tftpboot/
cp /media/cdrom/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/ #基于pxe安装使用的光盘上的文件(自己本地挂载光盘即可)或者是yum仓库里
mkdir /var/lib/tftpboot/pxelinux.cfg/
vim default #default的文件内容如下
default menu.c32 #加载时显示的默认菜单控制的程序
prompt 5 #显示提示符时间
timeout 30 #超时时长
MENU TITLE CentOS 7 PXE Menu #标题为CentOS7 PXE Menu
LABEL linux #指明下面菜单项的label
MENU LABEL Install CentOS 7 x86_64 #菜单的label
KERNEL vmlinuz #指明kernel文件
APPEND initrd=initrd.img inst.repo=http://192.168.121.17/centos7 ks=http://192.168.121.17/centos7.cfg #附加给kernel的参数,inst.repo可以是教室的ftp服务器,或者把光盘当做yum仓库,把它作为一个网站的访问就可以了
(4)接下来在Vmware 下面挂载光盘
mkdir -pv /media/cdrom mount -r /dev/cdrom /media/cdrom mkdir -pv /var/www/html/centos7/ mount --bind /media/cdrom /var/www/html/centos7
配置kickstart文件:该kickstart文件是CentOS7 最小化安装的一部分+system-config-kickstart 命令创建的kickstart文件(强烈建议在desktop centos7 上面操作system-config-kickstart命令)的合集[root@node7 html]# pwd /var/www/html [root@node7 html]# ls centos7 centos7.cfg [root@node7 html]# cat centos7.cfg #platform=x86, AMD64, or Intel EM64T #version=DEVEL # Install OS instead of upgrade install # Keyboard layouts keyboard 'us' # Root password rootpw --iscrypted $1$1Yz7yBap$ULm/SsQw.7sOa73ZgXgOH1 #密码是123456,只不过此处是加密的文件 # System timezone timezone Asia/Shanghai # Use network installation url --url="http://192.168.121.17/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=eno16777736 # Halt after installation halt # System bootloader configuration bootloader --location=none # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Disk partitioning information #分区设定 part /boot --fstype="ext4" --size=500 part / --fstype="ext4" --size=102400 %packages #最小化安装 @^minimal @core kexec-tools %end %addon com_redhat_kdump --enable --reserve-mb='auto' %end
最后创建一个新的虚拟机,然后设定VMware 的网卡,设定为192.168.121.17为同一个网络段,可以设定为同一个交换机段即可:
最后的效果如下:
不过到此时 可能是VMware的问题,始终界面打开是黑屏不知道为何,在BIOS设定中也没有找到相关的VT选项,物理机应该是没有问题的。
更多推荐
已为社区贡献1条内容
所有评论(0)