max*_*zig 6 fedora pxe system-installation
如何使用 PXE 引导通过网络安装 Fedora?
动机:目标系统的 BIOS 根本无法从 USB 大容量存储设备启动。另一种动机是通过网络启动更方便。
挑战:LAN 已经有一个无法更改的 DHCP 服务器,即不支持配置 PXE 相关选项的服务器(它是 Fritz Box 路由器的一部分)。
也可以为PXE设置代理 DHCP服务。因此,不需要更改现有的 DHCP 服务器。然后可以使用普通的 Linux 系统(例如工作站)来托管预引导执行环境 (PXE)。
设置 PXE 以通过网络引导Fedora 网络安装映像(假设也是 Fedora 主机)需要执行以下步骤:
$ gpg --verify Fedora-Server-21-x86_64-CHECKSUM
$ sha256sum --check Fedora-Server-21-x86_64-CHECKSUM
Fedora-Server-netinst-x86_64-21.iso: OK
Run Code Online (Sandbox Code Playgroud)
mkdir /mnt/iso
mount -o loop Fedora-Server-netinst-x86_64-21.iso /mnt/iso
Run Code Online (Sandbox Code Playgroud)
yum install dnsmasq tftp-server syslinux-tftpboot
Run Code Online (Sandbox Code Playgroud)
该tftp-server包仅用于创建目录/var/lib/tftpboot,dnsmasq 已经集成了一个 tftp 服务器。
配置:
cat > /etc/dnsmasq.conf
interface=enp0s25
# and don't bind to 0.0.0.0
bind-interfaces
# extra logging
log-dhcp
dhcp-range=192.168.178.0,proxy
# first IP address is the one of the host
dhcp-boot=pxelinux.0,192.168.178.34,192.168.178.0
pxe-service=x86PC,"Automatic Network Boot",pxelinux
# Specify the IP address of another tftp server
enable-tftp
# default location of tftp-server on Fedora
tftp-root=/var/lib/tftpboot
# disable DNS
port=0
Run Code Online (Sandbox Code Playgroud)
启动它:
systemctl start dnsmasq.service
Run Code Online (Sandbox Code Playgroud)
复制所有需要的文件:
cp /mnt/iso/images/pxeboot/initrd.img /var/lib/tftpboot
cp /mnt/iso/images/pxeboot/vmlinuz /var/lib/tftpboot
cp /tftpboot/pxelinux.0 /var/lib/tftpboot
cp /tftpboot/vesamenu.c32 /var/lib/tftpboot
cp /tftpboot/ldlinux.c32 /var/lib/tftpboot
cp /tftpboot/libcom32.c32 /var/lib/tftpboot
cp /tftpboot/libutil.c32 /var/lib/tftpboot
Run Code Online (Sandbox Code Playgroud)
添加配置:
mkdir /var/lib/tftpboot/pxelinux.cfg
cat > /var/lib/tftpboot/pxelinux.cfg/default
default vesamenu.c32
prompt 0
# disable timeout
timeout 0
#timeout 600
# if file is missing, this is ignored
display boot.msg
label linux
menu label Install Fedora 21 Server x86-64
kernel vmlinuz
append initrd=initrd.img inst.stage2=http://workstation.example.org/
Run Code Online (Sandbox Code Playgroud)
yum install nginx
Run Code Online (Sandbox Code Playgroud)
配置实例:
cat > /etc/nginx/conf.d/iso.conf
server {
listen 80 default_server;
server_name localhost;
root /mnt/iso ;
include /etc/nginx/default.d/*.conf;
}
Run Code Online (Sandbox Code Playgroud)
禁用默认实例/将其移动到不同的端口:
--- a/nginx/nginx.conf
+++ b/nginx/nginx.conf
@@ -43,7 +43,7 @@ http {
include /etc/nginx/conf.d/*.conf;
server {
- listen 80 default_server;
+ listen 8080 default_server;
server_name localhost;
root /usr/share/nginx/html;
Run Code Online (Sandbox Code Playgroud)
启动服务器:
systemctl start nginx.service
Run Code Online (Sandbox Code Playgroud)
Fedora 安装程序 (dracut) 基本上只需要从该 http 服务器获取一个文件:
LiveOS/squashfs.img
Run Code Online (Sandbox Code Playgroud)
firewall-cmd --add-service=http
firewall-cmd --add-service=dhcp
firewall-cmd --add-service=tftp
firewall-cmd --add-service=http --permanent
firewall-cmd --add-service=dhcp --permanent
firewall-cmd --add-service=tftp --permanent
Run Code Online (Sandbox Code Playgroud)
就是这样。客户知道能够通过 PXE 进行网络引导并获得 Fedora 网络安装映像。
变化可能是:为全自动网络安装添加 kickstart 文件(并设置超时)、为不同客户端配置不同的 PXE 设置(基于 MAC 地址)等。
可以停止守护进程并卸载回送映像:
systemctl stop nginx.service
systemctl stop dnsmasq.service
umount /mnt/iso
Run Code Online (Sandbox Code Playgroud)
此方法只能在可信任的 Intranet 中执行,因为 netboot 客户端通过 TFTP 和 HTTP 获取其配置和几个绝对不安全的图像。
| 归档时间: |
|
| 查看次数: |
6974 次 |
| 最近记录: |