pex+http+kickstart

来源:https://www.cnblogs.com/zhangxingeng/archive/2018/08/30/9560221.html
-Advertisement-
Play Games

1、說明 所謂的PXE是Preboot Execution Environment的縮寫,字面上的意思是開機前的執行環境。 要實現pxe,至少需要3個服務 2、流程 註意:全部用的udp封裝 1)client向pxe server上的dhcp發送IP地址請求消息,dhcp檢測client是否合法,同 ...


 

1、說明

所謂的PXE是Preboot Execution Environment的縮寫,字面上的意思是開機前的執行環境。

要實現pxe,至少需要3個服務

 

2、流程

 註意:全部用的udp封裝

 1)client向pxe server上的dhcp發送IP地址請求消息,dhcp檢測client是否合法,同事將pxe環境下的boot loader文件pxelinux.0的位置信息發給client

 2)client向pxe server上的tftp請求pxelinux.0,tftp收到消息向client發送pxelinux.0大小信息,試探client是否滿意,當tftp收到client發回的統一大小信息後,發送pxelinux.0.

 3)client執行接收到的pxelinux.0

 4)client向TFTP請求pxelinux.cfg文件(其實是目錄,裡面放了啟動菜單,即grub的配置文件),TFTP將配置文件發回client,繼而client根據配置文件執行後續的操作

 5)client向TFTP發送linux內核請求信息,TFTP發送內核

 6)client向TFTP發送根文件請求信息,TFTP接受到消息之後返回linux根文件系統

 7)client載入linux內核(啟動參數已經在4中的配置文件中設置好了)。

 8)client通過nfs/ftp/http下載系統安裝文件進行安裝,如果4中的配置文件指定了kickstart路徑,則回根據此文件自動應答安裝系統

 

幾個文件的說明

  • vmlinuz:核心文件(kernel file);
  • initrd.img:開啟過程中核心組件的參數;
  • isolinux.cfg --> demo:開機pxe選擇參考;

3、部署

順序

DHCP

TFTP

提供bootloader及配置文件

掛載光碟,把內核文件cp到tftp目錄

部署httpd,並放置文件

設置菜單及提供系統安裝文件

3.1部署DHCP

  yum -y install 
  dhcp[root@localhost ~]# cat /etc/dhcp/dhcpd.con
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.216.0 netmask 255.255.255.0 {
  range dynamic-bootp 192.168.216.220 192.168.216.230;
  option domain-name-servers 192.168.216.147;
  option subnet-mask 255.255.255.0;
  option routers 192.168.216.147;
  default-lease-time 600;
  max-lease-time 7200;  
  next-server 192.168.216.147;      ###這個就是tftp地址
filename"pxelinux.0";          ###告知從tftp根目錄獲取bootloader文件
}
host clientA{                        ###可以綁定某台主機的ip地址,用mac綁定
        hardware ethernet 00:0C:29:83:A2:10;      
        fixed-address 192.168.216.229;
}
ddns-update-style interim;

    啟動服務

  systemctl start dhcpd
3.2部署TFTP
  從流程得知boot loader文件pxelinux.0以及內核相關的配置文件(目錄pxelinux.cfg下)主要都是由TFTP來提供的
  yum install tftp-server
  yum -y install xinetd
  TFTP是由xinetd這個super daemon所管理的,因此設定好TFTP之後,要啟動的是xinetd;
[root@localhost ~]# cat /etc/xinetd.d/tftp 
# default: off
# description: The tftp server serves files using the trivial file transfer \
#       protocol.  The tftp protocol is often used to boot diskless \
#       workstations, download configuration files to network-aware printers, \
#       and to start the installation process for some operating systems.
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot  ###這個是tftp的根目錄
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

  啟動tftp

  systemctl start tftp

  查看服務ps -ef |grep xinetd

[root@localhost tftpboot]# ps -ef |grep xinetd
root      49896      1  0 Aug29 ?        00:00:00 /usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid
root      61791  49577  0 16:15 pts/0    00:00:00 grep --color=auto xinetd

  ss -unlp

  查看一下埠是否監聽埠是69

3.3提供bootloader及配置文件

  yum -y install syslinux
   需要使用CentOS提供的syslinux包,從中copy幾個文件

  cp -a /usr/share/syslinux/{menu.c32,vesamenu.c32,pxelinux.0}
/var/lib/tftpboot
  
[root@localhost tftpboot]# ll 
total 47964
-rw-r--r-- 1 root root       84 Sep 21  2017 boot.msg
-rw-r--r-- 1 root root    20704 Sep 20  2017 chain.c32
-rw-r--r-- 1 root root      501 Sep 20  2017 fstab
-rw-r--r-- 1 root root 43372552 Sep 20  2017 initrd.img
-rw-r--r-- 1 root root    33628 Sep 20  2017 mboot.c32
-rw-r--r-- 1 root root    26140 Sep 20  2017 memdisk
-rw-r--r-- 1 root root    55012 Sep 20  2017 menu.c32      #圖形化菜單
-rw-r--r-- 1 root root    26764 Sep 20  2017 pxelinux.0     #bootloader
drwxr-xr-x 2 root root       21 Aug 29 18:34 pxelinux.cfg    #開機菜單設定
-rw-r--r-- 1 root root      186 Sep 21  2017 splash.png
-rw-r--r-- 1 root root   152976 Sep 21  2017 vesamenu.c32    #也是圖形菜單
-rwxr-xr-x 1 root root  5392080 Sep 20  2017 vmlinuz

 註意:pxelinux.cfg是個目錄,可以放置預設的開機選項,也可以針對不同的客戶端主機提供不同的開機選項。可以在pxelinux.cfg目錄內建立一個名為default的文件來提供預設選項。

3.4部署http服務

yum install -y httpd

mkdir /media/cdrom

mount -r /dev/cdrom /media/cdrom

mount --bind /media/cdrom/ /var/www/html/centos7

3.4掛載光碟,把內核文件cp到tftpmulu

 cd /var/www/html/centos7

cp isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

cp images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot

cp isolinux/{vesamenu.c32,boot.msg,splash.png} /var/lib/tftpboot/

 

3.5設置菜單及提供系統安裝文件

[root@localhost pxelinux.cfg]# cat default 
default menu.c32   #這個必須有也可以使用vesamenu.c32
prompt 1
timeout 10       #超時時間

menu title ########## PXE Boot Menu ##########

label 1
menu label ^1) Install CentOS 7 x64 with Local Repo    #菜單文字
menu default                         #表示開機游標一開始停留在label上 
kernel vmlinuz                          #內核文件路徑,相對路徑是從/tftpboot開始的
append initrd=initrd.img inst.repo=http://192.168.216.147/centos7   #內核啟動選項,其中initrd的路徑,還有其他的stage2文件,
ks=http://192.168.216.147/ks.cfg              #指定kickstart路徑  

 

 這樣就完成了配置,接下來開啟個服務,並開機自啟

 systemctl restart dhcpd.service

systemctl restart xinetd.service

systemctl restart tftp.socket

systemctl restart tftp.service

systemctl restart httpd.service

 

systemctl enable dhcpd.service

systemctl enable xinetd.service

systemctl enable tftp.service

systemctl  enable httpd.service

 

4、kickstart實現無人值守批量安裝(不完全是無人)

cp -a ~/anaconda-ks.cfg /var/www/html/ks.cfg

chmod +r /var/www/html/ks.cfg  #使全局可讀

cd /var/www/html/

[root@localhost html]# cat ks.cfg
#version=DEVEL
# System authorization information
auth --useshadow --enablemd5
# Install OS instead of upgrade
install
# Use network installation
url --url="http://192.168.216.147/centos7"
# Use graphical install
graphical
# Firewall configuration
firewall --enabled
firstboot --disable
ignoredisk --only-use=sda
# Keyboard layouts
# old format: keyboard us
# new format:
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8

# Network information
network  --bootproto=dhcp --device=link
network  --hostname=localhost.localdomain
# Reboot after installation
reboot
# Root password
rootpw --iscrypted $1$uH$aaWTA7AmvIxGMidj0sp.u1
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
# X Window System configuration information
xconfig  --startxonboot
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --none --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=300
part swap --fstype="swap" --size=3841
part / --fstype="xfs" --size=57298

