About loader.4th and mac / ip based loader.conf 's

May 23, 2006 09:45

Dear All,



The following solution is pretty good if you have a pxe environment with a lot of freebsd, but with different hardware, kernels & configs. With this method you can have a true loader.conf based on the dhcp.host-name variable in the pxeboot loader(8). (Or IP, MAC, whatever).

If a diskless machine boots with pxe, it will ask the dhcp server for some information. Then it will try to load the following files in this order:

/boot/loader.rc
/boot/loader.4th
/boot/support.4th
/boot/defaults/loader.conf
/boot/loader.conf
/boot/loader.conf.local
/loader.conf.d/webservers1.rc
/loader.conf.d/webservers1.conf

The last 2 files are for you to modify. This way you have full control over the boot process.

use the following /boot/loader.rc

include /boot/loader.4th

echo Configuring for Group: ${dhcp.host-name} / IP: ${boot.netif.ip} / MAC: ${boot.netif.hwaddr}

only forth also support-functions definitions

: initialize_name ( addr len -- )
strdup conf_files .len ! conf_files .addr !
;

: customstart
s" /boot/defaults/loader.conf" initialize include_conf_files
s" include /loader.conf.d/${dhcp.host-name}.rc" ['] evaluate catch
any_conf_read? if
load_kernel
load_modules
then
;

customstart

in my case a group of servers has 'dhcp.host-name' "webservers1"

/loader.conf.d/webservers1.rc

s" /loader.conf.d/webservers1.conf" initialize_name include_conf_files

/loader.conf.d/webservers1.conf

rootfs_load="YES"
rootfs_type="mfs_root"
rootfs_name="/rootfs/webservers1-mfsroot"

autoboot_delay=3

hint.sc.0.at="isa"
hint.sc.0.flags="0x100"
hint.vga.0.at="isa"
hint.acpi.0.disabled="1"

vfs.root.mountfrom="ufs:/dev/md0"

Much cooler would be if anybody who's good at 4th/ficl could modify loader.4th/support.4th so you can have loader(8) environment variables in the builtin-like commands loader.4th provides. something like: loader_conf_files="/loader.conf.d/${boot.netif.hwaddr}.conf" in /boot/loader.conf. Maybe one day....

Previous post Next post
Up