Skip to content

Instantly share code, notes, and snippets.

@chsbuffer
Created August 29, 2024 12:41
Show Gist options
  • Select an option

  • Save chsbuffer/fef63d32980b31016e1ec82f42d92b08 to your computer and use it in GitHub Desktop.

Select an option

Save chsbuffer/fef63d32980b31016e1ec82f42d92b08 to your computer and use it in GitHub Desktop.
directory as root archlinux mkinitcpio hook. why? Because I want to install linux and Windows on same partition.
#!/usr/bin/ash
# this file is at /etc/initcpio/hooks/bedrock
run_hook ()
{
mount_handler="ramdisk_mount_handler"
}
ramdisk_mount_handler ()
{
msg ":: mounting '$root' on dummy root"
mkdir /dummy_root
if ! mount -t "${rootfstype:-auto}" -o "${rwopt:-ro}${rootflags:+,$rootflags}" "$root" "/dummy_root"; then
# shellcheck disable=SC2086
run_hookfunctions 'run_emergencyhook' 'emergency hook' $EMERGENCYHOOKS
err "Failed to mount '$root' on dummy root"
echo "You are now being dropped into an emergency shell."
# shellcheck disable=SC2119
launch_interactive_shell
msg "Trying to continue (this will most likely fail) ..."
fi
msg ":: mounting '/dummy_root/$rootdir' on real root"
if ! mount --bind "/dummy_root/$rootdir" "$1"; then
# shellcheck disable=SC2086
run_hookfunctions 'run_emergencyhook' 'emergency hook' $EMERGENCYHOOKS
err "Failed to mount '$root' on real root"
echo "You are now being dropped into an emergency shell."
# shellcheck disable=SC2119
launch_interactive_shell
msg "Trying to continue (this will most likely fail) ..."
fi
}
#!/usr/bin/env bash
# this file is at /etc/initcpio/install/bedrock
build() {
add_runscript
}
help() {
cat <<HELPEOF
HELPEOF
}
# vim: set ft=sh ts=4 sw=4 et:
@chsbuffer
Copy link
Author

add bedrock to /etc/mkinitcpio.conf HOOKS, rebuild initd sudo mkinitcpio -P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment