ipxe u盘启动linux内核,iPXE的使用介绍
iPXE的使用介紹.md
概述
PXE是Intel提出的,用以網(wǎng)卡啟動(dòng)。通過DHCP獲取IP以及TFTP獲取啟動(dòng)文件。
gPXE/iPXE是PXE的擴(kuò)展版,支持HTTP等多種獲取手段。iPXE由gPXE分支而來(fork),功能更豐富。
iPXE的使用
之前我們使用PXE的時(shí)候,要在DHCP配置中設(shè)置啟動(dòng)文件為pxelinux.0
# Subnet for new 100 subnet
subnet172.16.100.0netmask255.255.254.0{
range172.16.101.230172.16.101.240;
option subnet-mask255.255.254.0;
option routers172.16.100.1;
next-server172.16.10.31;
filename"pxelinux.0";
}
如果使用的是gpxe,那么這個(gè)文件名就是 gpxelinux.0
這兩個(gè)文件都可以在你syslinux的安裝包中找到。
iPXE就沒那么好了,需要自己下載。
下載鏈接是 http://boot.ipxe.org/undionly.kpxe
然后設(shè)定DHCP配置文件
next-server172.16.10.31;
filename"undionly.kpxe";
But… 問題來了,你會(huì)發(fā)現(xiàn)iPXE的啟動(dòng)界面是一個(gè)死循環(huán)。
如何打破這個(gè)死循環(huán)呢?
官方提供了2個(gè)辦法,一個(gè)是改DHCP的配置,貌似很麻煩,我們還是采用第二種辦法,重新編譯。
git clone git://git.ipxe.org/ipxe.git
cd ipxe/src
cat<>demo.ipxe
#!ipxe
dhcp
chain http://boot.ipcpu.com
EOF
make bin/undionly.kpxe EMBED=demo.ipxe
其中的chain需要填寫啟動(dòng)網(wǎng)址。
生成新的undionly.kpxe,我們把它覆蓋掉原先的文件。
接下來,我們就要處理啟動(dòng)網(wǎng)站了。
啟動(dòng)網(wǎng)站的處理
啟動(dòng)網(wǎng)站需要http服務(wù)器,這里我們使用了nginx。
首先我們寫入首頁文件index.html
#!ipxe
echo
echoBootingboot.oskarcz.netfor${hostname}
set210:stringhttp://boot.ipcpu.com/
set209:stringpxelinux.cfg/default
set208:hex f1:00:74:7e
setfilename ${210:string}pxelinux.0
chain ${filename}||
echoBooting${filename}failed,dropping to shell
shell
#@加載http://boot.ipcpu.com/pxelinux.0文件
#@加載http://boot.ipcpu.com/pxelinux.cfg/default 配置
然后這里就和普通的PXE一樣了,唯一不同的是協(xié)議全部是HTTP。
配置文件pxelinux.cfg/default
######################################
#使用vesamenu.c32菜單
DEFAULT res/vesamenu.c32
PROMPT0
MENU TITLE PXE NETBOOT TOOLKITS
#背景圖片
MENU BACKGROUND res/back.png
#字體設(shè)定
FONT res/myfont.psf
#超時(shí)設(shè)定
TIMEOUT300
MENU VSHIFT6
#超時(shí)默認(rèn)啟動(dòng)hardboot
ONTIMEOUT hardboot
#####custom6.6
LABEL centos66
MENU LABEL^1--CustomCentOS6.664bitSetup
linux http://boot.ipcpu.com/pxe/centos6/isolinux/vmlinuz
append initrd=http://boot.ipcpu.com/pxe/centos6/isolinux/initrd.img ks=http://boot.ipcpu.com/secret/ks/centos66.cfg ksdevice=bootif ip=172.1.30.250 netmask=255.255.0.0 gateway=172.1.1.1 dns=172.1.10.1,172.1.10.2 hostname=IPCPU-30-250
######boot from harddisk
LABEL hardboot
MENU LABEL^H--Bootfromthe firstHardDisk
kernel res/chain.c32 hd0
界面截圖
QA
QA-1
Q:如何實(shí)現(xiàn)公網(wǎng)上的安裝服務(wù)?
A:我們看到iPXE配置里寫的是一個(gè)網(wǎng)址,將網(wǎng)站發(fā)布出去就可以利用公網(wǎng)安裝了。http://boot.oskarcz.net/ 以及 https://netboot.xyz/boot-ipxe/index.html 就是這樣一種服務(wù)
QA-2
Q:如何使用公網(wǎng)上的安裝服務(wù)
A:在iPXE啟動(dòng)界面中按下Ctrl+B,中斷默認(rèn)啟動(dòng)方式,然后輸入以下內(nèi)容,即可使用。
iPXE>dhcp
iPXE>chain http://boot.oskarcz.net
QA-3
Q:如何實(shí)現(xiàn)http://boot.oskarcz.net/這種方式呢,瀏覽器訪問時(shí)顯示幫助文件。
A:這里是采用nginx對(duì)UserAgent進(jìn)行判斷,UA為iPXE時(shí),根目錄是腳本目錄,其他UA時(shí),根目錄是幫助文件。
QA-4
Q:gPXE有什么缺點(diǎn)呢?
A:gPXE已經(jīng)停止開發(fā),沒有技術(shù)支持了,并且在實(shí)際使用中,發(fā)現(xiàn)VMWARE ESXi使用gpxe后,下載配置文件特別慢,無法忍受。
參考資料
總結(jié)
以上是生活随笔為你收集整理的ipxe u盘启动linux内核,iPXE的使用介绍的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Abaqus模拟偏心受压钢管混凝土柱计算
- 下一篇: Tendermint mempool分析