%post
/usr/sbin/adduser zhangxingeng
/usr/sbin/usermod -p '$1$uH$aaWTA7AmvIxGMidj0sp.u1' zhangxingeng
/usr/bin/chfn -f "centos-7-64" zhangxingeng
mv /etc/rc.d/rc.local /etc/rc.d/rc.local.00
echo '#!/bin/bash' > /etc/rc.d/rc.local
ln -s ../rc.local /etc/rc.d/rc5.d/S99rclocal
chmod 755 /etc/rc.d/rc.local
echo 'mkdir -p /var/log/vmware' >> /etc/rc.d/rc.local
echo 'exec 1> /var/log/vmware/rc.local.log' >> /etc/rc.d/rc.local
echo 'exec 2>&1' >> /etc/rc.d/rc.local
echo 'set -x' >> /etc/rc.d/rc.local
echo 'echo Installing Open VM Tools' >> /etc/rc.d/rc.local
echo 'set -x' >> /etc/rc.d/rc.local
echo '/bin/eject sr0 || /bin/true' >> /etc/rc.d/rc.local
echo '/bin/eject sr1 || /bin/true' >> /etc/rc.d/rc.local
echo '/bin/vmware-rpctool' \'guest.upgrader_send_cmd_line_args --default\' >> /etc/rc.d/rc.local
echo '/bin/vmware-rpctool' \'upgrader.setGuestFileRoot /tmp\' >> /etc/rc.d/rc.local
echo '/bin/vmware-rpctool' \'toolinstall.installerActive 1\' >> /etc/rc.d/rc.local
echo '/bin/vmware-rpctool' \'toolinstall.installerActive 100\' >> /etc/rc.d/rc.local
echo 'rm -f /etc/rc.d/rc.local' >> /etc/rc.d/rc.local
echo 'rm -f /etc/rc.d/rc5.d/S99rclocal' >> /etc/rc.d/rc.local
echo 'mv /etc/rc.d/rc.local.00 /etc/rc.d/rc.local' >> /etc/rc.d/rc.local
/bin/echo done
%end

%packages
@base
@core
@desktop-debugging
@dial-up
@directory-client
@fonts
@gnome-desktop
@guest-desktop-agents
@input-methods
@internet-browser
@java-platform
@multimedia
@network-file-system-client
@print-client
@x11
binutils
ftp
gcc
kernel-devel
kexec-tools
make
open-vm-tools
patch
python

%end

%addon com_redhat_kdump --enable --reserve-mb='auto'

%end
[root@localhost html]# 

  

 

先到這裡,本著學習的態度,只是為了熟悉一下整個pxe流程,本文參考http://www.cnblogs.com/f-ck-need-u/p/7342919.html

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 環境:VMware Workstation 12 Pro,Windows 10,CentOS 6.9 x86_64,Xshell5 基本介紹 tcpdump是Linux自帶的抓包工具,可以詳細看到電腦通信中詳細報文內容,如果讀者熟悉另一款 強大的抓包工具wireshark,tcpdump相當於是w ...
  • Shutter是一個由第三方提供的在Ubuntu上運行的截圖工具,相對於系統自帶的截圖工具(預設可通過Ctrl + Shift + Print快捷鍵啟動截圖),最大的優點就是可以即時對圖片進行編輯,在圖片上做一些標記和文字標註等,使用起來很方便。在Ubuntu 16.04上,該軟體運行一切正常,當將 ...
  • 1、編寫一段程式,使用系統調用fork( )創建兩個子進程,再用系統調用signal( )讓父進 程捕捉鍵盤上來的中斷信號(即按ctrl+c鍵),當捕捉到中斷信號後,父進程用系統調用kill( )向兩個子進程發出信號,子進程捕捉到信號後,分別輸出下列信息後終止: Child process 1 is ...
  • 常用的Shell命令 當用戶登錄到字元界面系統或使用終端模擬視窗時,就是在和稱為shell的命令解釋程式進行通信。當用戶在鍵盤上輸入一條命令時,shell程式將對命令進行解釋並完成相應的動作。這種動作可能是執行用戶的應用程式,或者是調用一個編輯器、GNU/Linux實用程式或其他標準程式,或者是一條 ...
  • 一、實驗目的 1、熟悉操作系統的系統功能調用。 2、掌握用C語言實現系統功能調用的方法和步驟。 3、掌握利用10H號功能調用(BIOS的顯示I/O功能調用)來實現對屏幕的操作與控制。 二、實驗內容 1、在屏幕的指定區域內顯示字元串。(必做題) 2、在屏幕的制定區域內畫框,在框內顯示字元串。(提高題) ...
  • cat命令連接文件並列印到標準輸出設備上。 註意:當文件較大時,文本在屏幕上迅速閃過(滾屏),用戶往往看不清所顯示的內容。因此,一般用more等命令分屏顯示。為了控制滾屏,可以按Ctrl+S鍵,停止滾屏;按Ctrl+Q鍵可以恢復滾屏。按Ctrl+C(中斷)鍵可以終止該命令的執行,並且返回Shell提 ...
  • 和某些應用軟體衝突時,需要將上述補丁卸載。 ...
  • 追加用戶組 追加新用戶 更改用戶 添加用戶到其他組 修改用戶密碼 刪除用戶 給用戶增加sudo許可權 切換超級用戶 添加sudo許可權 預設的sudoers文件是沒有寫入許可權的,需要增加許可權 修改sudoers文件 找到下麵root的代碼處 在之後追加以下代碼,保存退出 更改目錄和文件的訪問許可權 更改目 ...
