mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-29 21:41:00 +08:00
commit
973c62f551
@ -1,22 +1,22 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (qhwdw)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: ()
|
||||
[#]: publisher: ()
|
||||
[#]: url: ()
|
||||
[#]: subject: (How to Build a Netboot Server, Part 3)
|
||||
[#]: via: (https://fedoramagazine.org/how-to-build-a-netboot-server-part-3/)
|
||||
[#]: author: (Gregory Bartholomew https://fedoramagazine.org/author/glb/)
|
||||
|
||||
How to Build a Netboot Server, Part 3
|
||||
如何构建一台网络引导服务器(第三部分)
|
||||
======
|
||||
|
||||
![](https://fedoramagazine.org/wp-content/uploads/2018/12/netboot3-816x345.jpg)
|
||||
|
||||
The [How to Build a Netboot Server, Part 1][1] article provided a minimal [iPXE][2] boot script for your netboot image. Many users probably have a local operating system that they want to use in addition to the netboot image. But switching bootloaders using the typical workstation’s BIOS can be cumbersome. This part of the series shows how to set up some more complex iPXE configurations. These allow the end user to easily choose which operating system they want to boot. They also let the system administrator manage the boot menus from a central server.
|
||||
在 [如何构建一台网络引导服务器(第一部分)][1] 的文章中,我们提供了一个极简的 [iPXE][2] 引导脚本来引导你的网络引导镜像。许多用户除了使用网络引导镜像外,可能在机器本地也有一个操作系统。但是使用常见的工作站的 BIOS 去切换引导加载器是很笨拙的。在本系列文件的第三部分,我们将向你展示如何设置一个更复杂的 iPXE 配置。它将允许终端用户以更容易的方式去选择引导哪个操作系统。它也可以配置为让系统管理员从一台中央服务器来统一管理引导菜单。
|
||||
|
||||
### An interactive iPXE boot menu
|
||||
### 一个交互式 iPXE 引导菜单
|
||||
|
||||
The commands below redefine the netboot image’s boot.cfg as an interactive iPXE boot menu with a 5 second countdown timer:
|
||||
下面这些命令重定义了网络引导镜像的 boot.cfg 来作为一个交互式的 iPXE 引导菜单,并使用了一个 5 秒倒计时的定时器:
|
||||
|
||||
```
|
||||
$ MY_FVER=29
|
||||
@ -59,32 +59,33 @@ boot || goto failed
|
||||
END
|
||||
```
|
||||
|
||||
The above menu has five sections:
|
||||
上述菜单有五个节:
|
||||
|
||||
* **menu** defines the actual menu that will be shown on the screen.
|
||||
* **failed** notifies the user that something went wrong and drops the user to a shell so they can troubleshot the problem.
|
||||
* **shell** provides an interactive command prompt. You can reach it either by pressing the **Esc** key while at the boot menu or if the “boot” command returns with a failure code.
|
||||
* **lcl** contains a single command that tells iPXE to exit and return control back to the BIOS. Whatever you want to boot by default (e.g. the workstation’s local hard drive) **must** be listed as the next boot item right after iPXE in your workstation’s BIOS.
|
||||
* **f29** contains the same netboot code used earlier but with the final exit replaced with goto failed.
|
||||
* **menu** 定义了显示在屏幕上的实际菜单内容。
|
||||
* **failed** 提示用户发生了错误,并将用户带到 shell 以错误错误。
|
||||
* **shell** 提供了交互式命令提示符。你可以在引导菜单出现时按下 **Esc** 键进入,或者是
|
||||
“boot” 命令失败时也会进入到命令提示符。
|
||||
* **lcl** 包含一个提供给 iPXE 退出的简单命令,以及返还控制权给 BIOS。在 iPXE 之后,无论你希望缺省引导的设备(即:工作站的本地硬件)是什么,都必须在你的工作站的 BIOS 中正确地作为下一个引导设备列出来。
|
||||
* **f29** 包含前面文章提到同一个网络引导代码,但使用最终的退出代码来替换掉 goto failed。
|
||||
|
||||
|
||||
|
||||
Copy the updated boot.cfg from your $HOME/esp/linux directory out to the ESPs of all your client systems. If all goes well, you should see results similar to the image below:
|
||||
从你的 `$HOME/esp/linux` 目录中复制更新后的 boot.cfg 到所有客户端系统的 ESP 中。如果一切顺利,你应该会看到类似下面图片的结果:
|
||||
|
||||
![][3]
|
||||
|
||||
### A server hosted boot menu
|
||||
### 一个服务器托管的引导菜单
|
||||
|
||||
Another feature you can add to the netboot server is the ability to manage all the client boot menus from one central location. This feature can be especially useful when rolling out a new version of the OS. It lets you perform a sort of [atomic transaction][4] to switch all clients over to the new OS after you’ve copied the new kernel and initramfs out to the ESPs of all the clients.
|
||||
你可以添加到网络引导服务器的另一个特性是,能够从一台中央位置去管理所有客户端的引导菜单。这个特性尤其适用于批量安装(升级)一个新版本的操作系统。在你将新内核和新的 initramfs 复制到所有客户端的 ESP 之后,这个特性可以让你执行一种 [原子事务][4] 去切换所有客户端到新操作系统。
|
||||
|
||||
Install Mojolicious:
|
||||
安装 Mojolicious:
|
||||
|
||||
```
|
||||
$ sudo -i
|
||||
# dnf install -y perl-Mojolicious
|
||||
```
|
||||
|
||||
Define the “bootmenu” app:
|
||||
定义 “bootmenu” 应用程序:
|
||||
|
||||
```
|
||||
# mkdir /opt/bootmenu
|
||||
@ -102,7 +103,7 @@ END
|
||||
# chmod 755 /opt/bootmenu/bootmenu.pl
|
||||
```
|
||||
|
||||
Define the configuration file for the bootmenu app:
|
||||
为 “bootmenu” 应用程序定义配置文件:
|
||||
|
||||
```
|
||||
# cat << END > /opt/bootmenu/bootmenu.conf
|
||||
@ -115,16 +116,16 @@ Define the configuration file for the bootmenu app:
|
||||
END
|
||||
```
|
||||
|
||||
This is an extremely simple Mojolicious application that listens on port 80 and only answers to /menu requests. If you want a quick introduction to what Mojolicious can do, run man Mojolicious::Guides::Growing to view the manual. Use the **Q** key to quit the manual.
|
||||
这是一个非常简单的 Mojolicious 应用程序,它监听 80 端口,并且只回复到 /menu 的请求。如果你想快速了解 Mojolicious 能做什么,运行 `man Mojolicious::Guides::Growing` 去查看手册。按 **Q** 键退出手册。
|
||||
|
||||
Move boot.cfg over to our netboot app as a template named menu.html.ep:
|
||||
将 boot.cfg 移到我们的网络引导应用程序中作为一个名为 menu.html.ep 的模板:
|
||||
|
||||
```
|
||||
# mkdir /opt/bootmenu/templates
|
||||
# mv $HOME/esp/linux/boot.cfg /opt/bootmenu/templates/menu.html.ep
|
||||
```
|
||||
|
||||
Define a systemd service to manage the bootmenu app:
|
||||
定义一个 systemd 服务去管理引导菜单应用程序:
|
||||
|
||||
```
|
||||
# cat << END > /etc/systemd/system/bootmenu.service
|
||||
@ -147,7 +148,7 @@ WantedBy=multi-user.target
|
||||
END
|
||||
```
|
||||
|
||||
Add an exception for the HTTP service to the local firewall and start the bootmenu service:
|
||||
在本地防火墙中为 HTTP 服务添加一个例外规则,并启动 bootmenu 服务:
|
||||
|
||||
```
|
||||
# firewall-cmd --add-service http
|
||||
@ -156,7 +157,7 @@ Add an exception for the HTTP service to the local firewall and start the bootme
|
||||
# systemctl start bootmenu.service
|
||||
```
|
||||
|
||||
Test it with wget:
|
||||
用 wget 测试它:
|
||||
|
||||
```
|
||||
$ sudo dnf install -y wget
|
||||
@ -164,7 +165,7 @@ $ MY_BOOTMENU_SERVER=server-01.example.edu
|
||||
$ wget -q -O - http://$MY_BOOTMENU_SERVER/menu
|
||||
```
|
||||
|
||||
The above command should output something similar to the following:
|
||||
以上的命令应该会输出类似下面的内容:
|
||||
|
||||
```
|
||||
#!ipxe
|
||||
@ -198,9 +199,9 @@ initrd --name initrd.img ${prefix}/initramfs-4.19.4-300.fc29.x86_64.img
|
||||
boot || goto failed
|
||||
```
|
||||
|
||||
Now that the boot menu server is working, rebuild the ipxe.efi bootloader with an init script that points to it.
|
||||
现在,引导菜单服务器已经正常工作了,重新构建 ipxe.efi 引导加载器,使用一个 init 脚本指向它。
|
||||
|
||||
First, update the init.ipxe script created in part one of this series:
|
||||
第一步,先更新我们在本系列文章的第一部分中创建的 init.ipxe 脚本:
|
||||
|
||||
```
|
||||
$ MY_BOOTMENU_SERVER=server-01.example.edu
|
||||
@ -213,7 +214,7 @@ chain http://$MY_BOOTMENU_SERVER/menu || exit
|
||||
END
|
||||
```
|
||||
|
||||
Now, rebuild the boot loader:
|
||||
现在,重新构建引导加载器:
|
||||
|
||||
```
|
||||
$ cd $HOME/ipxe/src
|
||||
@ -221,23 +222,23 @@ $ make clean
|
||||
$ make bin-x86_64-efi/ipxe.efi EMBED=../init.ipxe
|
||||
```
|
||||
|
||||
Copy the updated bootloader to your ESP:
|
||||
将更新后的引导加载器复制到你的 ESP 中:
|
||||
|
||||
```
|
||||
$ cp $HOME/ipxe/src/bin-x86_64-efi/ipxe.efi $HOME/esp/efi/boot/bootx64.efi
|
||||
```
|
||||
|
||||
After you’ve copied the updated bootloader to all your clients, you can make future updates to the boot menu simply by editing /opt/bootmenu/templates/menu.html.ep and running:
|
||||
将更新后的引导加载器复制到所有的客户端中之后,以后更新引导菜单只需要简单地编辑 `/opt/bootmenu/templates/menu.html.ep` 文件,然后再运行如下命令:
|
||||
|
||||
```
|
||||
$ sudo systemctl restart bootmenu.service
|
||||
```
|
||||
|
||||
### Making further changes
|
||||
### 做一步的改变
|
||||
|
||||
If the boot menu server is working properly, you’ll longer need the the boot.cfg file on your client systems.
|
||||
如果引导菜单服务器工作正常,在你的客户端系统上的 boot.cfg 文件将更长。
|
||||
|
||||
For example, re-add the Fedora 28 image to the boot menu:
|
||||
比如,重新添加 Fedora 28 镜像到引导菜单中:
|
||||
|
||||
```
|
||||
$ sudo -i
|
||||
@ -259,18 +260,17 @@ END
|
||||
# systemctl restart bootmenu.service
|
||||
```
|
||||
|
||||
If all goes well, your clients should see results similar to the image below the next time they boot:
|
||||
如果一切顺利,你的客户端下次引导时,应该看到如下图所示的结果:
|
||||
|
||||
![][5]
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/how-to-build-a-netboot-server-part-3/
|
||||
|
||||
作者:[Gregory Bartholomew][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[qhwdw](https://github.com/qhwdw)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user