hostonly mode support

This commit is contained in:
illiliti 2020-02-05 16:35:17 +03:00
parent 716aef47ee
commit 340cf9ff52
2 changed files with 27 additions and 16 deletions

3
config
View File

@ -20,6 +20,9 @@ root="UUID=07729c48-25d8-4096-acaf-ce5322915680"
# device manager ( mdev,mdevd,udev ) # device manager ( mdev,mdevd,udev )
devmgr="mdev" devmgr="mdev"
# hostonly mode
#hostonly=1
# drivers # drivers
#drivers="" #drivers=""

View File

@ -123,19 +123,27 @@ install_luks() {
# install drivers # install drivers
install_drivers() { install_drivers() {
modker="${moddir}${kernel}" modker="${moddir}${kernel}"
find \ if [ "$hostonly" = 1 ]; then
"${modker}/kernel/drivers/virtio" \ for modalias in $(find /sys/devices -name modalias -exec sort -u "{}" "+"); do
"${modker}/kernel/arch" \ for driver in $(modprobe -D $modalias 2>/dev/null | cut -d " " -f 2); do
"${modker}/kernel/crypto" \ install -Dm644 "$driver" "${tmpdir}${driver}"
"${modker}/kernel/fs" \ done
"${modker}/kernel/lib" \ done
"${modker}/kernel/drivers/block" \ else
"${modker}/kernel/drivers/ata" \ find \
"${modker}/kernel/drivers/md" \ "${modker}/kernel/drivers/virtio" \
"${modker}/kernel/drivers/scsi" \ "${modker}/kernel/arch" \
"${modker}/kernel/drivers/usb/storage" \ "${modker}/kernel/crypto" \
"${modker}/kernel/drivers/usb/host" \ "${modker}/kernel/fs" \
-type f | cpio -pd "$tmpdir" >/dev/null 2>&1 "${modker}/kernel/lib" \
"${modker}/kernel/drivers/block" \
"${modker}/kernel/drivers/ata" \
"${modker}/kernel/drivers/md" \
"${modker}/kernel/drivers/scsi" \
"${modker}/kernel/drivers/usb/storage" \
"${modker}/kernel/drivers/usb/host" \
-type f | cpio -pd "$tmpdir" >/dev/null 2>&1
fi
# install list of drivers # install list of drivers
cp "${modker}/modules.softdep" "${modker}/modules.builtin" "${modker}/modules.order" "${tmpdir}/${modker}" cp "${modker}/modules.softdep" "${modker}/modules.builtin" "${modker}/modules.order" "${tmpdir}/${modker}"
@ -249,6 +257,9 @@ create_initramfs() {
# check root # check root
[ "$(id -u)" = 0 ] || panic "must be run as root" [ "$(id -u)" = 0 ] || panic "must be run as root"
# remove tmpdir on exit or unexpected error
trap remove_tmpdir EXIT INT
check_currentdir check_currentdir
# source config # source config
@ -262,9 +273,6 @@ check_currentdir
trap : EXIT INT trap : EXIT INT
} }
# remove tmpdir on exit or unexpected error
trap remove_tmpdir EXIT INT
# variables # variables
tmpdir="$(mktemp -d /tmp/initramfs.XXXXXXXX)" || panic "failed to create working directory" tmpdir="$(mktemp -d /tmp/initramfs.XXXXXXXX)" || panic "failed to create working directory"
kernel="$(uname -r)" kernel="$(uname -r)"