简体   繁体   中英

Patching and compiling Ext4 as a kernel module

I'm currently patching Ext4 for academic purposes (only linux/fs/ext4/*, like file.c, ioctl.c, ext4.h) . I'm working on the QEMU virtual machine, and to speed up the whole process I've selected Ext4 to compile as a kernel module. The problem occurs when it comes to test new changes, as, even though I run make modules ARCH=x86 && make modules_install ARCH=x86 and reboot the machine (/ is Ext4), they are not visible unless I recompile the whole kernel. It's a little bit weird as I have a variety of signs that the Ext4 has been compiled as a module:

  1. It is configured as that:

     $ grep EXT4 .config CONFIG_EXT4_FS=m 
  2. It does compile as a module:

     $ make modules ARCH=x86 (...) CC [M] fs/ext4/ioctl.o LD [M] fs/ext4/ext4.o Building modules, stage 2. MODPOST 3 modules LD [M] fs/ext4/ext4.ko 
  3. After $ make modules_install ARCH=x86 the files in /lib/modules/3.13.3/kernel/fs/ have proper time stamp.

  4. Finally:

     $ lsmod Module Size Used by ext4 340817 1 (...) 

For some reason I have to do $ make all ARCH=x86 in order to see my changes appear in the runtime. What have I missed? Thanks!

Most boot processes use an "initial ramdisk" ( initrd ) which contains all kernel modules which the kernel needs to load to be able to do anything - after all, to read files from an Ext4 file system, the kernel needs a driver for this file system and if the driver is on said file system, well, ...

So the solution is to pack all those files into an archive (the initial ramdisk) and save the hard disk blocks as a list of numbers in the boot loader. It can then use a primitive IDE/SATA driver to load the blocks directly, extract the drivers and load them.

Check the documentation of your linux distro to find out how to update initrd. On my Ubuntu Linux, it's mkinitramfs .

Related:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM