debian 12 PXE Server 批量部署系統

pxe server 前言

PXE(Preboot eXecution Environment,預啟動執行環境)是一種網絡啟動協議,允許計算機通過網絡啟動而不是使用本地硬盤。PXE服務器是實現這一功能的服務器,它提供了啟動鏡像和引導加載程序,使得客戶端計算機可以通過網絡啟動并安裝操作系統或運行其他軟件。

在Debian系統中,要設置一個PXE服務器,您需要以下幾個組件:

  • TFTP服務器:用于提供啟動鏡像和引導加載程序。
  • DHCP服務器:用于分配IP地址給客戶端計算機。
  • NFS或HTTP服務器:用于提供操作系統鏡像和其他文件。

在Debian中,可以使用以下軟件包來設置PXE服務器:

  • atftpd:一個輕量級的TFTP服務器,可以用于提供啟動鏡像和引導加載程序。
  • dnsmasq:一個輕量級的DHCP和DNS服務器,可以用于分配IP地址給客戶端計算機。
  • nfs-kernel-server:用于提供NFS服務,以便客戶端可以訪問操作系統鏡像和其他文件。

debian 相關下載,文檔參考

  • debian 基礎系統部署,源參考
debiandebian 歷史版debian 發行版debian 安裝debian preseed.cfg自動化編排debian dhcp 配置netboot 下載

Debian 全球鏡像站

downloaddownload參考參考參考參考downloaddownload

創建一鍵安裝tftp dhcp 實現批量部署debian

  • 實現自動化安裝debian,lvm 分區,xfs?
  • debian 自動化部署需要連接互聯網,原因需要你建立一個 Debian 內網倉庫的鏡像,耗時較長,文件較大,根據自身情況進行選擇,參考
  • dhcp 配置文件位置/etc/dhcp/dhcpd.conf
  • tftp 配置文件/etc/default/tftpd-hpa
  • tftp 文件位置/srv/tftp/
  • netboot 位置/srv/tftp/debian-installer
  • 使用crypt(3)哈希進行加密(apt install -y whois) (mkpasswd -m sha-512 生成密鑰)
  • 基于bios 啟動配置文件/srv/tftp/debian-installer/amd64/pxelinux.cfg/default
  • debian 自動化編排腳本位置/srv/tftp/preseed/debian-12-preseed.cfg
  • 執行以下腳本執行前 ln -sf bash /bin/sh
  • root/1234.com 以下自動化安裝完成的用戶密碼
  • 18-35行變量,根據自己的實際情況進行變更
  • 目前實現bios,uefi目前沒有實現,后續實現后更新
