共享`pexlinux`数据文件的网络服务

实验环境准备:

1.红帽7主机

2.要全图形安装

3.配置网络为手动,配置网络可用

4.关闭vmware DHCP功能

一、kickstart自动安装脚本制作

1.安装图形化生成kickstart自动脚本安装工具

2.启动图形制作工具

3.图形配置脚本

这里使用的共享方式是http,这里不能乱写,需要根据自己的主机IP和自己创建的共享目录来填写,需要自己提前配置好http服务,具体步骤如下:

#下载hhtpd软件包,这里我已经下载了
[root@localhost redhat]# yum install httpd -y
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
              : manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

baseos                                                 | 2.8 kB     00:00     
Package httpd-2.4.6-95.el7.x86_64 already installed and latest version
Nothing to do


#/rhel7目录是我自己创建的目录用于写仓库和挂载,根据自己所创建的目录来更改
[root@localhost redhat]# ls /rhel7/
addons            images      repodata
EFI               isolinux    RPM-GPG-KEY-redhat-beta
EULA              LiveOS      RPM-GPG-KEY-redhat-release
extra_files.json  media.repo  TRANS.TBL
GPL               Packages

#将创建rhel7目录的软连接指向http服务的默认目录/var/www/html/中,创建软连接使用ln -s命令
[root@localhost redhat]# ll /var/www/html/
total 4
-rw-r--r--. 1 root root 1205 Aug  4 04:19 ks.cfg
lrwxrwxrwx. 1 root root    7 Aug  3 22:54 rhel7 -> /rhel7/

创建分区: 

 

 这里根据自己网卡名选择Add添加

 

 

 这里的内容是系统在启动后去执行的脚本,这里可以根据自己的需要去写就好了,需要启动后执行什么就在上面写上对应的命令

4.保持配置,保存路径自选,这里是/root

5.打开上面保存的ks脚本,配置安装时要下载的软件包

 删除--maxsize=1

 

6.新建一台红帽7虚拟机,测试自动安装,具体操作如下:

 

正常情况这里安装是会有问题的,不能够安装成功,还需要下面的操作,搭建DHCP服务。

二、搭建dhcp服务并测试kickstart脚本

在上一个实验的基础上继续。

1.安装dhcp服务器为其他服务器提供分配IP的功能

2.生成配置文件 

3.编写配置文件  

打叉表示35行下面的都不要

 整个配置文件内容如下:

[root@localhost ~]# cat /etc/dhcp/dhcpd.conf 
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#

# option definitions common to all supported networks...
option domain-name "timingma.org";
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.

#subnet 10.152.187.0 netmask 255.255.255.0 {
#}

# This is a very basic subnet declaration.

subnet 172.25.254.0 netmask 255.255.255.0 {
  range 172.25.254.30 172.25.254.40;
  option routers 172.25.254.2;
}

修改的地方如下:

 4.配置文件编写好后,启动DHCP服务

[root@localhost ~]# systemctl enable --now dhcpd

5.新建红帽7虚拟机,测试自动安装

 这里安装就可以了,正常情况就可以自动安装了。

 三、共享pexlinux数据文件的网络服务

在上一个实验的基础上继续。

1.下载软件包

  

2.启动服务
[root@localhost ~]# systemctl enable --now tftp
3.复制文件到pexlinux的默认共享目录/var/lib/tftpboot/

这里我磁盘挂载的地方是在/rhel7目录下,根据自己的具体情况来定

红帽在启动时的页面的定义是在isolinux目录下的文件定义的,所以需要将这些文件共享出去

