mkinitrd

Create an image file to be loaded into the ramdisk

Supplementary instructions

mkinitrd command creates an image file to be loaded into the ramdisk so that the ramdisk can be loaded when Linux boots.

This is a command to repackage the core. For example, if you modify the driver of a device yourself, if this driver is to be added to the core level, you need to repackage the core and compile the newly added configuration into the core!

grammar

mkinitrd(options)(parameters)

Options

-f: If the specified image name is the same as an existing file, the existing file will be overwritten;
-v: Display detailed information during execution;
--omit-scsi-modules: Do not load SCSI modules;
--preload=<module name>: Specify the module to be loaded;
--with=<module name>: Specify the module to be loaded;
--version: Display version information.

Parameters

Example

[root@localhost tmp]# mkinitrd -v -f myinitrd.img $(uname -r)
Creating initramfs
WARNING: using /tmp for temporary files
Looking for deps of module ide-disk
Looking for deps of module ext3 jbd
Looking for deps of module jbd
Using modules: ./kernel/fs/jbd/jbd.ko ./kernel/fs/ext3/ext3.ko
/sbin/nash -> /tmp/initrd.Vz3928/bin/nash
/sbin/insmod.static -> /tmp/initrd.Vz3928/bin/insmod
/sbin/udev.static -> /tmp/initrd.Vz3928/sbin/udev
/etc/udev/udev.conf -> /tmp/initrd.Vz3928/etc/udev/udev.conf
copy from /lib/modules/2.6.9-5.EL/./kernel/fs/jbd/jbd.ko(elf32-i386) to /tmp/initrd.Vz3928/lib/jbd.ko(elf32-i386)
copy from /lib/modules/2.6.9-5.EL/./kernel/fs/ext3/ext3.ko(elf32-i386) to /tmp/initrd.Vz3928/lib/ext3.ko(elf32-i386)
Loading module jbd
Loading module ext3

[root@localhost tmp]# file myinitrd.img
myinitrd.img: gzip compressed data, from Unix, max compression

[root@localhost tmp]# mv myinitrd.img myinitrd.img.gz
[root@localhost tmp]# gzip -d myinitrd.img.gz
[root@localhost tmp]# file myinitrd.img
myinitrd.img: ASCII cpio archive (SVR4 with no CRC)