#2724 Issue closed
: pxe boot with grub (from iso or plain)¶
Labels: enhancement
, needs sponsorship
, no-issue-activity
DEvil0000 opened issue at 2021-12-08 10:25:¶
- ReaR configuration files ("cat /etc/rear/site.conf" and/or "cat
/etc/rear/local.conf"):
PXE config expected to support grub bootloader (and maybe ISO targets) in the future:
OUTPUT=PXE
OUTPUT_PREFIX_PXE=$HOSTNAME
PXE_TFTP_PREFIX=$HOSTNAME.
#OUTPUT_URL=tftpbootfs
PXE_TFTP_URL=sshfs://user@172.200.200.1/tmp/test
PXE_CONFIG_URL=sshfs://user@172.200.200.1/tmp/test/
PXE_RECOVER_MODE="manual"
PXE_CREATE_LINKS="IP"
USB_BOOTLOADER=grub
Config used to generate the ISO used in the example later:
OUTPUT=ISO
OUTPUT_URL=sshfs://user@hostname.domain/tftp_path/iso/
ISO_PREFIX="recover-$HOSTNAME"
#just about users
CLONE_USERS=(root)
CLONE_GROUPS=(root)
CLONE_ALL_USERS_GROUPS="false"
- Grub config snippets
grub config for MAC based include since grub feature_net_search_cfg is documented but not implemented :(
(in addition I have a main file including all the others with source)
source /boot/grub/grub.cfg-$net_pxe_mac
grub snippet to boot normally from tftp:
menuentry "Relax-and-Recover PXE" --class gnu-linux --class gnu --class os {
# root=tftp
# prefix=(tftp)/boot/grub
insmod gzio
insmod progress
echo 'Loading kernel ...'
linux /linux/vmlinuz selinux=0
# is serial is used: console=ttyS0,115200
echo 'Loading initial ramdisk ...'
initrd /linux/initrd
}
grub snippet to boot from iso on tftp:
menuentry "Relax-and-Recover PXE ISO" {
# root=tftp
# prefix=(tftp)/boot/grub
echo "booting form network stored iso"
echo "you have to be very patient..."
insmod progress
set isofile="/iso/recover-hostname.iso"
loopback loop $isofile
linux (loop)/isolinux/kernel iso_location=$isofile rw selinux=0
# is serial is used: console=ttyS0,115200
initrd (loop)/isolinux/initrd.cgz
}
- dnsmasq example config:
# DNS port (default 53, disable with 0)
port=0
# Listen only on the specified interface
interface=eth0
# define the dhcp ip range and mode used
# Note: the interface must have IP from this subnet
dhcp-range=tag:red,172.200.200.3,172.200.200.10,12h
# set tags for mac
dhcp-mac=set:red,00:0d:b9:*:*:*
dhcp-mac=set:red,00:13:3b:*:*:*
# allow static dhcp for mac by vender
dhcp-host=00:0d:b9:*:*:*,set:red
dhcp-host=00:13:3b:*:*:*,set:red
# deny unknown clients
dhcp-ignore=tag:!known
# set tags based on arch
dhcp-match=set:bios,option:client-arch,0
dhcp-match=set:efi-x86_64,option:client-arch,7
dhcp-match=set:efi-x86_64,option:client-arch,9
#dhcp-match=set:efi-x86,option:client-arch,6
# assign boot bin path based on tags
dhcp-boot=tag:red,tag:bios,/boot/pxelinux/pxelinux.0
dhcp-boot=tag:red,tag:bios,/boot/grub/i386-pc/booti386.0
dhcp-boot=tag:red,tag:efi-x86_64,/boot/grub/x86_64-efi/bootx64.efi
# promt boot option
pxe-prompt="Press F8 for menu or proceed with default in", 10
# pxe boot options and config path offered
pxe-service=x86PC, "Boot from local disk"
pxe-service=tag:red,tag:bios,x86PC,"pxelinux",/boot/pxelinux/pxelinux
pxe-service=tag:red,tag:bios,x86PC,"grub legacy bios",/boot/grub/i386-pc/booti386
#pxe-service=tag:red,tag:bios,x86PC,"grub legacy bios",/boot/grub/
pxe-service=tag:red,tag:efi-x86_64,X86-64_EFI,"grub efi",/boot/grub/x86_64-efi/bootx64.efi
enable-tftp
tftp-root=/var/lib/tftpboot
log-queries
log-dhcp
#log-facility=/var/log/dnsmasq.log
- grub boot files needed (i386 in the example but works basically the
same with efi on 64bit):
generate bootloader with:
grub-mkimage -d /usr/lib/grub/i386-pc/ -O i386-pc-pxe -o /var/lib/tftpboot/boot/grub/i386-pc/booti386.0 -p '(tftp)/boot/grub' pxe tftp
you may need to copy over the mods by:
cp /usr/lib/grub/i386-pc/* /var/lib/tftpboot/boot/grub/i386-pc
- Description of the issue (ideally so that others can reproduce it):
output=PXE does at the moment only support syslinux and not grub. This
may be fine for most usecases with grub however I am more familier and
you can actually use the shell. Also you get boot from ISO and other
features for free.
At the moment I don't have the time to implement the grub config writing
for PXE but I want to document the needed snippets here so someone else
may do so.
I switched to output=ISO and provide the PXE config from somewhere else
for the moment. That is more convinient and I can use the same ISO no
matter if I actually put it on USB, TFTP or run it over IPMI.
additional notes:
- ISO on USB may replace current output=USB mode but can also used as some kind of RAW with ISO mode.
- grub can also use http (not sure about https) similar to tftp
- I am quite sure tftp/http could also be used in grub config without DHCP/PXE
gdha commented at 2021-12-23 08:55:¶
@DEvil0000 Would be a serious enhancement for Rear for sure. However,
the amount of work to test all different Linux flavors is a nightmare
IMHO.
Nothing prevents you to work on a PR and we would welcome it with open
arms and assist you where we can.
github-actions commented at 2022-02-22 02:10:¶
Stale issue message
[Export of Github issue for rear/rear.]