linux 基础 PEX
#####PXE######
PXE的工作过程:
1.PXE Client 从自己的PXE网卡启动,向本网络中的DHCP服务器索取IP;
2.DHCP服务器返回分配给客户机的IP以及PXE文件的放置位置(该文件一般是放在一台TFTP服务器上);
3.PXE Client向本机网络中的TFTP服务器索取pxelinux.0文件;
4.PXE Client取得pxelinux.0文件后执行该文件;
5.根据pxelinux.0的执行结果,通过TFTP服务器加载内核和文件系统;
#####1.kickstart文件共享,配置http安装方式#####
1.
# yum install httpd -y
# systemctl start httpd
# systemctl stop firewalld.service
# mkdir /var/www/html/rhel7.1
# mount /dev/sr0 /var/www/html/rhel7.1
mount: /dev/sr0 is write-protected, mounting read-only
2.关机重启后依旧挂载
# vim /etc/fstab
/dev/sr0/var/www/html/rhel7.1 defaults 0 0
# mount -a
#####2配置tftp#######
# yum install tftp-server -y ####安装tftp服务
# vim /etc/xinetd.d/tftp ####启动tftp服务
# systemctl restart xinetd.service
# chkconfig --list
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies '.
iprdump 0:off1:off2:on3:on4:on5:on6:off
iprinit 0:off1:off2:on3:on4:on5:on6:off
iprupdate 0:off1:off2:on3:on4:on5:on6:off
netconsole 0:off1:off2:off3:off4:off5:off6:off
network 0:off1:off2:on3:on4:on5:on6:off
rhnsd 0:off1:off2:on3:on4:on5:on6:off
xinetd based services:
chargen-dgram: off
chargen-stream:off
daytime-dgram: off
daytime-stream:off
discard-dgram: off
discard-stream:off
echo-dgram: off
echo-stream: off
tcpmux-server: off
tftp: on
time-dgram: off
time-stream: off
#######配置ks.cfg文件######
Kickstart:是一种无人值手的安装方式。Kickstart脚本是自动应答系统在安装过程中一切问题的脚本文件,这个文件可以实现系统的自动安装。在系统安装完成后会在系统的root家目录中生成anaconda-ks.cfg,这个文件就是以此系统为模板生成的kickstart脚本。
#####kickstart脚本的制作####
手动编写kickstart的难度大,系统中system-config-kickstart工具可以以图形的方式制作kickstart脚本。
# yum provides */system-config-kickstart ####找出有此工具的安装包
# yum install system-config-kickstart-2.9.2-4.el7.noarch -y ###安装图形制作工具
# system-config-kickstart ###打开图形ks制作工具
/usr/share/system-config-kickstart/kickstartGui.py:104: GtkWarning: GtkSpinButton: setting an adjustment with non-zero page size is deprecated
xml = gtk.glade.XML ("/usr/share/system-config-kickstart/system-config-kickstart.glade", domain="system-config-kickstart")
Loaded plugins: langpacks
将ks.cfg文将保存到/var/www/html/中
# cd /var/www/html/
# ls
ks.cfgrhel7.1
# vim ks.cfg
%packages
@base
lftp
%end
# ksvalidator ks.cfg ####检验ks.cfg语法
#######配置支持PXE的启动程序########
# yum whatprovides */pxelinux.0
Loaded plugins: langpacks
syslinux-4.05-12.el7.x86_64 : Simple kernel loader which boots from a FAT filesystem
Repo : rhel_dvd
Matched from:
Filename : /usr/share/syslinux/pxelinux.0
# yum install syslinux-4.05-12.el7.x86_64-y
# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
# cd /var/lib/tftpboot
# ls
pxelinux.0
# mount /dev/sr0 /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3377228 709667233% /
devtmpfs 927072 0 927072 0% /dev
tmpfs 942660 140 942520 1% /dev/shm
tmpfs 942660 17080 925580 2% /run
tmpfs 942660 0 942660 0% /sys/fs/cgroup
/dev/sr0 3798292 3798292 0 100% /mnt
# cd /mnt/
# ls
addonsGPL LiveOS release-notes RPM-GPG-KEY-redhat-release
EFI images media.reporepodata TRANS.TBL
EULA isolinuxPackages RPM-GPG-KEY-redhat-beta
# cd isolinux/
# ls
boot.catgrub.conf isolinux.binmemtest TRANS.TBL vesamenu.c32
boot.msginitrd.imgisolinux.cfgsplash.pngupgrade.imgvmlinuz
# cp -r /mnt/isolinux/* /var/lib/tftpboot/
# ls
boot.catgrub.conf isolinux.binmemtest splash.pngupgrade.img vmlinuz
boot.msginitrd.imgisolinux.cfgpxelinux.0TRANS.TBL vesamenu.c32
# mkdir pxelinux.cfg
# cp isolinux.cfg pxelinux.cfg/default
# ls
boot.catgrub.conf isolinux.binmemtest pxelinux.cfgTRANS.TBL vesamenu.c32
boot.msginitrd.imgisolinux.cfgpxelinux.0splash.png upgrade.imgvmlinuz
# cd pxelinux.cfg/
# ls
default
# vim default
可在此文件中改标题等
#########配置dhcp服务########
root@localhost ~]# yum install dhcp -y
# cd /etc/dhcp
# ls
dhclient.ddhcpd6.confdhcpd.conf
# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
cp: overwrite ‘/etc/dhcp/dhcpd.conf’? yes
# vim dhcpd.conf
# systemctl restart dhcpd
#########检测是否搭建成功######
新建虚拟机
页:
[1]