PXE_Installation_Guide

使用 PXE 网络引导安装 Ubuntu 系统(详细教程)

🧰 一、准备工作

项目说明
PXE 服务器已安装 Ubuntu 的主机(建议 Ubuntu 20.04 或 22.04)
目标机器准备安装系统的空白主机
网络两台设备需处于同一局域网中
Ubuntu ISO 镜像下载地址:https://ubuntu.com/download/server

📦 二、安装并配置 PXE 环境(在 Ubuntu 上操作)

1️⃣ 安装所需软件

sudo apt update
sudo apt install -y dnsmasq apache2 syslinux pxelinux

2️⃣ 准备 TFTP 服务(存储引导文件)

sudo mkdir -p /srv/tftp/pxelinux.cfg
sudo cp /usr/lib/PXELINUX/pxelinux.0 /srv/tftp/
sudo cp /usr/lib/syslinux/modules/bios/* /srv/tftp/

3️⃣ 挂载 Ubuntu ISO 镜像

cd ~
mkdir -p /mnt/iso
sudo mount -o loop ~/Downloads/ubuntu-22.04-live-server-amd64.iso /mnt/iso

4️⃣ 复制 netboot 文件

sudo mkdir -p /srv/tftp/ubuntu-installer
sudo cp -r /mnt/iso/install/netboot/* /srv/tftp/ubuntu-installer/

5️⃣ 创建 PXE 引导菜单

sudo nano /srv/tftp/pxelinux.cfg/default

粘贴以下内容:

DEFAULT install
LABEL install
    KERNEL ubuntu-installer/amd64/linux
    APPEND vga=normal initrd=ubuntu-installer/amd64/initrd.gz --- quiet

6️⃣ 配置 dnsmasq(DHCP + TFTP)

找到你的网卡名称(用 ip a,如 enp0s3),然后:

sudo nano /etc/dnsmasq.d/pxe.conf

内容如下(替换网卡名称):

interface=enp0s3
dhcp-range=192.168.1.100,192.168.1.200,12h
dhcp-boot=pxelinux.0
enable-tftp
tftp-root=/srv/tftp
pxe-service=x86PC, "Install Ubuntu", pxelinux

7️⃣ 搭建 HTTP 服务提供安装文件

sudo mkdir -p /var/www/html/ubuntu
sudo cp -r /mnt/iso/* /var/www/html/ubuntu/
sudo systemctl restart apache2

8️⃣ 启动 dnsmasq 服务

sudo systemctl restart dnsmasq
sudo systemctl enable dnsmasq

🖥️ 三、目标机器设置 PXE 启动

  1. 启动前按 Del / F2 / F12 进入 BIOS 设置;
  2. 启用 PXE Boot 或设置启动顺序为 Network Boot;
  3. 启动后,目标机会自动从网络加载引导程序;
  4. 然后你会看到 Ubuntu 安装界面,进入正常安装流程。

✅ 安装成功后

目标机器就能像正常那样完成 Ubuntu 安装,和光盘或 U 盘一样,只不过它是从网络获取安装内容。

PXE网络安装配置指南

步骤一:准备 PXE 服务器

1. 安装必要的软件

在 PXE 服务器上安装所需的软件包:

sudo apt update
sudo apt install dnsmasq tftpd-hpa syslinux pxelinux apache2

2. 配置 DHCP 和 TFTP 服务

编辑 dnsmasq.conf 配置文件,设置 DHCP 和 TFTP 服务:

sudo nano /etc/dnsmasq.conf

添加以下内容:

interface=eth0
dhcp-range=192.168.1.100,192.168.1.150,12h
dhcp-boot=pxelinux.0
enable-tftp
tftp-root=/srv/tftp

3. 创建 TFTP 目录

创建 TFTP 根目录,并设置 PXE 引导文件:

sudo mkdir -p /srv/tftp/pxelinux.cfg

步骤二:获取网络安装镜像

1. 使用 netboot 镜像进行安装

Ubuntu 提供了网络安装镜像(Netboot)。这是一种精简的镜像,不包含完整的操作系统,它会在安装时从网络上下载需要的文件。

你可以下载网络安装镜像,并将它作为源来提供安装:

选择合适的版本并下载 netboot.tar.gz 文件。

2. 下载并解压网络安装镜像

将镜像文件下载到服务器上并解压:

wget http://archive.ubuntu.com/ubuntu/dists/focal/main/installer-amd64/current/images/netboot/netboot.tar.gz
tar -xvzf netboot.tar.gz -C /srv/tftp/

解压后,/srv/tftp 目录下会出现相关的引导文件。

步骤三:配置 PXE 引导菜单

/srv/tftp/pxelinux.cfg/ 目录下创建一个默认的引导配置文件:

sudo nano /srv/tftp/pxelinux.cfg/default

添加以下内容:

DEFAULT install
LABEL install
  KERNEL ubuntu-installer/amd64/linux
  APPEND vga=788 initrd=ubuntu-installer/amd64/initrd.gz

这会告诉 PXE 客户端从网络启动并加载 Ubuntu 安装器。

步骤四:配置 Apache 提供安装源

如果你想从 HTTP 提供安装源,可以使用 Apache 来提供安装镜像:

  1. 将网络安装镜像放置在 /var/www/html/ubuntu/
sudo cp -r /srv/tftp/ubuntu-installer /var/www/html/ubuntu/
  1. 确保 Apache 服务正常运行:
sudo systemctl restart apache2

步骤五:客户端配置

  1. 在客户端机器的 BIOS 中启用 PXE 引导。
  2. 客户端机器启动时,应该会通过 PXE 引导从服务器加载 Ubuntu 安装器。
  3. 按照安装向导完成安装过程。

说明:

  • 网络安装(Netboot)是一个非常轻量的安装方式,适用于没有足够存储空间的设备,或者你没有完整 ISO 镜像时。
  • 客户端从 PXE 启动后,会连接到服务器并从网络上加载必要的文件进行操作系统安装。
### CentOS 8 Server Installation Guide To install a CentOS 8 server, follow this detailed step-by-step tutorial: #### Prerequisites Ensure that the system meets hardware requirements such as minimum RAM and disk space before proceeding with the installation process. #### Step 1: Boot from Installation Media Insert the CentOS 8 installation media into the target machine or configure PXE booting if applicable. Start the computer and enter BIOS/UEFI settings to set the boot order so it boots from the installation medium first[^1]. #### Step 2: Choose Language Settings Select preferred language options during initial setup screens which appear after successfully booting from the installation media. #### Step 3: Network & Hostname Configuration Configure network interfaces including setting up static IP addresses if required. Set hostname for identification purposes within networks. #### Step 4: Time Zone Selection Choose appropriate time zones according to geographical location where the server will operate. #### Step 5: Partitioning Disks Decide whether automatic partitioning is sufficient or manual configuration of partitions is necessary based on specific storage needs. #### Step 6: Software Selection Pick software packages needed for intended use cases; minimal installations are recommended unless additional features are explicitly desired. #### Step 7: Begin Installation Process After confirming all configurations, start the actual installation procedure by clicking "Begin Installation". This phase involves copying files onto disks along with configuring basic system parameters. #### Post-installation Setup Once installed, log in using credentials created earlier. It's advisable to create non-root users with `sudo` access following best practices outlined elsewhere[^2]. For database management systems like MariaDB, refer to dedicated guides covering their deployment post OS installation[^3]. ```bash ssh username@serveripaddress ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值