Load kernel modules as early as possible 01/317201/3 accepted/tizen/unified/20241101.174155 accepted/tizen/unified/x/20241218.032807 accepted/tizen/unified/x/asan/20241224.004530
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 5 Sep 2024 10:37:59 +0000 (12:37 +0200)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 22 Oct 2024 01:17:29 +0000 (01:17 +0000)
This should allow delivering selected filesystems and storage
drivers to be delivered in the form of a module (eg. nbd).

Change-Id: I181e2d9df1da26428fc735383c3dda445ba532a1

data/initrd-file.list
scripts/init.sh

index 8c614f1d8713120d438e9d2856faa4cf7b95bc5e..09889052ef981cc3b6cb6e820c833571d65705b8 100644 (file)
@@ -7,7 +7,7 @@ SYS_SKELDIR="
 /tmp
 /usr/bin
 /usr/sbin
-/usr/lib
+/usr/lib/modules
 /sysroot
 /opt
 /run
index 68f564f45ddf0ce460b93235bf49fb3fc9b2ded7..2b29f759026d912440fc941912cbf0b662c5a89b 100755 (executable)
@@ -13,6 +13,8 @@ ROOTFS_MNT=
 DATAFS_MNT=
 MODULES_MNT=
 
+MODULES_INITRD_MNT=/usr/lib/modules
+
 IN_INITRD=0
 IN_INITRAMFS=0
 NEED_RESIZEFS=1
@@ -386,9 +388,15 @@ function process_modulesfs
 {
     if [ x$MODULES = "x" ]; then return; fi
 
-    /bin/mount -o ro $MODULES $MODULES_MNT
+    /bin/mount -o ro $MODULES $MODULES_INITRD_MNT
 }
 
+function move_modulesfs
+{
+    if [ x$MODULES = "x" ]; then return; fi
+
+    /bin/mount --move $MODULES_INITRD_MNT $MODULES_MNT
+}
 
 function process_userfs()
 {
@@ -441,11 +449,7 @@ function load_kernel_modules
 {
     echo "Load kernel modules"
 
-    # module conf file doest not exist
-    config_cnt=$(/bin/find $MODULES_MNT/modules-load.d -name "*.conf" 2> /dev/null | /bin/wc -l)
-    if [ $config_cnt = 0 ]; then return; fi
-
-    for conf in $MODULES_MNT/modules-load.d/*.conf
+    for conf in $(compgen -G $MODULES_INITRD_MNT"/modules-load.d/*.conf")
     do
         echo "Read module conf: $conf"
         while read module
@@ -455,7 +459,7 @@ function load_kernel_modules
             if [ "${module:0:1}" = "#" ]; then continue; fi  # skip # commented line
 
             echo "Loading module: $module"
-            /sbin/modprobe --dirname=$ROOTFS_MNT --config=${ROOTFS_MNT}/lib/modules/modprobe.d $module &
+            /sbin/modprobe $module &
         done < $conf
     done
 
@@ -537,22 +541,24 @@ else
 fi
 
 print_boot_info
+wait_find_partitions
+
+process_modulesfs
+load_kernel_modules
 
 check_network
 setup_nbd
-wait_find_partitions
 restore_partitions
 check_flags
 check_bootmode
 
 process_rootfs
 process_datafs
-process_modulesfs
 process_halfs
 process_userfs
+move_modulesfs
 write_resized_flag
 
-load_kernel_modules
 pivot_root
 change_root $@