vim /pxe_server_install.sh
#!/bin/bash
# -*- coding: utf-8 -*-
# Author: make.han 
# Email: CIASM@CIASM
# Date: 2024/07/12
# install PXE Server debian 12# preseed.cfg 編排
#https://www.debian.org/releases/stable/amd64/apbs04.zh-cn.html#ftn.idm3455# TFTP 網絡引導準備文件
#https://www.debian.org/releases/stable/amd64/ch04s05.zh-cn.html# 安裝手冊
#https://www.debian.org/releases/stable#dhcp ip address
nic_network_name=`ifconfig -s | awk 'NR>1 && !/^lo/ && !/^idrac/ && !/^br/ && !/^veth/ && !/^docker/{print $1; exit}'`
host_IP=`ifconfig -a | grep inet | grep -v '127.0.0.1' | awk '{ print $2}' | awk 'NR==1'`
IP="192.168.11.69"
MASK="255.255.255.0"
BROADCAST_ADDRESS="192.168.11.255"
ROUTERS="192.168.11.1"
SUBNET="192.168.11.0"
DNS="8.8.8.8"
RANGE="192.168.11.56 192.168.11.250"# root用戶,普通用戶 密碼使用crypt(3)哈希進行加密(apt install -y whois) (mkpasswd -m sha-512 生成密鑰)
root_password='$6$5vShu8v/wRoByWOr$0uGqOl9W40u.hXXZwLBrP6jGFubcw.UM3JE13eOkdm7RsfcnseVsCe1YBR6VawPtFH4rNROi2sJ35X98dNO.C/'
host_name=debian
common_user=debian
common_password='$6$5vShu8v/wRoByWOr$0uGqOl9W40u.hXXZwLBrP6jGFubcw.UM3JE13eOkdm7RsfcnseVsCe1YBR6VawPtFH4rNROi2sJ35X98dNO.C/'
time_zone="Asia/Shanghai"
mirror="ftp.cn.debian.org"
tftp_port=69install_pxe_server (){if ! [ -x "$(command -v dhcpd)" ]; thenif [ $? -eq 0 ];thenecho "install firewalld"
apt install -y firewalld curl
firewall-cmd --zone=public --add-port=$tftp_port/tcp --permanent && firewall-cmd --reload
firewall-cmd --zone=public --add-port=$tftp_port/udp --permanent && firewall-cmd --reloadecho "install whois mkpasswd"
apt install -y whoisecho "install dhcp"
apt install -y isc-dhcp-serverecho "isc-dhcp-server add nic"
sed -i "s/^INTERFACESv4=.*$/INTERFACESv4=\"$nic_network_name\"/" /etc/default/isc-dhcp-serverecho "configuration dhcpd.conf"
rm -rf /etc/dhcp/dhcpd.conf
cat <<EOF>>/etc/dhcp/dhcpd.conf
option domain-name         "$DNS";
option domain-name-servers  $DNS;
default-lease-time 2592000;
max-lease-time 2592000;
authoritative;# add follows
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 $SUBNET  netmask $MASK {range dynamic-bootp $RANGE;option broadcast-address $BROADCAST_ADDRESS;option routers $ROUTERS;#add followsclass "pxeclients" {match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";# PXE servers hostname or IP addressnext-server $IP;if option architecture-type = 00:07 {filename "debian-installer/amd64/bootnetx64.efi";}else {filename "pxelinux.0";}}
}
EOFecho "install tftpd-hpa"
apt install -y tftpd-hpaecho "configuration tftpd-hpa"
echo > /etc/default/tftpd-hpa
cat <<EOF>>/etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftp/"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="-l -c -s"
EOFecho "start tftpd-hpa"
systemctl enable tftpd-hpa
systemctl start tftpd-hpaecho "downlaod netboot"
curl -o /srv/tftp/netboot.tar.gz http://mirrors.ustc.edu.cn/debian/dists/bookworm/main/installer-amd64/current/images/netboot/netboot.tar.gz
tar -xf /srv/tftp/netboot.tar.gz -C /srv/tftpecho "configuration default"
rm -rf /srv/tftp/debian-installer/amd64/pxelinux.cfg/default
cat <<EOF | tee /srv/tftp/debian-installer/amd64/pxelinux.cfg/default
path debian-installer/amd64/boot-screens
default debian-installer/amd64/boot-screens/vesamenu.c32#自定義圖片路徑位置
#menu background /debian.pngmenu hshift 13
menu width 49
menu margin 8
menu tabmsg
timeout 100menu title Installer boot menu
label Auto Install Debian 12menu label ^Auto Install Debian 12menu defaultkernel debian-installer/amd64/linuxappend auto=true priority=critical vga=788 initrd=debian-installer/amd64/initrd.gz preseed/url=tftp://${host_IP}/preseed/debian-12-preseed.cfg
menu endlabel local#menu defaultcom32 chain.c32menu label Boot from ^local drivelocalboot 0xffff
menu end
EOFecho "create directory preseed"
mkdir -p /srv/tftp/preseedecho "establish debian-12-preseed.cfg"
cat <<EOF>>/srv/tftp/preseed/debian-12-preseed.cfg
# 地區設置語言、國家和地區
d-i debian-installer/locale string en_US
d-i debian-installer/language string en
d-i debian-installer/country string CN
d-i debian-installer/locale string en_GB.UTF-8
d-i localechooser/supported-locales multiselect en_US.UTF-8, zh_CN.UTF-8# 配置鍵盤
d-i keyboard-configuration/xkb-keymap select us# 配置自動配置網絡DHCP
d-i netcfg/choose_interface select auto# 配置hostname和domain
d-i netcfg/get_hostname string $host_name
d-i netcfg/get_domain string $host_name# 指定軟件包鏡像源的設置
d-i mirror/country string manual
#d-i mirror/protocol string http
d-i mirror/http/hostname string $mirror
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string# 選擇軟件包,標準系統實用程序
tasksel tasksel/first multiselect standard ssh-server #開啟root登錄并設置root密碼,關閉普通用戶創建
d-i passwd/root-login boolean true
d-i passwd/make-user boolean false# Root密碼,可以是明文
#d-i passwd/root-password password $root_password
#d-i passwd/root-password-again password $root_password# root用戶密碼使用crypt(3)哈希進行加密(apt install -y whois) (mkpasswd -m sha-512 生成密鑰)
d-i passwd/root-password-crypted password $root_password# 普通用戶創建
#d-i passwd/make-user boolean true
#d-i passwd/user-fullname string Debian User
#d-i passwd/username string $common_user# 普通用戶密碼,可以是明文
#d-i passwd/user-password password $common_password
#d-i passwd/user-password-again password $common_password# 普通用戶密碼使用crypt(3)哈希進行加密(apt install -y whois) (mkpasswd -m sha-512 生成密鑰)
#d-i passwd/user-password-crypted password $common_password#允許弱密碼在用戶賬戶創建時被接受
d-i user-setup/allow-password-weak boolean true# 時鐘與時區設置
d-i clock-setup/utc boolean true
d-i time/zone string $time_zone
d-i clock-setup/ntp boolean false
#d-i clock-setup/ntp-server string ntp.example.com# uefi引導,強制使用gpt分區表
#d-i partman-efi/non_efi_system boolean true
#d-i partman-partitioning/choose_label string gpt
#d-i partman-partitioning/default_label string gpt# 配置磁盤 LVM xfs
d-i partman-auto/method string lvm
d-i partman-auto/disk string /dev/sda
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto/choose_recipe select atomic
d-i partman/default_filesystem string xfs# partman在沒有確認的情況下自動分區
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true# 基本系統安裝
#d-i  base-installer/kernel/p_w_picpath string linux-server#設置apt
#d-i apt-setup/security_host string mirrors.aliyun.com
#d-i apt-setup/security_path string /ubuntu
#d-i debian-installer/allow_unauthenticated string false
#d-i pkgsel/upgrade select safe-upgrade
#d-i pkgsel/language-packs multiselect 
#d-i pkgsel/update-policy select none
#d-i pkgsel/updatedb boolean trueb# 禁止在安裝的時候彈出CD/DVD掃描提示
d-i apt-setup/non-free boolean true
d-i apt-setup/contrib boolean true
d-i apt-setup/cdrom/set-first boolean false
d-i apt-setup/cdrom/set-next boolean false
d-i apt-setup/cdrom/set-failed boolean false# 安裝額外的軟件包,不更新系統
d-i pkgsel/include string openssh-server vim vim-tiny sudo whois git firewalld curl
d-i pkgsel/upgrade select none# grub安裝
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i grub-installer/bootdev string default
d-i grub-installer/skip boolean false
d-i grub-installer/bootdev string /dev/sda
#d-i lilo-installer/skip boolean false# 安裝完成之后不要彈出安裝完成的界面,直接重啟
d-i finish-install/reboot_in_progress note# 允許ssh服務使用root用戶登錄
d-i preseed/late_command string in-target sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
EOFecho "restart dhcp"
systemctl enable isc-dhcp-serverecho "restart tftpd-hpa isc-dhcp-server"
systemctl restart tftpd-hpa isc-dhcp-serverecho -e "\033[32mThe pxe server Install Sussess...\033[0m" elseecho -e "\033[33mThe pxe server Install Failed...\033[0m" exit 1fielseecho -e "\033[31mThe pxe server Install already...\033[0m"
fi
}main (){install_pxe_server
}main

