From 791d6d9dd94174b2b399613e3f4c832a1d71f269 Mon Sep 17 00:00:00 2001 From: Shengwen Cheng Date: Sun, 16 Jun 2024 15:48:51 +0800 Subject: [PATCH] Add initrd script for packing virtio-gpu related files --- scripts/initrd-image.sh | 29 +++++++++++++++++++++++++++++ target/run.sh | 15 +++++++++++++++ 2 files changed, 44 insertions(+) create mode 100755 scripts/initrd-image.sh create mode 100755 target/run.sh diff --git a/scripts/initrd-image.sh b/scripts/initrd-image.sh new file mode 100755 index 0000000..50cd481 --- /dev/null +++ b/scripts/initrd-image.sh @@ -0,0 +1,29 @@ +#!/usr/bin/bash + +IMG=ext4.img +KERNEL_VER=$(git -C linux/ tag | sed "s/^v//") +SRC=linux/out/lib/modules/$KERNEL_VER +DEST=rootfs/lib/modules/$KERNEL_VER + +# Add path of kernel modules to load with dependency file, for example: +# for example: +# FILES='kernel/drivers/gpu/drm/drm.ko +# modules.dep' +FILES='' + +for file in $FILES; do + mkdir -p `dirname $DEST/$file` + cp -f $SRC/$file $DEST/$file +done + +cp -r directfb rootfs +cp target/run.sh rootfs + +# DirectFB-example requires ~60MiB of space +dd if=/dev/zero of=${IMG} bs=4k count=20000 +mkfs.ext4 -F ${IMG} -d rootfs + +rm -rf rootfs + +# show image size +du -h ${IMG} diff --git a/target/run.sh b/target/run.sh new file mode 100755 index 0000000..fad3dd3 --- /dev/null +++ b/target/run.sh @@ -0,0 +1,15 @@ +#!/usr/bin/bash + +# Install kernel modules +if [ -d "/lib/modules/" ]; then + mkdir -p /lib/modules/ + cp -r ./lib/modules/* /lib/modules/ +fi + +# Install DirectFB and examples +cp -r ./usr/local /usr/ +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib +export PATH=$PATH:/usr/local/bin/ + +# Load kernel modules if exists +# modprobe virtio-gpu