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
- As
root, list the contents in the/bootdirectory and find the kernel (vmlinuz-kernel_version) andinitramfs-kernel_versionwith the latest (most recent) version number:Example 3.1. Ensuring that the kernel and initramfs versions match
#
ls /bootconfig-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
/bootdirectory), - the latest kernel is
vmlinuz-3.10.0-78.el7.x86_64, and - an
initramfsfile matching our kernel version,initramfs-3.10.0-78.el7.x86_64kdump.img, also exists.
Important
In the/bootdirectory you might find severalinitramfs-kernel_versionkdump.imgfiles. 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 onkdump, see the Red Hat Enterprise Linux 7 Kernel Crash Dump Guide. - If your
initramfs-kernel_versionfile does not match the version of the latest kernel in the/bootdirectory, or, in certain other situations, you might need to generate aninitramfsfile with the Dracut utility. Simply invokingdracutasrootwithout options causes it to generate aninitramfsfile in/bootfor the latest kernel present in that directory:#
dracutYou must use the-f,--forceoption if you wantdracutto overwrite an existinginitramfs(for example, if yourinitramfshas become corrupt). Otherwisedracutwill refuse to overwrite the existinginitramfsfile:#
dracutWill not override existing initramfs (/boot/initramfs-3.10.0-78.el7.x86_64.img) without --forceYou can create an initramfs in the current directory by callingdracut 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 theadd_dracutmodules+="module [more_modules ]"directive of the/etc/dracut.confconfiguration file. You can list the file contents of aninitramfsimage file created by dracut by using thelsinitrd initramfs_filecommand:#
lsinitrd /boot/initramfs-3.10.0-78.el7.x86_64.imgImage: /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]Seeman dracutandman dracut.conffor more information on options and usage. - Examine the
/boot/grub2/grub.cfgconfiguration file to ensure that anfile exists for the kernel version you are booting. For example:initramfs-kernel_version.img#
grep initramfs /boot/grub2/grub.cfginitrd16 /initramfs-3.10.0-123.el7.x86_64.img initrd16 /initramfs-0-rescue-6d547dbfd01c46f6a4c1baa8c4743f57.imgSee Section 3.6, “Verifying the Boot Loader” for more information.
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
- Reboot the system choosing the rescue kernel in the GRUB menu.
- Change the incorrect setting that caused the
initramfsto malfunction. - Recreate the
initramfswith 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