diff --git a/config b/config index 61ac384..ea318c7 100644 --- a/config +++ b/config @@ -20,6 +20,9 @@ root="UUID=07729c48-25d8-4096-acaf-ce5322915680" # device manager ( mdev,mdevd,udev ) devmgr="mdev" +# hostonly mode +#hostonly=1 + # drivers #drivers="" diff --git a/generate b/generate index 7b4883a..9a47f67 100755 --- a/generate +++ b/generate @@ -123,19 +123,27 @@ install_luks() { # install drivers install_drivers() { modker="${moddir}${kernel}" - find \ - "${modker}/kernel/drivers/virtio" \ - "${modker}/kernel/arch" \ - "${modker}/kernel/crypto" \ - "${modker}/kernel/fs" \ - "${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 + 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" \ + "${modker}/kernel/crypto" \ + "${modker}/kernel/fs" \ + "${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 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)"