0
点赞
收藏
分享

微信扫一扫

基于Ubuntu18.04 tftp+apache2+grub搭建PXE系统(EFI模式)

南柯Taylor 2022-12-13 阅读 159

基于Ubuntu18.04 tftp+apache2+grub搭建PXE系统(EFI模式)

apt-get install tftpd-hpa

apt-get install apache2

mkdir /iso

mount -o loop ubuntu-18.04.6-server-amd64.iso /iso

rsync -av --progress /iso/install /var/lib/tftpboot/

rsync -av --progress /iso/boot/grub /var/lib/tftpboot/

mkdir /var/www/html/ks/UBT18046-x86_64 -p

rsync -av --progress /iso/* /var/www/html/ks/UBT18046-x86_64/

apt-get install shim-signed grub-efi-amd64-signed

mkdir -p /var/lib/tftpboot/grub

cp -rv /usr/lib/grub/x86_64-efi-signed/grubnetx64.efi.signed /var/lib/tftpboot/grubx64.efi

cp -rv /usr/lib/shim/shimx64.efi.signed /var/lib/tftpboot/grub/BOOTx64.efi

vi /var/lib/tftpboot/grub/grub.cfg

if loadfont /grub/font.pf2 ; then

        set gfxmode=auto

        insmod efi_gop

        insmod efi_uga

        insmod gfxterm

        terminal_output gfxterm

fi

set menu_color_normal=white/black

set menu_color_highlight=black/light-gray

set timeout=-1 (-1代表需要手动回车,以免正常服务器重启被误重装)

menuentry "Install Ubuntu Server 18.04.6" {

set gfxpayload=keep

linux /install/netboot/ubuntu-installer/amd64/linux netcfg/disable_autoconfig=true netcfg/choose_interface=ens3f0 netcfg/confirm_static=true netcfg/get_ipaddress=10.0.0.3 netcfg/get_netmask=255.255.255.0 netcfg/get_gateway=10.0.0.1 netcfg/get_nameservers=10.0.0.30 netcfg/get_hostname=aa netcfg/get_domain=​​ming.com​​ --- auto=true url=10.0.0.5/ks/preseed/ubt18046.seed quiet

initrd /install/netboot/ubuntu-installer/amd64/initrd.gz

}

:wq!

DHCP设置为grubx64.efi

PXE过程中到配置软件源的时候如果出现Downloading a file failed,可以点击Cancel—Save debug logs—web(查看报错log),如果系统装好了,可以在系统/var/log/installer/syslog看log

ISO里有preseed示例,可以在它基础上修改,/var/www/html/ks/UBT18046-x86_64/doc/install/manual/example-preseed.txt.gz

cp -rv /var/www/html/ks/UBT18046-x86_64/doc/install/manual/example-preseed.txt.gz /var/www/html/ks/UBT18046-x86_64/preseed/

cd /var/www/html/ks/UBT18046-x86_64/preseed/

gunzip example-preseed.txt.gz

mv example-preseed.txt example-preseed.seed

example-preseed.seed内容示例:

d-i debian-installer/local string en_US

d-i console-configuration/layoutcode string de

d-i mirror/country string manual

d-i mirror/http/hostname string 10.0.0.5 (PXE本机ip)

d-i mirror/http/directory string /ks/UBT18046-x86_64

d-i mirror/http/proxy string

d-i passwd/root-login boolean false

d-i passwd/make-user boolean true

#d-i passwd/root-password password xxxxx

#d-i passwd/root-password-again password xxxxx

d-i passwd/user-fullname string ming

d-i passwd/username string ming

d-i passwd/user-password password xxxxx

d-i passwd/user-password-again password xxxxx

#d-i passwd/user-password-crypted password [crypt(3) hash]

d-i user-setup/allow-password-weak boolean true

d-i user-setup/encrypt-home boolean false

d-i passwd/user-default-groups string sudo

d-i clock-setup/utc boolean true d-i time/zone string Asia/Shanghai

d-i clock-setup/ntp boolean true

d-i clock-setup/ntp-server string ​​ntp.ming.com​​​

d-i partman-basicfilesystems/choose_label string gpt

d-i partman-basicfilesystems/default_label string gpt

d-i partman-partitioning/choose_label string gpt

d-i partman-partitioning/default_label string gpt

d-i partman/choose_label string gpt

d-i partman/default_label string gpt

d-i partman-auto/disk string /dev/sda

d-i partman-auto/method string regular

d-i partman-auto/choose_recipe select boot-root

d-i partman-auto/expert_recipe string \

    boot-root :: \

    1024 1024 1024 ext4 \

$primary{ } \

$bootable{ } \

method{ efi } \

format{ } \

mountpoint{ /boot/efi } \

. \

307200 307200 307200 ext4 \

method{ format } \

format{ } \

use_filesystem{ } \

filesystem{ ext4 } \

mountpoint{ / } \

. \

102400 102400 102400 linux-swap \

method{ swap } \

format{ } \

.
d-i partman/default_filesystem string ext4

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 live-installer/net-image string ​​​http://10.0.0.5/ks/UBT18046-x86_64/install/filesystem.squashfs​​​

d-i pkgsel/update-policy select none tasksel tasksel/first multiselect openssh-server

d-i pkgsel/include string wget

d-i grub-installer/only_debian boolean true

d-i grub-installer/with_other_os boolean true

#d-i grub-installer/password password xxxx

#d-i grub-installer/password password-again xxxx

#d-i grub-installer/password password-crypted password xxxx

d-i finish-install/reboot_in_progress note

#d-i preseed/early_comman string xxxx

d-i preseed/late_command string in-target wget -O /opt/keys.sh ​​​http://10.0.0.5/ks/UBT18046-x86_64/preseed/keys.sh​​​; in-target chmod +x /opt/keys.sh; in-target /bin/sh /opt/keys.sh

#d-i preseed/late_command string chroot /target sh -c "wget -O /opt/keys.sh ​​​http://10.0.0.5/ks/UBT18046-x86_64/preseed/keys.sh​​ && chmod +x /opt/keys.sh && /bin/sh /opt/keys.sh"

举报

相关推荐

0 条评论