UEFI PXE Server架設 (RHEL6) - Linux

By Hedy
at 2011-08-13T08:52
at 2011-08-13T08:52
Table of Contents
最近研究完UEFI PXE Server架設
這邊與各位分享
以下是用Shell Script寫法 附上說明
#!/bin/bash
# 這個Shell Script適用在RHEL6來架設UEFI PXE Server
# 網路IP請先設定好 這邊使用的是192.168.100.100當範例
# 請將RHEL6的DVD資料cp到/var/ftp/RHEL6
# 1. Install all service
# 請確認你的yum server有先架設起來
# 參考src.repo檔案寫法
# [src]
# name=src
# baseurl=file:///var/ftp/RHEL6/
yum -y install tftp-server dhcp vsftpd
# 2. Config all service
# (1) tftp server
# tftp部份 只要將原始檔的disable=yes改成no即可
echo "service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no
per_source = 11
CPUS = 100 2
flags = IPv4
}" > /etc/xinetd.d/tftp
chkconfig tftp on
service xinetd restart
# (2) vsftp server
# 這邊看個人需求 具有匿名下載的基本功能即可
chkconfig vsftpd on
service vsftpd restart
# (3) dhcp server
# 這邊做的是將efiboot.img掛載起來 然後複製必要檔案到tftp server
mkdir /efiboot
mount -o loop /var/ftp/RHEL6/images/efiboot.img /efiboot
cp -R /efiboot/EFI/BOOT/* /var/lib/tftpboot/
# 這邊是dhcpd的config
# 指定的區段是.50到.250
echo "ddns-update-style none;
ignore client-updates;
allow booting;
allow bootp;
subnet 192.168.100.0 netmask 255.255.255.0 {
range 192.168.100.50 192.168.100.250;
option routers 192.168.100.254;
option subnet-mask 255.255.255.0;
next-server 192.168.100.100;
# next-server是重點 代表指引Client的目標Server IP
filename \"BOOTX64.efi\";
# 這邊與Legacy BIOS的檔案不同 UEFI使用的是efi檔案做開機
# 也就是剛剛掛載的image複製出來的檔案之一
}" > /etc/dhcp/dhcpd.conf
umount /efiboot
rmdir /efiboot
chkconfig dhcpd on
service dhcpd start
# (4) make boot menu
echo "default=0
timeout 10
splashimage=(nd)/splash.xpm.gz
# nd代表network device 指定從網路介面去讀取splash.xpm.gz
# 成功的話 Client連結到時 menu會在螢幕正中間 而不是左上角
title RHEL6
root (nd)
# nd是重點
splashimage /splash.xpm.gz
kernel /vmlinuz keymap=us lang=en_US
method=ftp://192.168.100.100/RHEL6 ip=dhcp noipv6
# 這邊指定的是Server的RHEL6光碟檔案放置處 採用dhcp的方式
initrd /initrd.img
title Kickstart
root (nd)
kernel /vmlinuz ks=ftp://192.168.100.100/ks.cfg
initrd /initrd.img" > /var/lib/tftpboot/efidefault
# 這個選單有兩種模式 預設是使用者自己手動安裝
# 第二種是kickstart來自動安裝
# (5) copy vmlinux
cp /var/ftp/RHEL6/images/pxeboot/* /var/lib/tftpboot/
echo "Now you can test UEFI-PXE"
# Kickstart file automatically generated by anaconda.
# (6) ks.cfg 這個kickstart會清掉所有分割區 要套用前記得修改成自己要的
echo "#version=RHEL6
install
url --url=ftp://192.168.100.100/RHEL6
# url指定的是Server的光碟檔案位置
lang en_US.UTF-8
keyboard us
network --device eth0 --bootproto dhcp
rootpw --iscrypted
$6$e57ki/NcsLdO1lSv$UzC2Uv5aUbGt8o.vU9e6HNqyammGXj7WTL6WYEFXBn1YytM.1eA6jWhay8dLUw2me6gji9Irki8wx6cecGJS3/
# 密碼是設定成Aa123456
# 你也可以去掉這行 或是換成明碼
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512 --enablefingerprint
selinux --enforcing
timezone Asia/Taipei
bootloader --location=partition --driveorder=sda --append="crashkernel=auto
rhgb quiet"
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
clearpart --all --drives=sda
part /boot/efi --fstype=efi --grow --maxsize=200 --size=20
part /boot --fstype=ext4 --size=500
part pv.oR0bde-SgcE-eiHl-Khvt-BRx9-NpmK-otQ5HU --grow --size=1
volgroup vg_urhel6 --pesize=4096 pv.oR0bde-SgcE-eiHl-Khvt-BRx9-NpmK-otQ5HU
logvol / --fstype=ext4 --name=lv_root --vgname=vg_urhel6 --size=570596
logvol swap --name=lv_swap --vgname=vg_urhel6 --size=1024
repo --name="Red Hat Enterprise Linux"
--baseurl=ftp://192.168.100.100/RHEL6/ --cost=100
%packages
@additional-devel
@base
@compat-libraries
@console-internet
@core
@debugging
@basic-desktop
@desktop-debugging
@desktop-platform
@desktop-platform-devel
@development
@directory-client
@eclipse
@fonts
@general-desktop
@graphical-admin-tools
@hardware-monitoring
@input-methods
@java-platform
@kde-desktop
@large-systems
@legacy-x
@network-file-system-client
@performance
@perl-runtime
@remote-desktop-clients
@server-platform
@server-platform-devel
@server-policy
@x11
httpd-devel
pcre-devel
libcap-devel
libXinerama-devel
openmotif-devel
net-snmp-devel
libgudev1-devel
kdelibs-apidocs
xz-devel
libtopology-devel
kdegraphics-devel
libibverbs-devel
libuuid-devel
kdepimlibs-devel
libblkid-devel
papi-devel
libXmu-devel
unique-devel
xorg-x11-proto-devel
gmp-devel
kdepim-devel
sane-backends-devel
perl-Test-Pod
kdemultimedia-devel
startup-notification-devel
libudev-devel
cups-devel
gstreamer-plugins-base-devel
unixODBC-devel
tcl-devel
numactl-devel
libgnomeui-devel
libbonobo-devel
perl-Test-Pod-Coverage
libtiff-devel
junit
SDL-devel
libXau-devel
tcp_wrappers-devel
PyQt4-devel
kdenetwork-devel
kdelibs-devel
libgcrypt-devel
popt-devel
libusb-devel
hunspell-devel
iptables-devel
libdrm-devel
libXrandr-devel
libxslt-devel
kdebase-devel
tk-devel
libnl-devel
libXpm-devel
expat-devel
e2fsprogs-devel
kdebase-workspace-devel
libglade2-devel
libaio-devel
gnutls-devel
kdesdk-devel
fuse-devel
libXaw-devel
libhugetlbfs-devel
mtools
pax
python-dmidecode
oddjob
squashfs-tools
sgpio
genisoimage
wodim
sabayon-apply
control-center-extra
xguest
tigervnc-server
oprofile-gui
abrt-gui
xrestop
systemtap-grapher
bltk
qt-mysql
qt3-ODBC
qt-odbc
qt-postgresql
qt3-PostgreSQL
qt3-MySQL
kdesdk
gnome-common
qt-doc
gtk2-devel-docs
glade3
desktop-file-utils
gnome-devel-docs
systemtap-sdt-devel
mod_dav_svn
ElectricFence
ant
libstdc++-docs
gcc-gnat
expect
dejagnu
perltidy
cmake
imake
babel
rpmdevtools
compat-gcc-34
systemtap-server
gcc-java
compat-gcc-34-g77
jpackage-utils
bzr
mercurial
chrpath
gcc-objc
rpmlint
gcc-objc++
compat-gcc-34-c++
python-docs
nasm
certmonger
pam_krb5
krb5-workstation
nscd
pam_ldap
nss-pam-ldapd
eclipse-mylyn-cdt
eclipse-pde
eclipse-mylyn-pde
eclipse-mylyn-wikitext
eclipse-mylyn-trac
eclipse-subclipse-graph
eclipse-mylyn-webtasks
cjkuni-fonts-ghostscript
bitmap-fixed-fonts
bitmap-lucida-typewriter-fonts
krb5-auth-dialog
gnome-pilot-conduits
gconf-editor
dvgrab
alacarte
seahorse-plugins
rhythmbox-upnp
gnome-games
gedit-plugins
gnome-pilot
totem-upnp
vim-X11
sabayon
system-config-lvm
audit-viewer
setroubleshoot
firstaidkit-gui
system-config-kickstart
policycoreutils-gui
kdebase-workspace-akonadi
kdebase-workspace-python-applet
xorg-x11-twm
openmotif
xorg-x11-fonts-ISO8859-1-75dpi
xterm
xorg-x11-fonts-cyrillic
xorg-x11-xdm
xorg-x11-fonts-ISO8859-9-100dpi
xorg-x11-fonts-ISO8859-14-100dpi
xorg-x11-fonts-75dpi
xorg-x11-fonts-ISO8859-9-75dpi
libXmu
xorg-x11-fonts-ISO8859-15-75dpi
libXp
openmotif22
xorg-x11-fonts-ISO8859-14-75dpi
xorg-x11-fonts-ISO8859-2-75dpi
xorg-x11-fonts-ethiopic
xorg-x11-fonts-ISO8859-2-100dpi
papi
perl-DBD-SQLite
spice-xpi
tsclient
rdesktop
vinagre
tigervnc
spice-client
wacomcpl
%end " > /var/ftp/ks.cfg
chmod 777 /var/ftp/ks.cfg
# 要注意權限問題 免得Client無法下載ks.cfg
--
這邊與各位分享
以下是用Shell Script寫法 附上說明
#!/bin/bash
# 這個Shell Script適用在RHEL6來架設UEFI PXE Server
# 網路IP請先設定好 這邊使用的是192.168.100.100當範例
# 請將RHEL6的DVD資料cp到/var/ftp/RHEL6
# 1. Install all service
# 請確認你的yum server有先架設起來
# 參考src.repo檔案寫法
# [src]
# name=src
# baseurl=file:///var/ftp/RHEL6/
yum -y install tftp-server dhcp vsftpd
# 2. Config all service
# (1) tftp server
# tftp部份 只要將原始檔的disable=yes改成no即可
echo "service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no
per_source = 11
CPUS = 100 2
flags = IPv4
}" > /etc/xinetd.d/tftp
chkconfig tftp on
service xinetd restart
# (2) vsftp server
# 這邊看個人需求 具有匿名下載的基本功能即可
chkconfig vsftpd on
service vsftpd restart
# (3) dhcp server
# 這邊做的是將efiboot.img掛載起來 然後複製必要檔案到tftp server
mkdir /efiboot
mount -o loop /var/ftp/RHEL6/images/efiboot.img /efiboot
cp -R /efiboot/EFI/BOOT/* /var/lib/tftpboot/
# 這邊是dhcpd的config
# 指定的區段是.50到.250
echo "ddns-update-style none;
ignore client-updates;
allow booting;
allow bootp;
subnet 192.168.100.0 netmask 255.255.255.0 {
range 192.168.100.50 192.168.100.250;
option routers 192.168.100.254;
option subnet-mask 255.255.255.0;
next-server 192.168.100.100;
# next-server是重點 代表指引Client的目標Server IP
filename \"BOOTX64.efi\";
# 這邊與Legacy BIOS的檔案不同 UEFI使用的是efi檔案做開機
# 也就是剛剛掛載的image複製出來的檔案之一
}" > /etc/dhcp/dhcpd.conf
umount /efiboot
rmdir /efiboot
chkconfig dhcpd on
service dhcpd start
# (4) make boot menu
echo "default=0
timeout 10
splashimage=(nd)/splash.xpm.gz
# nd代表network device 指定從網路介面去讀取splash.xpm.gz
# 成功的話 Client連結到時 menu會在螢幕正中間 而不是左上角
title RHEL6
root (nd)
# nd是重點
splashimage /splash.xpm.gz
kernel /vmlinuz keymap=us lang=en_US
method=ftp://192.168.100.100/RHEL6 ip=dhcp noipv6
# 這邊指定的是Server的RHEL6光碟檔案放置處 採用dhcp的方式
initrd /initrd.img
title Kickstart
root (nd)
kernel /vmlinuz ks=ftp://192.168.100.100/ks.cfg
initrd /initrd.img" > /var/lib/tftpboot/efidefault
# 這個選單有兩種模式 預設是使用者自己手動安裝
# 第二種是kickstart來自動安裝
# (5) copy vmlinux
cp /var/ftp/RHEL6/images/pxeboot/* /var/lib/tftpboot/
echo "Now you can test UEFI-PXE"
# Kickstart file automatically generated by anaconda.
# (6) ks.cfg 這個kickstart會清掉所有分割區 要套用前記得修改成自己要的
echo "#version=RHEL6
install
url --url=ftp://192.168.100.100/RHEL6
# url指定的是Server的光碟檔案位置
lang en_US.UTF-8
keyboard us
network --device eth0 --bootproto dhcp
rootpw --iscrypted
$6$e57ki/NcsLdO1lSv$UzC2Uv5aUbGt8o.vU9e6HNqyammGXj7WTL6WYEFXBn1YytM.1eA6jWhay8dLUw2me6gji9Irki8wx6cecGJS3/
# 密碼是設定成Aa123456
# 你也可以去掉這行 或是換成明碼
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512 --enablefingerprint
selinux --enforcing
timezone Asia/Taipei
bootloader --location=partition --driveorder=sda --append="crashkernel=auto
rhgb quiet"
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
clearpart --all --drives=sda
part /boot/efi --fstype=efi --grow --maxsize=200 --size=20
part /boot --fstype=ext4 --size=500
part pv.oR0bde-SgcE-eiHl-Khvt-BRx9-NpmK-otQ5HU --grow --size=1
volgroup vg_urhel6 --pesize=4096 pv.oR0bde-SgcE-eiHl-Khvt-BRx9-NpmK-otQ5HU
logvol / --fstype=ext4 --name=lv_root --vgname=vg_urhel6 --size=570596
logvol swap --name=lv_swap --vgname=vg_urhel6 --size=1024
repo --name="Red Hat Enterprise Linux"
--baseurl=ftp://192.168.100.100/RHEL6/ --cost=100
%packages
@additional-devel
@base
@compat-libraries
@console-internet
@core
@debugging
@basic-desktop
@desktop-debugging
@desktop-platform
@desktop-platform-devel
@development
@directory-client
@eclipse
@fonts
@general-desktop
@graphical-admin-tools
@hardware-monitoring
@input-methods
@java-platform
@kde-desktop
@large-systems
@legacy-x
@network-file-system-client
@performance
@perl-runtime
@remote-desktop-clients
@server-platform
@server-platform-devel
@server-policy
@x11
httpd-devel
pcre-devel
libcap-devel
libXinerama-devel
openmotif-devel
net-snmp-devel
libgudev1-devel
kdelibs-apidocs
xz-devel
libtopology-devel
kdegraphics-devel
libibverbs-devel
libuuid-devel
kdepimlibs-devel
libblkid-devel
papi-devel
libXmu-devel
unique-devel
xorg-x11-proto-devel
gmp-devel
kdepim-devel
sane-backends-devel
perl-Test-Pod
kdemultimedia-devel
startup-notification-devel
libudev-devel
cups-devel
gstreamer-plugins-base-devel
unixODBC-devel
tcl-devel
numactl-devel
libgnomeui-devel
libbonobo-devel
perl-Test-Pod-Coverage
libtiff-devel
junit
SDL-devel
libXau-devel
tcp_wrappers-devel
PyQt4-devel
kdenetwork-devel
kdelibs-devel
libgcrypt-devel
popt-devel
libusb-devel
hunspell-devel
iptables-devel
libdrm-devel
libXrandr-devel
libxslt-devel
kdebase-devel
tk-devel
libnl-devel
libXpm-devel
expat-devel
e2fsprogs-devel
kdebase-workspace-devel
libglade2-devel
libaio-devel
gnutls-devel
kdesdk-devel
fuse-devel
libXaw-devel
libhugetlbfs-devel
mtools
pax
python-dmidecode
oddjob
squashfs-tools
sgpio
genisoimage
wodim
sabayon-apply
control-center-extra
xguest
tigervnc-server
oprofile-gui
abrt-gui
xrestop
systemtap-grapher
bltk
qt-mysql
qt3-ODBC
qt-odbc
qt-postgresql
qt3-PostgreSQL
qt3-MySQL
kdesdk
gnome-common
qt-doc
gtk2-devel-docs
glade3
desktop-file-utils
gnome-devel-docs
systemtap-sdt-devel
mod_dav_svn
ElectricFence
ant
libstdc++-docs
gcc-gnat
expect
dejagnu
perltidy
cmake
imake
babel
rpmdevtools
compat-gcc-34
systemtap-server
gcc-java
compat-gcc-34-g77
jpackage-utils
bzr
mercurial
chrpath
gcc-objc
rpmlint
gcc-objc++
compat-gcc-34-c++
python-docs
nasm
certmonger
pam_krb5
krb5-workstation
nscd
pam_ldap
nss-pam-ldapd
eclipse-mylyn-cdt
eclipse-pde
eclipse-mylyn-pde
eclipse-mylyn-wikitext
eclipse-mylyn-trac
eclipse-subclipse-graph
eclipse-mylyn-webtasks
cjkuni-fonts-ghostscript
bitmap-fixed-fonts
bitmap-lucida-typewriter-fonts
krb5-auth-dialog
gnome-pilot-conduits
gconf-editor
dvgrab
alacarte
seahorse-plugins
rhythmbox-upnp
gnome-games
gedit-plugins
gnome-pilot
totem-upnp
vim-X11
sabayon
system-config-lvm
audit-viewer
setroubleshoot
firstaidkit-gui
system-config-kickstart
policycoreutils-gui
kdebase-workspace-akonadi
kdebase-workspace-python-applet
xorg-x11-twm
openmotif
xorg-x11-fonts-ISO8859-1-75dpi
xterm
xorg-x11-fonts-cyrillic
xorg-x11-xdm
xorg-x11-fonts-ISO8859-9-100dpi
xorg-x11-fonts-ISO8859-14-100dpi
xorg-x11-fonts-75dpi
xorg-x11-fonts-ISO8859-9-75dpi
libXmu
xorg-x11-fonts-ISO8859-15-75dpi
libXp
openmotif22
xorg-x11-fonts-ISO8859-14-75dpi
xorg-x11-fonts-ISO8859-2-75dpi
xorg-x11-fonts-ethiopic
xorg-x11-fonts-ISO8859-2-100dpi
papi
perl-DBD-SQLite
spice-xpi
tsclient
rdesktop
vinagre
tigervnc
spice-client
wacomcpl
%end " > /var/ftp/ks.cfg
chmod 777 /var/ftp/ks.cfg
# 要注意權限問題 免得Client無法下載ks.cfg
--
Tags:
Linux
All Comments

By Gary
at 2011-08-18T00:38
at 2011-08-18T00:38

By Faithe
at 2011-08-19T01:53
at 2011-08-19T01:53

By Hedda
at 2011-08-19T23:43
at 2011-08-19T23:43

By James
at 2011-08-24T05:15
at 2011-08-24T05:15
Related Posts
在xp系統下再灌linux,grub進不了xp?

By Liam
at 2011-08-12T23:50
at 2011-08-12T23:50
NIS問題 fedora14

By Candice
at 2011-08-12T14:02
at 2011-08-12T14:02
Ubuntu 中文顯示

By Hamiltion
at 2011-08-12T04:18
at 2011-08-12T04:18
Embedded Linux技術研討會-Kernel ARP實作 / ARP Spoofing

By Dinah
at 2011-08-11T23:49
at 2011-08-11T23:49
給入門新手的Stardict字典檔及發音檔安 …

By Dinah
at 2011-08-11T22:11
at 2011-08-11T22:11