一周排行
    -Advertisement-
    Play Games
  • 前言 本文介紹一款使用 C# 與 WPF 開發的音頻播放器,其界面簡潔大方,操作體驗流暢。該播放器支持多種音頻格式(如 MP4、WMA、OGG、FLAC 等),並具備標記、實時歌詞顯示等功能。 另外,還支持換膚及多語言(中英文)切換。核心音頻處理採用 FFmpeg 組件,獲得了廣泛認可,目前 Git ...
  • OAuth2.0授權驗證-gitee授權碼模式 本文主要介紹如何筆者自己是如何使用gitee提供的OAuth2.0協議完成授權驗證並登錄到自己的系統,完整模式如圖 1、創建應用 打開gitee個人中心->第三方應用->創建應用 創建應用後在我的應用界面,查看已創建應用的Client ID和Clien ...
  • 解決了這個問題:《winForm下,fastReport.net 從.net framework 升級到.net5遇到的錯誤“Operation is not supported on this platform.”》 本文內容轉載自:https://www.fcnsoft.com/Home/Sho ...
  • 國內文章 WPF 從裸 Win 32 的 WM_Pointer 消息獲取觸摸點繪製筆跡 https://www.cnblogs.com/lindexi/p/18390983 本文將告訴大家如何在 WPF 裡面,接收裸 Win 32 的 WM_Pointer 消息,從消息裡面獲取觸摸點信息,使用觸摸點 ...
  • 前言 給大家推薦一個專為新零售快消行業打造了一套高效的進銷存管理系統。 系統不僅具備強大的庫存管理功能,還集成了高性能的輕量級 POS 解決方案,確保頁面載入速度極快,提供良好的用戶體驗。 項目介紹 Dorisoy.POS 是一款基於 .NET 7 和 Angular 4 開發的新零售快消進銷存管理 ...
  • ABP CLI常用的代碼分享 一、確保環境配置正確 安裝.NET CLI: ABP CLI是基於.NET Core或.NET 5/6/7等更高版本構建的,因此首先需要在你的開發環境中安裝.NET CLI。這可以通過訪問Microsoft官網下載並安裝相應版本的.NET SDK來實現。 安裝ABP ...
  • 問題 問題是這樣的:第三方的webapi,需要先調用登陸介面獲取Cookie,訪問其它介面時攜帶Cookie信息。 但使用HttpClient類調用登陸介面,返回的Headers中沒有找到Cookie信息。 分析 首先,使用Postman測試該登陸介面,正常返回Cookie信息,說明是HttpCli ...
  • 國內文章 關於.NET在中國為什麼工資低的分析 https://www.cnblogs.com/thinkingmore/p/18406244 .NET在中國開發者的薪資偏低,主要因市場需求、技術棧選擇和企業文化等因素所致。歷史上,.NET曾因微軟的閉源策略發展受限,儘管後來推出了跨平臺的.NET ...
  • 在WPF開發應用中,動畫不僅可以引起用戶的註意與興趣,而且還使軟體更加便於使用。前面幾篇文章講解了畫筆(Brush),形狀(Shape),幾何圖形(Geometry),變換(Transform)等相關內容,今天繼續講解動畫相關內容和知識點,僅供學習分享使用,如有不足之處,還請指正。 ...
  • 什麼是委托? 委托可以說是把一個方法代入另一個方法執行,相當於指向函數的指針;事件就相當於保存委托的數組; 1.實例化委托的方式: 方式1:通過new創建實例: public delegate void ShowDelegate(); 或者 public delegate string ShowDe ...