執行安裝

 bash /pxe_server_install.sh

pxe 網絡啟動,目前實現bios,uefi 后續更新?

自動化安裝中

安裝完成,查看

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/44501.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/44501.shtml
英文地址,請注明出處:http://en.pswp.cn/web/44501.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

STM32的TIM1之PWM互補輸出_死區時間和剎車配置

STM32的TIM1之PWM互補輸出_死區時間和剎車配置 1、定時器1的PWM輸出通道 STM32高級定時器TIM1在用作PWM互補輸出時&#xff0c;共有4個輸出通道&#xff0c;其中有3個是互補輸出通道&#xff0c;如下&#xff1a; 通道1&#xff1a;TIM1_CH1對應PA8引腳,TIM1_CH1N對應PB13引…

LDAPWordlistHarvester:基于LDAP數據的字典生成工具

關于LDAPWordlistHarvester LDAPWordlistHarvester是一款功能強大的字典列表生成工具&#xff0c;該工具可以根據LDAP中的詳細信息生成字典列表文件&#xff0c;廣大研究人員隨后可以利用生成的字典文件測試目標域賬號的非隨機密碼安全性。 工具特征 1、支持根據LDAP中的詳細信…

STM32F103RC使用HAL庫配置USART進行數據收發

目錄 STM32F103RC使用HAL庫配置USART進行數據收發&#xff08;代碼模塊&#xff09; 一、USART初始化 二、USART使用的GPIO初始化 三、USART的接收中斷配置 四、USART的數據發送 五、補充 STM32F103RC使用HAL庫配置USART進行數據收發&#xff08;代碼模塊&#xff09; 一…

