본문 바로가기
【Fundamental Tech】/Linux

Grub2 PXE Boot UEFI MAC address based configuration

반응형

Grub config for MAC based include since grub feature_net_search_cfg is documented but not implemented :(

(https://www.gnu.org/software/grub/manual/grub/grub.html#Network)

 

My grub.cfg currently looks like this: 

set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
set gfxpayload=keep
insmod all_video

#if $grub_platform = efi ; then
#  eval "set net_pxe_mac=\$net_${efi_boot_interface}_mac" 
#fi
set net_pxe_mac=$net_default_mac

regexp --set=1:m1 --set=2:m2 --set=3:m3 --set=4:m4 --set=5:m5 --set=6:m6  
'^([0-9a-f]{1,2})\:([0-9a-f]{1,2})\:([0-9a-f]{1,2})\:([0-9a-f]{1,2})\:([0-9a-f]{1,2})\:([0-9a-f]{1,2})'
 "$net_default_mac"

mac=${m1}-${m2}-${m3}-${m4}-${m5}-${m6}

configfile=/cfg/mac/$net_pxe_mac
source "$configfile"

configfile=$prefix/grub.cfg-$mac
source "$configfile"

ip=$net_default_ip

for c in 1 2 3 4; do
configfile=$prefix/grub.cfg-$ip
source "$configfile"
regexp --set=ip '^(.*)\..+$' "$ip"
done

 

반응형