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 )
devmgr="mdev"
# hostonly mode
#hostonly=1
# drivers
#drivers=""

View File

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