JavaDS —— 棧 Stack 和 隊列 Queue

棧的概念 棧是一種先進后出的線性表&#xff0c;只允許在固定的一端進行插入和刪除操作。 進行插入和刪除操作的一端被稱為棧頂&#xff0c;另一端被稱為棧底 棧的插入操作叫做進棧/壓棧/入棧 棧的刪除操作叫做出棧 現實生活中棧的例子&#xff1a; 棧的模擬實現 下面是Jav…

windows USB 設備驅動程序開發-總線接口查詢

總線接口的查詢 USB 客戶端驅動程序可以獲取對USB總線驅動程序接口的引用&#xff0c;并使用它來訪問總線驅動程序例程&#xff0c;而不是使用 I/O 請求數據包 (IRP) 機制。 使用總線驅動程序接口為客戶端驅動程序提供了幾個優勢&#xff1a; 它可以使用接口的服務&#xff…

對接企業微信API自建應用配置企業可信IP

前言 為了實現系統調用團隊會議功能&#xff0c;組織發起企業微信會議&#xff0c;于是需要和企業微信做API對接。對接過程很難受&#xff0c;文檔不清晰、沒有SDK、沒有技術支持甚至文檔報文和實際接口報文都不匹配&#xff0c;只能說企業微信的API是從業以來見過的最難用的AP…

[Spring] Spring Web MVC基礎理論

&#x1f338;個人主頁:https://blog.csdn.net/2301_80050796?spm1000.2115.3001.5343 &#x1f3f5;?熱門專欄: &#x1f9ca; Java基本語法(97平均質量分)https://blog.csdn.net/2301_80050796/category_12615970.html?spm1001.2014.3001.5482 &#x1f355; Collection與…

n3.平滑升級和回滾

平滑升級和回滾 1. 平滑升級流程2. 平滑升級和回滾案例 有時候我們需要對Nginx版本進行升級以滿足對其功能的需求&#xff0c;例如添加新模塊&#xff0c;需要新功能&#xff0c;而此時 Nginx又在跑著業務無法停掉&#xff0c;這時我們就可能選擇平滑升級 1. 平滑升級流程 平…

使用ChatGPT來撰寫和潤色學術論文的教程(含最新升級開桶ChatGpt4教程)

現在有了ChatGPT4o更加方便了, 但次數太少了 想要增加次數可以考慮升級開桶ChatGpt4 一、引言 在學術研究中&#xff0c;撰寫高質量的論文是一項重要的技能。本教程將介紹如何利用ChatGPT來輔助完成從論文構思到潤色的全過程。 二、使用ChatGPT寫論文 1. 寫標題 Title/Topic…

【TB作品】51單片機,MSP430單片機,STM32單片機,簡易波形發生器

https://docs.qq.com/sheet/DUEdqZ2lmbmR6UVdU?tabBB08J2二、 簡易波形發生器 &#xff08;限MSP430、STM32單片機&#xff09; 任務要求&#xff1a; 制作一個簡易波形發生器&#xff0c;具有如下功能&#xff1a; 1、能夠產生方波、正弦波&#xff0c;并可通過示波器觀察到&…

