日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

pxe linux自动安装系统,通过 PXE 自动安装操作系统(1):部署 PXE Server

發布時間:2025/3/19 linux 52 豆豆
生活随笔 收集整理的這篇文章主要介紹了 pxe linux自动安装系统,通过 PXE 自动安装操作系统(1):部署 PXE Server 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

PXE(Preboot eXecution Environment) 支持客戶端通過網絡從服務器端下載系統鏡像,并進行安裝。在安裝過程中,可以通過 Kickstart 配置文件實現無人值守安裝,并定制操作系統。

PXE 服務器組件:

DHCP : 負責分配網絡 IP 地址,并通過 DHCP 包來指定系統啟動文件的。

syslinux: 預啟動程序

TFTP: PXE 客戶端通過 TFTP 獲取啟動文件。

FTP: PXE 客戶端通過 FTP 下載系統鏡像內容。

初始化服務器

為 PXE Server 配置固定 IP 地址;

[it@pxesvr?~]$?sudo?vim?/etc/sysconfig/network-scripts/ifcfg-ens192

[sudo]?password?for?it:

[it@pxesvr?~]$?cat?/etc/sysconfig/network-scripts/ifcfg-ens192

TYPE=Ethernet

PROXY_METHOD=none

BROWSER_ONLY=no

BOOTPROTO=static

DEFROUTE=yes

IPV4_FAILURE_FATAL=no

IPV6INIT=yes

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_FAILURE_FATAL=no

IPV6_ADDR_GEN_MODE=stable-privacy

NAME=ens192

UUID=6346f97a-42c5-4fff-ad62-93bdfd90f417

DEVICE=ens192

ONBOOT=yes

IPADDR=10.10.10.53

PREFIX=24

GATEWAY=10.10.10.1

DNS1=10.10.10.1

IPV6_PRIVACY=no

關閉防火墻;[it@pxesvr?~]$?sudo?systemctl?stop?firewalld.service

[it@pxesvr?~]$?sudo?systemctl?disable?firewalld.service

Removed?/etc/systemd/system/multi-user.target.wants/firewalld.service.

Removed?/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

DHCP

安裝 DHCP 服務器角色;

[it@pxesvr?~]$?sudo?yum?install?dhcp-server?-y

Updating?Subscription?Management?repositories.

Unable?to?read?consumer?identity

This?system?is?not?registered?to?Red?Hat?Subscription?Management.?You?can?use?subscription-manager?to?register.

Last?metadata?expiration?check:?0:12:17?ago?on?Sat?10?Oct?2020?04:06:12?PM?CST.

Dependencies?resolved.

================================================================================================================

Package????????????????????Arch??????????????????Version????????????????????????Repository????????????????Size

================================================================================================================

Installing:

dhcp-server????????????????x86_64????????????????12:4.3.6-30.el8????????????????localREPO????????????????529?k

Transaction?Summary

================================================================================================================

Install??1?Package

...?...?...?...

...?...?...?...

...?...?...?...

配置 DHCP;[it@pxesvr?~]$?sudo?vim?/etc/dhcp/dhcpd.conf

[it@pxesvr?~]$?sudo?cat?/etc/dhcp/dhcpd.conf?|?grep?-v?^#

allow?bootp;

allow?booting;

default-lease-time?600;

max-lease-time?7200;

option?space?pxelinux;

option?pxelinux.magic?code?208?=?string;

option?pxelinux.configfile?code?209?=?text;

option?pxelinux.pathprefix?code?210?=?text;

option?pxelinux.reboottime?code?211?=?unsigned?integer?32;

option?architecture-type?code?93?=?unsigned?integer?16;

subnet?10.10.10.0?netmask?255.255.255.0?{

option?routers?10.10.10.1;

range?10.10.10.100?10.10.10.199;

class?'pxeclients'?{

match?if?substring?(option?vendor-class-identifier,?0,?9)?=?'PXEClient';

next-server?10.10.10.53;?????????#pxe?server?IP

if?option?architecture-type?=?00:07?{

filename?'uefi/BOOTX64.EFI';?????#?UEFI?boot

}?else?{

filename?'/pxelinux.0';??????????#?BIOS?boot

}

}

}

啟動 DHCP 服務,并配置開機啟動;

[it@pxesvr?~]$?sudo?systemctl?enable?--now?dhcpd.service

