3.5. Verifying the Initial RAM Disk Image

The job of the initial RAM disk image is to preload the block device modules, such as for IDE, SCSI or RAID, so that the root file system, on which those modules normally reside, can then be accessed and mounted. On Red Hat Enterprise Linux 7 systems, whenever a new kernel is installed using either the Yum, PackageKit, or RPM package manager, the Dracut utility is always called by the installation scripts to create an initramfs (initial RAM disk image).
If you make changes to the kernel attributes by modifying the /etc/sysctl.conf file or another sysctl configuration file, and if the changed settings are used early in the boot process, then rebuilding the Initial RAM Disk Image by running the dracut -f command might be necessary. An example is if you have made changes related to networking and are booting from network-attached storage.
On all architectures other than IBM eServer System i (see Section 3.5, “Verifying the Initial RAM Disk Image and Kernel on IBM eServer System i”), you can create an initramfs by running the dracut command. However, you usually don't need to create an initramfs manually: this step is automatically performed if the kernel and its associated packages are installed or upgraded from RPM packages distributed by Red Hat.
You can verify that an initramfs corresponding to your current kernel version exists and is specified correctly in the grub.cfg configuration file by following this procedure:

Procedure 3.1. Verifying the Initial RAM Disk Image

  1. As root, list the contents in the /boot directory and find the kernel (vmlinuz-kernel_version) and initramfs-kernel_version with the latest (most recent) version number:

    Example 3.1. Ensuring that the kernel and initramfs versions match

    ls /boot
    config-3.10.0-67.el7.x86_64
    config-3.10.0-78.el7.x86_64
    efi
    grub
    grub2
    initramfs-0-rescue-07f43f20a54c4ce8ada8b70d33fd001c.img
    initramfs-3.10.0-67.el7.x86_64.img
    initramfs-3.10.0-67.el7.x86_64kdump.img
    initramfs-3.10.0-78.el7.x86_64.img
    initramfs-3.10.0-78.el7.x86_64kdump.img
    initrd-plymouth.img
    symvers-3.10.0-67.el7.x86_64.gz
    symvers-3.10.0-78.el7.x86_64.gz
    System.map-3.10.0-67.el7.x86_64
    System.map-3.10.0-78.el7.x86_64
    vmlinuz-0-rescue-07f43f20a54c4ce8ada8b70d33fd001c
    vmlinuz-3.10.0-67.el7.x86_64
    vmlinuz-3.10.0-78.el7.x86_64
    • we have three kernels installed (or, more correctly, three kernel files are present in the /boot directory),
    • the latest kernel is vmlinuz-3.10.0-78.el7.x86_64, and
    • an initramfs file matching our kernel version, initramfs-3.10.0-78.el7.x86_64kdump.img, also exists.

    Important

    In the /boot directory you might find several initramfs-kernel_versionkdump.img files. These are special files created by the Kdump mechanism for kernel debugging purposes, are not used to boot the system, and can safely be ignored. For more information on kdump, see the Red Hat Enterprise Linux 7 Kernel Crash Dump Guide.
  2. If your initramfs-kernel_version file does not match the version of the latest kernel in the /boot directory, or, in certain other situations, you might need to generate an initramfs file with the Dracut utility. Simply invoking dracut as root without options causes it to generate an initramfs file in /boot for the latest kernel present in that directory:
    dracut
    You must use the -f, --force option if you want dracut to overwrite an existing initramfs (for example, if your initramfs has become corrupt). Otherwise dracut will refuse to overwrite the existing initramfs file:
    dracut
              Will not override existing initramfs (/boot/initramfs-3.10.0-78.el7.x86_64.img) without --force
    You can create an initramfs in the current directory by calling dracut initramfs_name kernel_version :
    dracut "initramfs-$(uname -r).img" $(uname -r)
    If you need to specify specific kernel modules to be preloaded, add the names of those modules (minus any file name suffixes such as .ko) inside the parentheses of the add_dracutmodules+="module [more_modules ]" directive of the /etc/dracut.conf configuration file. You can list the file contents of an initramfs image file created by dracut by using the lsinitrd initramfs_file command:
    lsinitrd /boot/initramfs-3.10.0-78.el7.x86_64.img
    Image: /boot/initramfs-3.10.0-78.el7.x86_64.img: 11M
    ========================================================================
    dracut-033-68.el7
    ========================================================================
    
    drwxr-xr-x  12 root     root            0 Feb  5 06:35 .
    drwxr-xr-x   2 root     root            0 Feb  5 06:35 proc
    lrwxrwxrwx   1 root     root           24 Feb  5 06:35 init -> /usr/lib/systemd/systemd
    drwxr-xr-x  10 root     root            0 Feb  5 06:35 etc
    drwxr-xr-x   2 root     root            0 Feb  5 06:35 usr/lib/modprobe.d
    [output truncated]
    See man dracut and man dracut.conf for more information on options and usage.
  3. Examine the /boot/grub2/grub.cfg configuration file to ensure that an initramfs-kernel_version.img file exists for the kernel version you are booting. For example:
    grep initramfs /boot/grub2/grub.cfg
    initrd16 /initramfs-3.10.0-123.el7.x86_64.img
    initrd16 /initramfs-0-rescue-6d547dbfd01c46f6a4c1baa8c4743f57.img

Verifying the Initial RAM Disk Image and Kernel on IBM eServer System i

On IBM eServer System i machines, the initial RAM disk and kernel files are combined into a single file, which is created with the addRamDisk command. This step is performed automatically if the kernel and its associated packages are installed or upgraded from the RPM packages distributed by Red Hat; thus, it does not need to be executed manually. To verify that it was created, run the following command as root to make sure the /boot/vmlinitrd-kernel_version file already exists:
ls -l /boot/
The kernel_version should match the version of the kernel just installed.

Reversing the Changes Made to the Initial RAM Disk Image

In some cases, for example, if you misconfigure the system and it no longer boots, you may need to reverse the changes made to the Initial RAM Disk Image by following this procedure:

Procedure 3.2. Reversing Changes Made to the Initial RAM Disk Image

  1. Reboot the system choosing the rescue kernel in the GRUB menu.
  2. Change the incorrect setting that caused the initramfs to malfunction.
  3. Recreate the initramfs with the correct settings by running the following command as root:
    dracut --kver kernel_version --force
The above procedure might be useful if, for example, you incorrectly set the vm.nr_hugepages in the sysctl.conf file. Because the sysctl.conf file is included in initramfs, the new vm.nr_hugepages setting gets applied in initramfs and causes rebuilding of the initramfs. However, because the setting is incorrect, the new initramfs is broken and the newly built kernel does not boot, which necessitates correcting the setting using the above procedure.

Listing the Contents of the Initial RAM Disk Image

To list the files that are included in the initramfs, run the following command as root:
lsinitrd
To only list files in the /etc directory, use the following command:
lsinitrd | grep etc/
To output the contents of a specific file stored in the initramfs for the current kernel, use the -f option:
lsinitrd -f filename
For example, to output the contents of sysctl.conf, use the following command:
lsinitrd -f /etc/sysctl.conf
To specify a kernel version, use the --kver option:
lsinitrd --kver kernel_version -f /etc/sysctl.conf
For example, to list the information about kernel version 3.10.0-327.10.1.el7.x86_64, use the following command:
lsinitrd --kver 3.10.0-327.10.1.el7.x86_64 -f /etc/sysctl.conf