[root@localhost ~]# df
Filesystem            1K-blocks    Used Available Use% Mounted on
devtmpfs                 914480       0    914480   0% /dev
tmpfs                    931516       0    931516   0% /dev/shm
tmpfs                    931516   10712    920804   2% /run
tmpfs                    931516       0    931516   0% /sys/fs/cgroup
/dev/mapper/rhel-root  17811456 4297536  13513920  25% /
/dev/sda1               1038336  187276    851060  19% /boot
tmpfs                    186304      36    186268   1% /run/user/1000
/dev/sr0                4420474 4420474         0 100% /rhel7
tmpfs                    186304       0    186304   0% /run/user/0
[root@localhost ~]# cp /rhel7/isolinux/* /var/lib/tftpboot/
[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
4.移动到默认目录,创建default目录

5.修改/etc/dhcp/dhcpd.conf配置文件
# This is a very basic subnet declaration.

subnet 172.25.254.0 netmask 255.255.255.0 {
  range 172.25.254.30 172.25.254.40;
  option routers 172.25.254.2;
  next-server 172.25.254.131;   #这里指定下一个服务器找谁
  filename "pxelinux.0";   #这个表示找哪个文件
}
6.修改default文件

前提你的共享地址在浏览器上是可以访问到的如下:

如果访问显示的错误码是404,那可能是你的文件路径有问题,没有找到,要根据自己创建的目录来定;如果是没有权限,那检查一下自己的防火墙有没有关等。

 

[root@localhost ~]# cat /var/lib/tftpboot/pxelinux.cfg/default 
default vesamenu.c32
timeout 30  #这里是在安装系统的选择页面的等待时间,30为3秒,默认是600,这里我们将其改为三秒让其指定安装

display boot.msg

# Clear the screen when exiting the menu, instead of leaving the menu displayed.
# For vesamenu, this means the graphical background is still displayed without
# the menu itself for as long as the screen remains in graphics mode.
menu clear
menu background splash.png
menu title Red Hat Enterprise Linux 7.9
menu vshift 8
menu rows 18
menu margin 8
#menu hidden
menu helpmsgrow 15
menu tabmsgrow 13

# Border Area
menu color border * #00000000 #00000000 none

# Selected item
menu color sel 0 #ffffffff #00000000 none

# Title bar
menu color title 0 #ff7ba3d0 #00000000 none

# Press [Tab] message
menu color tabmsg 0 #ff3a6496 #00000000 none

# Unselected menu item
menu color unsel 0 #84b8ffff #00000000 none

# Selected hotkey
menu color hotsel 0 #84b8ffff #00000000 none

# Unselected hotkey
menu color hotkey 0 #ffffffff #00000000 none

# Help text
menu color help 0 #ffffffff #00000000 none

# A scrollbar of some type? Not sure.
menu color scrollbar 0 #ffffffff #ff355594 none

# Timeout msg
menu color timeout 0 #ffffffff #00000000 none
menu color timeout_msg 0 #ffffffff #00000000 none

# Command prompt text
menu color cmdmark 0 #84b8ffff #00000000 none
menu color cmdline 0 #ffffffff #00000000 none

# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.

menu tabmsg Press Tab for full configuration options on menu items.

menu separator # insert an empty line
menu separator # insert an empty line

label linux
  menu label ^Install Red Hat Enterprise Linux 7.9 hahahahahahaha  #为了检验,我们在这里自定义一下,随便写,我这里加了hahahhahah
  kernel vmlinuz
  menu default   #这里表示在在安装页面时的默认选项,我们将其改到开始安装这个选项这里
  append initrd=initrd.img repo=http://172.25.254.131/rhel7 ks=http://172.25.254.131/ks.cfg quiet     #这里的文件不能乱写了,IP地址为共享文件的主机,为了确保路径可以使用,可以自己提前在浏览器上访问一下,确保自己可以访问到

label check
  menu label Test this ^media & install Red Hat Enterprise Linux 7.9
  kernel vmlinuz
  #menu default   #将默认的删除或者注释掉
  append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.9\x20Server.x86_64 rd.live.check quiet

menu separator # insert an empty line

# utilities submenu
menu begin ^Troubleshooting
  menu title Troubleshooting

label vesa
  menu indent count 5
  menu label Install Red Hat Enterprise Linux 7.9 in ^basic graphics mode
  text help
	Try this option out if you're having trouble installing
	Red Hat Enterprise Linux 7.9.
  endtext
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.9\x20Server.x86_64 xdriver=vesa nomodeset quiet

label rescue
  menu indent count 5
  menu label ^Rescue a Red Hat Enterprise Linux system
  text help
	If the system will not boot, this lets you access files
	and edit config files to try to get it booting again.
  endtext
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.9\x20Server.x86_64 rescue quiet

label memtest
  menu label Run a ^memory test
  text help
	If your system is having issues, a problem with your
	system's memory may be the cause. Use this utility to
	see if the memory is working correctly.
  endtext
  kernel memtest

menu separator # insert an empty line

label local
  menu label Boot from ^local drive
  localboot 0xffff

menu separator # insert an empty line
menu separator # insert an empty line

label returntomain
  menu label Return to ^main menu
  menu exit

menu end
7.测试

在新建的红帽7虚拟机启动时,选择打开电源时进入固件

选择如下: 

boot选择Network boot from Intel E1000 ,通过网络引导启动的方式;'+'号向上移动,‘-’号向下移动

 

回车后选择yes 

可以看见安装页面就是我们定义的页面了,默认选择第一个,等待三秒

 3秒之后就会自动安装,只需等待就可以了

安装完成后记得关机再选择打开电源时进入固件,将启动方式更改成默认的方式:Hard Drive 即硬盘启动方式。不然会进入无限快乐模式,一直安装不停。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值