improve handling of kernel modules
This commit is contained in:
parent
95162c581c
commit
99d46a0ac2
@ -8,17 +8,19 @@ cd build
|
|||||||
echo_blue "Starting installation at $ROOT."
|
echo_blue "Starting installation at $ROOT."
|
||||||
create_dirs
|
create_dirs
|
||||||
|
|
||||||
echo_blue "Adding kernel binaries..."
|
echo_blue "Adding binaries and libs..."
|
||||||
install_busybox
|
|
||||||
install_binary $(which modprobe)
|
|
||||||
install_binary $(which switch_root)
|
install_binary $(which switch_root)
|
||||||
install_binary $(which bash)
|
install_binary $(which bash)
|
||||||
|
install_binary $(which mount)
|
||||||
|
install_kmod
|
||||||
|
install_busybox
|
||||||
|
|
||||||
echo_blue "Adding scripts..."
|
echo_blue "Adding scripts..."
|
||||||
install_init_script
|
install_init_script
|
||||||
|
|
||||||
echo_blue "Adding kernel modules..."
|
echo_blue "Adding kernel modules..."
|
||||||
install_module "$(df -T / | awk '{ print $2 }' | tail -1)"
|
install_module "$(df -T / | awk '{ print $2 }' | tail -1)"
|
||||||
|
install_module btrfs
|
||||||
install_module msr
|
install_module msr
|
||||||
install_module sev-guest
|
install_module sev-guest
|
||||||
install_module dm_crypt
|
install_module dm_crypt
|
||||||
|
@ -63,6 +63,17 @@ install_binary() {
|
|||||||
done <<< "$( echo "$ldd_deps" | grep -F ' => ' | awk '{ print $3 }' )"
|
done <<< "$( echo "$ldd_deps" | grep -F ' => ' | awk '{ print $3 }' )"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install_kmod() {
|
||||||
|
echo_blue "Installing kmod (depmod, insmod, lsmod, modinfo, modprobe, rmmod)..."
|
||||||
|
install_binary /usr/bin/kmod || return 1
|
||||||
|
ln -s kmod ${ROOT}/usr/bin/lsmod
|
||||||
|
ln -s kmod ${ROOT}/usr/bin/rmmod
|
||||||
|
ln -s kmod ${ROOT}/usr/bin/insmod
|
||||||
|
ln -s kmod ${ROOT}/usr/bin/modinfo
|
||||||
|
ln -s kmod ${ROOT}/usr/bin/modprobe
|
||||||
|
ln -s kmod ${ROOT}/usr/bin/depmod
|
||||||
|
}
|
||||||
|
|
||||||
install_busybox() {
|
install_busybox() {
|
||||||
echo_blue "Installing busybox..."
|
echo_blue "Installing busybox..."
|
||||||
[[ -f "$BUSYBOX_PATH" ]] || {
|
[[ -f "$BUSYBOX_PATH" ]] || {
|
||||||
@ -82,21 +93,32 @@ install_init_script() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
install_module() {
|
install_module() {
|
||||||
local module="$1" depends='' dep='' filename=''
|
local module="$1"
|
||||||
filename="$( modinfo -k $KERNEL $module | grep '^filename:' | awk '{ print $2 }' )"
|
echo "modprobe $module" >> "${ROOT}/load_modules.sh.tmp"
|
||||||
[[ "$filename" == "(builtin)" ]] && {
|
_install_module "$module"
|
||||||
|
}
|
||||||
|
|
||||||
|
_install_module() {
|
||||||
|
local module="$1" depends='' dep='' filename='' filenames=''
|
||||||
|
filenames="$( modinfo -k $KERNEL $module | grep '^filename:' | awk '{ print $2 }' )"
|
||||||
|
[[ "$filenames" == "(builtin)" ]] && {
|
||||||
echo_yellow "Module $module is builtin. Installation not needed."
|
echo_yellow "Module $module is builtin. Installation not needed."
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
install_dep "$filename"
|
while read -r filename; do
|
||||||
echo "insmod $filename" >> "${ROOT}/load_modules.sh"
|
[[ -z $filename ]] && continue
|
||||||
|
install_dep "$filename"
|
||||||
|
done <<< "$( echo "$filenames" )"
|
||||||
|
|
||||||
depends="$(modinfo -k $KERNEL $module |
|
depends="$( \
|
||||||
grep '^depends:' | awk '{ print $2 }' | sed 's/,/\n/g')"
|
modinfo -k $KERNEL $module |
|
||||||
|
grep '^depends:' | awk '{ print $2 }' | sed 's/,/\n/g';
|
||||||
|
modinfo -k $KERNEL $module | grep '^softdep:' | awk '{ print $3 }'
|
||||||
|
)"
|
||||||
while read -r dep; do
|
while read -r dep; do
|
||||||
[[ -z $dep ]] && continue
|
[[ -z $dep ]] && continue
|
||||||
install_module "$dep"
|
_install_module "$dep"
|
||||||
done <<< "$( echo "$depends" )"
|
done <<< "$( echo "$depends" )"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +128,8 @@ create_archive() {
|
|||||||
echo $archive > .archive_name
|
echo $archive > .archive_name
|
||||||
my_location="$(pwd)"
|
my_location="$(pwd)"
|
||||||
cd ${ROOT}
|
cd ${ROOT}
|
||||||
find . | cpio -o -H newc | gzip > "${my_location}/detee-$(hostnamectl hostname)-${KERNEL}.cpio.gz"
|
find . | cpio -o -H newc | gzip \
|
||||||
|
> "${my_location}/detee-$(hostnamectl hostname)-${KERNEL}.cpio.gz"
|
||||||
|
|
||||||
cd $my_location
|
cd $my_location
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ echo_red() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
load_modules() {
|
load_modules() {
|
||||||
cat /load_modules.sh | sort -u | bash
|
cat /load_modules.sh | bash
|
||||||
}
|
}
|
||||||
|
|
||||||
create_mounts() {
|
create_mounts() {
|
||||||
@ -34,5 +34,6 @@ create_mounts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mount_root() {
|
mount_root() {
|
||||||
|
mkdir /mnt
|
||||||
mount /dev/vda3 /mnt
|
mount /dev/vda3 /mnt
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user