Add required hook functions to netboot boot script
Initramfs-tools boot scripts must provide hook functions (netboot_top, netboot_premount, netboot_bottom) and mount wrappers (mount_top, mount_premount, mount_bottom) for the init script to call them properly. Without these, the init script doesn't recognize netboot as a valid boot method and falls back to trying /dev/root, causing "cannot open block device" errors.
This commit is contained in:
@@ -7,6 +7,38 @@ export PATH=/usr/bin:/usr/sbin:/bin:/sbin
|
||||
MOUNTPOINT=/root
|
||||
TMPFS_MOUNT=/mnt
|
||||
|
||||
# Hook functions for initramfs-tools boot script integration
|
||||
netboot_top()
|
||||
{
|
||||
if [ "${netboot_top_used}" != "yes" ]; then
|
||||
[ "${quiet?}" != "y" ] && log_begin_msg "Running /scripts/netboot-top"
|
||||
run_scripts /scripts/netboot-top
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
fi
|
||||
netboot_top_used=yes
|
||||
}
|
||||
|
||||
netboot_premount()
|
||||
{
|
||||
if [ "${netboot_premount_used}" != "yes" ]; then
|
||||
[ "${quiet?}" != "y" ] && log_begin_msg "Running /scripts/netboot-premount"
|
||||
run_scripts /scripts/netboot-premount
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
fi
|
||||
netboot_premount_used=yes
|
||||
}
|
||||
|
||||
netboot_bottom()
|
||||
{
|
||||
if [ "${netboot_premount_used}" = "yes" ] || [ "${netboot_top_used}" = "yes" ]; then
|
||||
[ "${quiet?}" != "y" ] && log_begin_msg "Running /scripts/netboot-bottom"
|
||||
run_scripts /scripts/netboot-bottom
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
fi
|
||||
netboot_premount_used=no
|
||||
netboot_top_used=no
|
||||
}
|
||||
|
||||
# Parse kernel command line for HTTP root
|
||||
parse_cmdline() {
|
||||
for x in $(cat /proc/cmdline); do
|
||||
@@ -27,6 +59,11 @@ parse_cmdline() {
|
||||
|
||||
mountroot() {
|
||||
rc=1
|
||||
|
||||
# Run hook scripts
|
||||
netboot_top
|
||||
netboot_premount
|
||||
|
||||
parse_cmdline
|
||||
|
||||
if test -z "${ROOT_URL}"; then
|
||||
@@ -145,3 +182,19 @@ mountroot() {
|
||||
|
||||
return ${rc}
|
||||
}
|
||||
|
||||
# Standard mount hook wrappers expected by initramfs init
|
||||
mount_top()
|
||||
{
|
||||
netboot_top
|
||||
}
|
||||
|
||||
mount_premount()
|
||||
{
|
||||
netboot_premount
|
||||
}
|
||||
|
||||
mount_bottom()
|
||||
{
|
||||
netboot_bottom
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user