QT 多線程 QThread

繼承QThread的線程 繼承 QThread 是創建線程的一個普通方法。其中創建的線程只有 run() 方法在線程里的。其他類內定義的方法都在主線程內。 通過上面的圖我們可以看到&#xff0c;主線程內有很多方法在主線程內&#xff0c;但是子線程&#xff0c;只有 run() 方法是在子線…

基于STM32設計的藥品柜溫濕度監測系統(華為云IOT)(184)

基于STM32設計的藥品柜溫濕度監測系統(華為云IOT)(184) 文章目錄 一、前言1.1 項目介紹【1】項目功能介紹【2】整體需求總結【3】項目硬件模塊組成1.2 設計思路【1】整體設計思路【2】ESP8266工作模式配置【3】華為云IOT手機APP界面開發思路1.3 項目開發背景【1】選題的意義【2…

R語言學習筆記6-數據框

R語言學習筆記6-數據框 數據框(DataFrame)介紹數據框用途創建數據框從矩陣創建數據框索引和切片添加和修改列數據框的預處理數據框的排序數據框的合并與拆分數據框的計算與匯總數據框的篩選處理缺失值應用函數處理數據重塑數據框使用 dplyr 進行數據框的管道操作數據框的時間序…

使用 WebSocket 進行實時數據傳輸

以下是使用 WebSocket 進行實時數據傳輸的一般步驟&#xff1a; 一、前端部分 &#xff08;一&#xff09;創建 WebSocket 連接 const socket new WebSocket(ws://your-server-url); 在上述代碼中&#xff0c;將 ws://your-server-url 替換為您實際的服務器 WebSocket 地…

SvANet:微小醫學目標分割網絡,增強早期疾病檢測

SvANet&#xff1a;微小醫學目標分割網絡&#xff0c;增強早期疾病檢測 提出背景前人工作醫學對象分割微小醫學對象分割注意力機制 SvANet 結構圖SvANet 解法拆解解法邏輯鏈 論文&#xff1a;SvANet: A Scale-variant Attention-based Network for Small Medical Object Segmen…

【JAVA poi-tl-ext 富文本轉word】

富文本轉word 環境使用poi-tl-ext的原因富文本轉word代碼 環境 jdk 1.8 <dependency><groupId>io.github.draco1023</groupId><artifactId>poi-tl-ext</artifactId><version>0.4.16</version> </dependency>poi-tl-ext已經包…

可靈重大升級!新增Web端上線、首尾幀控制、單次生成視頻時長增加至10s!

快手視頻生成大模型“可靈”&#xff08;Kling&#xff09;&#xff0c;作為全球首個真正用戶可用的視頻生成大模型&#xff0c;自面世以來&#xff0c;憑借其無與倫比的視頻生成效果&#xff0c;在全球范圍內贏得了用戶的熱烈追捧與高度評價。截至目前&#xff0c;申請體驗其內…

修正版頭像上傳組件

修正版頭像上傳組件 文章說明核心源碼展示運行效果展示源碼下載 文章說明 在頭像剪切上傳一文中&#xff0c;我采用div做裁剪效果&#xff0c;感覺會有一些小問題&#xff0c;在昨天基于canvas繪制的功能中改進了一版&#xff0c;讓代碼變得更簡潔&#xff0c;而且通用性相對高…

永恒之藍:一場網絡風暴的啟示

引言 在網絡安全的漫長歷史中&#xff0c;“永恒之藍”&#xff08;EternalBlue&#xff09;是一個不可忽視的里程碑事件。它不僅揭示了網絡世界的脆弱性&#xff0c;還促使全球范圍內對網絡安全的重視達到了前所未有的高度。本文將深入探討“永恒之藍”漏洞的起源、影響及其對…

【WebGIS】從設計層面設計系統

本項目在通過現代信息技術手段&#xff0c;對古村古鎮進行多方位、多角度的數字化記錄、展示與傳播&#xff0c;實現文化遺產的數字化保護、活化利用與共享。項目內容主要包括&#xff1a;1&#xff09;古村古鎮數據庫的建立&#xff1a;通過多種渠道收集古村古鎮的各類信息&am…