Created?symlink?/etc/systemd/system/multi-user.target.wants/dhcpd.service?→?/usr/lib/systemd/system/dhcpd.service.

syslinux

安裝 syslinux-tftpboot;[it@pxesvr?~]$?sudo?yum?install?syslinux-tftpboot?-y

Updating?Subscription?Management?repositories.

Unable?to?read?consumer?identity

This?system?is?not?registered?to?Red?Hat?Subscription?Management.?You?can?use?subscription-manager?to?register.

Last?metadata?expiration?check:?1:46:30?ago?on?Mon?12?Oct?2020?11:18:21?AM?CST.

Dependencies?resolved.

================================================================================================================

Package?????????????????????????Arch?????????????????Version?????????????????????Repository???????????????Size

================================================================================================================

Installing:

syslinux-tftpboot???????????????noarch???????????????6.04-1.el8??????????????????localREPO???????????????462?k

Installing?dependencies:

syslinux????????????????????????x86_64???????????????6.04-1.el8??????????????????localREPO???????????????576?k

syslinux-nonlinux???????????????noarch???????????????6.04-1.el8??????????????????localREPO???????????????554?k

Transaction?Summary

================================================================================================================

Install??3?Packages

...?...?...?...

...?...?...?...

...?...?...?...

配置啟動菜單(只有兩個菜單,一個 Install Red Hat Enterprise Linux 8.0,一個是 Boot from local drive(默認選擇)),并在第一個菜單配置啟動系統鏡像所需的文件,以及下載系統鏡像的目錄;

[it@pxesvr?~]$?sudo?mkdir?/tftpboot/pxelinux.cfg

[it@pxesvr?~]$?sudo?cp?/os/isolinux/isolinux.cfg?/tftpboot/pxelinux.cfg/default

[it@pxesvr?~]$?sudo?vim?/tftpboot/pxelinux.cfg/default

[it@pxesvr?~]$?sudo?cat?/tftpboot/pxelinux.cfg/default

default?vesamenu.c32

timeout?600

display?boot.msg

menu?title?Red?Hat?Enterprise?Linux?8.0

#?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?8.0

kernel?vmlinuz

append?initrd=initrd.img?inst.stage2=ftp://10.10.10.53/dvd?quiet

label?local

menu?label?^Boot?from?local?drive

menu?default

localboot?0xffff

[it@pxesvr?~]$

* ?啟動菜單文件 default 你可以通過示例文件修改獲得,也可以自己新建獲得。

復制系統鏡像啟動文件到對應的位置[it@pxesvr?~]$?sudo?cp?/os/isolinux/{boot.msg,vesamenu.c32}?/tftpboot/

[it@pxesvr?~]$?sudo?cp?/os/images/pxeboot/{vmlinuz,initrd.img}?/tftpboot/

TFTP

安裝 TFTP 服務器角色(pxe 客戶端通過 TFTP 獲取啟動文件);

[it@pxesvr?~]$?sudo?yum?install?tftp-server?-y

Updating?Subscription?Management?repositories.

Unable?to?read?consumer?identity

This?system?is?not?registered?to?Red?Hat?Subscription?Management.?You?can?use?subscription-manager?to?register.

Last?metadata?expiration?check:?0:45:23?ago?on?Mon?12?Oct?2020?08:05:39?AM?CST.

Dependencies?resolved.

================================================================================================================

Package????????????????????Arch??????????????????Version????????????????????Repository????????????????????Size

================================================================================================================

Installing:

tftp-server????????????????x86_64????????????????5.2-24.el8?????????????????localREPO_APP?????????????????50?k

Transaction?Summary

================================================================================================================

Install??1?Package

...?...?...?...

...?...?...?...

...?...?...?...

配置 TFTP 服務器(修改 TFTP 的路徑為 /tftpboot);[it@pxesvr?~]$?sudo?vim?/usr/lib/systemd/system/tftp.service

[it@pxesvr?~]$?sudo?cat?/usr/lib/systemd/system/tftp.service

[Unit]

Description=Tftp?Server

Requires=tftp.socket

Documentation=man:in.tftpd

[Service]

ExecStart=/usr/sbin/in.tftpd?-s?/tftpboot

StandardInput=socket

[Install]

Also=tftp.socket

啟動 TFTP 服務,并配置開機啟動;

[it@pxesvr?~]$?sudo?systemctl?enable?--now?tftp

