阅读(1446) (0)

19.2.3 配置SYSLinux服务程序

2019-05-16 10:52:32 更新

SYSLinux是一个用于提供引导加载的服务程序。与其说SYSLinux是一个服务程序,不如说更需要里面的引导文件,在安装好SYSLinux服务程序软件包后,/usr/share/syslinux目录中会出现很多引导文件。

    [root@linuxprobe ~]# yum install syslinux
    Loaded plugins: langpacks, product-id, subscription-manager
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Resolving Dependencies
    --> Running transaction check
    ---> Package syslinux.x86_64 0:4.05-8.el7 will be installed
    --> Finished Dependency Resolution
    Dependencies Resolved
    ================================================================================
     Package Arch Version Repository Size
    ================================================================================
    Installing:
     syslinux x86_64 4.05-8.el7 rhel 1.0 M
    Transaction Summary
    ================================================================================
    Install 1 Package
    Total download size: 1.0 M
    Installed size: 2.3 M
    Is this ok [y/d/N]: y
    Downloading packages:
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
     Installing : syslinux-4.05-8.el7.x86_64 1/1 
     Verifying : syslinux-4.05-8.el7.x86_64 1/1 
    Installed:
     syslinux.x86_64 0:4.05-8.el7 
    Complete!

我们首先需要把SYSLinux提供的引导文件复制到TFTP服务程序的默认目录中,也就是前文提到的文件pxelinux.0,这样客户端主机就能够顺利地获取到引导文件了。另外在RHEL 7系统光盘镜像中也有一些我们需要调取的引导文件。确认光盘镜像已经被挂载到/media/cdrom目录后,使用复制命令将光盘镜像中自带的一些引导文件也复制到TFTP服务程序的默认目录中。

    [root@linuxprobe ~]# cd /var/lib/tftpboot
    [root@linuxprobe tftpboot]# cp /usr/share/syslinux/pxelinux.0 .
    [root@linuxprobe tftpboot]# cp /media/cdrom/images/pxeboot/{vmlinuz,initrd.img} .
    [root@linuxprobe tftpboot]# cp /media/cdrom/isolinux/{vesamenu.c32,boot.msg} .

然后在TFTP服务程序的目录中新建pxelinux.cfg目录,虽然该目录的名字带有后缀,但依然也是目录,而非文件!将系统光盘中的开机选项菜单复制到该目录中,并命名为default。这个default文件就是开机时的选项菜单,如图19-4所示。

图19-4 Linux系统的引导菜单界面

    [root@linuxprobe tftpboot]# mkdir pxelinux.cfg
    [root@linuxprobe tftpboot]# cp  /media/cdrom/isolinux/isolinux.cfg pxelinux.cfg/default

默认的开机菜单中有两个选项,要么是安装系统,要么是对安装介质进行检验。既然我们已经确定采用无人值守的方式安装系统,还需要为每台主机手动选择相应的选项,未免与我们的主旨(无人值守安装)相悖。现在我们编辑这个default文件,把第1行的default参数修改为linux,这样系统在开机时就会默认执行那个名称为linux的选项了。对应的linux选项大约在64行,我们将默认的光盘镜像安装方式修改成FTP文件传输方式,并指定好光盘镜像的获取网址以及Kickstart应答文件的获取路径:

    [root@linuxprobe tftpboot]# vim pxelinux.cfg/default
     1 default linux
     2 timeout 600
     3
     4 display boot.msg
     5
     6 # Clear the screen when exiting the menu, instead of leaving the menu displa yed.
     7 # For vesamenu, this means the graphical background is still displayed witho ut
     8 # the menu itself for as long as the screen remains in graphics mode.
     9 menu clear
     10 menu background splash.png
     11 menu title Red Hat Enterprise Linux 7.0
     12 menu vshift 8
     13 menu rows 18
     14 menu margin 8
     15 #menu hidden
     16 menu helpmsgrow 15
     17 menu tabmsgrow 13
     18
     19 # Border Area
     20 menu color border * #00000000 #00000000 none
     21
     22 # Selected item
     23 menu color sel 0 #ffffffff #00000000 none
     24
     25 # Title bar
     26 menu color title 0 #ff7ba3d0 #00000000 none
     27
     28 # Press [Tab] message
     29 menu color tabmsg 0 #ff3a6496 #00000000 none
     30
     31 # Unselected menu item
     32 menu color unsel 0 #84b8ffff #00000000 none
     33
     34 # Selected hotkey
     35 menu color hotsel 0 #84b8ffff #00000000 none
     36
     37 # Unselected hotkey
     38 menu color hotkey 0 #ffffffff #00000000 none
     39
     40 # Help text
     41 menu color help 0 #ffffffff #00000000 none
     42 
     43 # A scrollbar of some type? Not sure.
     44 menu color scrollbar 0 #ffffffff #ff355594 none
     45 
     46 # Timeout msg
     47 menu color timeout 0 #ffffffff #00000000 none
     48 menu color timeout_msg 0 #ffffffff #00000000 none
     49 
     50 # Command prompt text
     51 menu color cmdmark 0 #84b8ffff #00000000 none
     52 menu color cmdline 0 #ffffffff #00000000 none
     53 
     54 # Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.
     55 
     56 menu tabmsg Press Tab for full configuration options on menu items.
     57 
     58 menu separator # insert an empty line
     59 menu separator # insert an empty line
     59 menu separator # insert an empty line
     60 
     61 label linux
     62 menu label ^Install Red Hat Enterprise Linux 7.0
     63 kernel vmlinuz
     64 append initrd=initrd.img inst.stage2=ftp://192.168.10.10 ks=ftp://192.168.10.10/pub/ks.cfg quiet
     65
    ………………省略部分输出信息………………