Created?symlink?/etc/systemd/system/sockets.target.wants/tftp.socket?→?/usr/lib/systemd/system/tftp.socket.

FTP

安裝 FTP 服務器(用于 pxe client 下載系統鏡像文件);[it@pxesvr?~]$?sudo?yum?install?vsftpd?-y

Updating?Subscription?Management?repositories.

Unable?to?read?consumer?identity

This?system?is?not?registered?to?Red?Hat?Subscription?Management.?You?can?use?subscription-manager?to?register.

Last?metadata?expiration?check:?0:01:41?ago?on?Sat?10?Oct?2020?04:06:12?PM?CST.

Dependencies?resolved.

================================================================================================================

Package????????????????Arch???????????????????Version??????????????????????Repository?????????????????????Size

================================================================================================================

Installing:

vsftpd?????????????????x86_64?????????????????3.0.3-28.el8?????????????????localREPO_APP?????????????????180?k

Transaction?Summary

================================================================================================================

Install??1?Package

...?...?...?...

...?...?...?...

配置 ftp 服務器,開啟匿名訪問,指定匿名訪問的目錄;

[it@pxesvr?~]$?sudo?vim?/etc/vsftpd/vsftpd.conf

[sudo]?password?for?it:

[it@pxesvr?~]$?sudo?grep?-e?anonymous?-e?anon_root?/etc/vsftpd/vsftpd.conf?|?grep?-v?^#

anonymous_enable=YES

anon_root=/var/ftp

啟動 ftp 服務,并配置開機啟動;[it@pxesvr?~]$?sudo?systemctl?enable?--now?vsftpd.service

Created?symlink?/etc/systemd/system/multi-user.target.wants/vsftpd.service?→?/usr/lib/systemd/system/vsftpd.service.

創建 ftp 匿名訪問的目錄目錄,然后復制系統鏡像內容到該目錄;

[it@pxesvr?~]$?sudo?mkdir?/var/ftp/dvd

[it@pxesvr?~]$?sudo?cp?-r?/run/media/it/RHEL-8-0-0-BaseOS-x86_64/*?/var/ftp/dvd/

測試啟動

通過 BIOS(Legacy ) 的方式啟動客戶端主機進行測試

配置支持 UEFI 啟動

配置 UEFI 啟動菜單[it@pxesvr?~]$?sudo?mkdir?/tftpboot/uefi

[sudo]?password?for?it:

[it@pxesvr?~]$?sudo?cp?-r?/os/EFI/BOOT/*?/tftpboot/uefi/

[it@pxesvr?~]$?vim?/tftpboot/uefi/grub.cfg

[it@pxesvr?~]$?sudo?vim?/tftpboot/uefi/grub.cfg

[it@pxesvr?~]$?sudo?cat?/tftpboot/uefi/grub.cfg

[sudo]?password?for?it:

set?default='1'

function?load_video?{

insmod?efi_gop

insmod?efi_uga

insmod?video_bochs

insmod?video_cirrus

insmod?all_video

}

load_video

set?gfxpayload=keep

insmod?gzio

insmod?part_gpt

insmod?ext2

set?timeout=60

###?END?/etc/grub.d/00_header?###

search?--no-floppy?--set=root?-l?'RHEL-8-0-0-BaseOS-x86_64'

###?BEGIN?/etc/grub.d/10_linux?###

menuentry?'Install?Red?Hat?Enterprise?Linux?8.0'?--class?fedora?--class?gnu-linux?--class?gnu?--class?os?{

linuxefi?vmlinuz?inst.stage2=ftp://10.10.10.53/dvd?quiet

initrdefi?initrd.img

}

menuentry?'Test?this?media?&?install?Red?Hat?Enterprise?Linux?8.0'?--class?fedora?--class?gnu-linux?--class?gnu?--class?os?{

linuxefi?vmlinuz?inst.stage2=ftp://10.10.10.53/dvd?quiet

initrdefi?initrd.img

}

重啟服務

[it@pxesvr?~]$?sudo?systemctl?restart?dhcpd.service

[it@pxesvr?~]$?sudo?systemctl?restart?tftp.socket

測試啟動

通過 UEFI 的方式啟動客戶端主機進行測試。

總結

以上是生活随笔為你收集整理的pxe linux自动安装系统,通过 PXE 自动安装操作系统(1):部署 PXE Server的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。