100% found this document useful (1 vote)
338 views

How To Rebuild The Initial Ramdisk Image in Red Hat Enterprise Linux - Red Hat Customer Portal

Uploaded by

Ahmed M. Soliman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
338 views

How To Rebuild The Initial Ramdisk Image in Red Hat Enterprise Linux - Red Hat Customer Portal

Uploaded by

Ahmed M. Soliman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

6/6/2020 How to rebuild the initial ramdisk image in Red Hat Enterprise Linux - Red Hat Customer Portal

(https://access.redhat.com/)

 Read Red Hat’s business continuity plan (https://www.redhat.com/en/about/here-to-


help/business-continuity) for COVID-19. Have feedback? Let us know 
(https://redhatvoc.co1.qualtrics.com/jfe/form/SV_6rsJsRslhOYK8VD).

How to rebuild the initial ramdisk image in Red Hat


Enterprise Linux
$ SOLUTION VERIFIED - Updated March 16 2020 at 1:38 PM - English ()

Environment
Red Hat Enterprise Linux (RHEL) 3,4,5,6,7
initrd / initramfs image

Issue
How to rebuild the initial ramdisk image in Red Hat Enterprise Linux
How to rebuild initial ram disk image in Red Hat Enterprise Linux
How to remake or recreate the initrd or initramfs
The /etc/lvm/lvm.conf and root file system resides on a logical volume. How to ensure the
changes are applied upon rebooting?
The /etc/multipath.conf and my root file system resides on a multipath device. How to
ensure the changes are applied upon rebooting?
The module options in /etc/modprobe.conf or /etc/modprobe.d/ have been modified. How
to ensure the changes are applied upon rebooting?

Resolution
When adding new hardware to a system, or after changing configuration files that may be used very
early in the boot process, or when changing the options on a kernel module, it may be necessary to
rebuild the initial ramdisk (also known as initrd or initramfs) to include the proper kernel modules,
files, and configuration directives. 
https://access.redhat.com/solutions/1958#initrd 1/8
6/6/2020 How to rebuild the initial ramdisk image in Red Hat Enterprise Linux - Red Hat Customer Portal

If you are adding a new module(https:/


in the initrd, first follow the instructions in How can I ensure certain
/access.redhat.com/)
modules are included in the initrd or initramfs in RHEL? (/knowledge/node/47028), or if it is a 
configuration change then make that change now.

Once the necessary modifications have been made, it is time to rebuild the initrd. This process
differs based on the version of RHEL. In these examples you will see the usage of $(uname -r) ,
which is a way to pass the current kernel version into a command without actually typing it out. If
you are working with a version of the kernel other than what is currently running, then replace
$(uname -r) with the actual kernel version, such as 2.6.18-274.el5 .

1. Rebuilding the initramfs (RHEL 6, 7)


2. Checking initramfs (RHEL 7)
3. Rebuilding the initrd (RHEL 3, 4, 5)
4. Working with backups (RHEL 3, 4, 5, 6)

1. Rebuilding the initramfs (RHEL 6, 7)


It is recommended you make a backup copy of the initramfs in case the new version has an
unexpected problem:

# cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).bak.$(date +%m-%d-%H%M%S).img

Now rebuild the initramfs for the current kernel version:

# dracut -f -v

If you are in a kernel version different to the initrd you are building (including if you are in Rescue
Mode) you must specify the full kernel version, including architecture:

# dracut -f /boot/initramfs-2.6.32-220.7.1.el6.x86_64.img 2.6.32-220.7.1.el6.x86_64


+------------------------ +------------------------
| |
v v
Replace these pieces with the full version of
the kernel you wish to rebuild

2. Checking initramfs (RHEL 7)


In RHEL 7, be certain that the /etc/grub2.cfg and /boot/grub2/grub.cfg includes the menu to
the newly installed or created custom initramfs


https://access.redhat.com/solutions/1958#initrd 2/8
6/6/2020 How to rebuild the initial ramdisk image in Red Hat Enterprise Linux - Red Hat Customer Portal

# grep initrd /etc/grub2.cfg


(https://access.redhat.com/)
initrd16 /initramfs-3.10.0-514.6.1.el7.x86_64.img

initrd16 /initramfs-3.10.0-514.el7.x86_64.img
initrd16 /initramfs-0-rescue-29579289bce743ebbf3d42aa22ebd5fe.img

# grep "menuentry " /boot/grub2/grub.cfg


menuentry 'Red Hat Enterprise Linux Server (3.10.0-514.6.1.el7.x86_64) ...'
menuentry 'Red Hat Enterprise Linux Server (3.10.0-514.el7.x86_64) ... '
menuentry 'Red Hat Enterprise Linux Server (0-rescue-29579289bce743ebbf3d42aa22ebd5fe) ...'

If the customized kernel menu entry does not appear in the grub configuration file(s), rebuild the
grub menu. This rebuild is nominally performed by dracut, but can not be successfully completed in
some corner cases.

How to create a custom menu entry in grub (https://access.redhat.com/solutions/4848251)

Rebuild grub.cfg file after creating the custom menu entry:

On BIOS-based machines, issue the following command as root:

# grub2-mkconfig -o /boot/grub2/grub.cfg

On UEFI-based machines, issue the following command as root:

# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

3. Rebuilding the initrd (RHEL 3, 4, 5)


It is recommended you make a backup copy of the initrd in case the new version has an unexpected
problem:

# cp /boot/initrd-$(uname -r).img /boot/initrd-$(uname -r).bak.$(date +%m-%d-%H%M%S).img

Now build the initrd:

# mkinitrd -f -v /boot/initrd-$(uname -r).img $(uname -r)

The -v verbose flag causes mkinitrd to display the names of all the modules it is including
in the initial ramdisk.
The -f option will force an overwrite of any existing initial ramdisk image at the path you
have specified

https://access.redhat.com/solutions/1958#initrd 3/8
6/6/2020 How to rebuild the initial ramdisk image in Red Hat Enterprise Linux - Red Hat Customer Portal

If you are in a kernel version different to the initrd you are building (including if you are in Rescue
(https://access.redhat.com/)
Mode) you must specify the full kernel version, without architecture: 

# mkinitrd -f -v /boot/initrd-2.6.18-348.2.1.el5.img 2.6.18-348.2.1.el5

4. Working with backups (RHEL 3, 4, 5, 6)


As mentioned previously, it is recommended that you take a backup of the previous initrd in case
something goes wrong with the new one. If desired, it is possible to create a separate entry in
/boot/grub/grub.conf for the backup initial ramdisk image, to conveniently choose the old
version at boot time without needing to restore the backup. This example configuration allows
selection of either the new or old initial ramdisk image from the grub menu:

title Red Hat Enterprise Linux 5 (2.6.18-274.el5)


root (hd0,0)
kernel /vmlinuz-2.6.18-274.el5 ro root=LABEL=/
initrd /initrd-2.6.18-274.el5.img
title Red Hat Enterprise Linux 5 w/ old initrd (2.6.18-274.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-274.el5 ro root=LABEL=/
initrd /initrd-2.6.18-274.el5.bak.MM-DD-HHMMSS.img

Alternatively, you can enter edit-mode in grub if you need to choose the old initrd and did not
make a separate entry in grub.conf before rebooting. To do so:

If grub is secured with a password, press p and enter the password


Use the arrow keys to highlight the entry for the kernel you wish to boot
Press e for edit
Highlight the initrd line and press e again
Change the path for the initrd to the backup copy you made (such as
/initrd-2.6.18-274.el5.bak.01-01-123456.img )
Press Enter to temporarily save the changes you have made
Press b for boot

Note: This procedure does not actually make the change persistent. The next boot will continue to
use the original grub.conf configuration unless it is updated.

Product(s) Red Hat Enterprise Linux (/taxonomy/products/red-hat-enterprise-linux)

Component dracut (/components/dracut) mkinitrd (/components/mkinitrd)

Category Learn more (/category/learn-more) 


https://access.redhat.com/solutions/1958#initrd 4/8
6/6/2020 How to rebuild the initial ramdisk image in Red Hat Enterprise Linux - Red Hat Customer Portal

Tags configuration (/tags/configuration) hardware


(https:/ (/tags/hardware) initrd (/tags/initrd)
/access.redhat.com/)
installation (/tags/installation) 

This solution is part of Red Hat’s fast-track publication program, providing a huge library of
solutions that Red Hat engineers have created while supporting our customers. To give you the
knowledge you need the instant it becomes available, these articles may be presented in a raw and
unedited form.

People who viewed this solution also viewed

How to rebuild the initial ramdisk in linux rescue mode

Solution - Apr 3, 2020

When is it necessary to rebuild the initramfs?

Solution - Oct 15, 2015

How do I rebuild the initramfs with multipath in Red Hat Enterprise Linux 6 and 7

Solution - Feb 15, 2016

9 Comments
23 July 2012 2:53 PM (https://access.redhat.com/solutions/1958#comment-384053)
SR Sylwester Rutkowski (/user/1617733)

(/user/1617733)
https://access.redhat.com/solutions/1958#initrd 5/8
6/6/2020 How to rebuild the initial ramdisk image in Red Hat Enterprise Linux - Red Hat Customer Portal
NEWBIE
Actually, when rebuilding initrd on RHEL 5.8 the command should be:
(https://access.redhat.com/)
7 Points mkinitrd -f -v /boot/initrd-$(uname -r).img $(uname -r) 
(entering -fv returns syntax error)

≤ Reply (/Ajax_comments/Reply/1958/384053)

16 August 2012 3:09 PM (https://access.redhat.com/solutions/1958#comment-392033)


JS jsynodin (/user/2001423)
(/user/2001423)
the instructions you send are not as clear as they should be.
COMMUNITY close this ticket.
MEMBER
jim
54 Points

≤ Reply (/Ajax_comments/Reply/1958/392033)

14 April 2016 4:52 PM (https://access.redhat.com/solutions/1958#comment-1037311)


FW Fred Wimberly (/user/1332283)
(/user/1332283)
I had a ticket opened and was pointed to this article by my RHCE. This fixed my issue
COMMUNITY with one caveat. My system (RHEL 5.11) is a multipathed, boot from SAN one. We use
MEMBER
LVM. The LVM filter in lvm.conf was set. Commenting out the filter to allow for
27 Points
defaults and running the mkinitrd as described here, worked.

From the RHCE: "...filters can be a little tricky depending on what path the pv was
created on and the way the disk enumerate. Unless you have around 100 or more disk
presented to the server, I recommend leaving the default filter. "

≤ Reply (/Ajax_comments/Reply/1958/1037311)

23 April 2018 1:47 PM (https://access.redhat.com/solutions/1958#comment-1297471)

Roger Sjöberg (/user/12482623)


(/user/12482623)
For RHEL 7.2 the commands is executed without errors but it still can't find lvroot.
COMMUNITY
MEMBER
≤ Reply (/Ajax_comments/Reply/1958/1297471)
48 Points

6 August 2018 9:16 PM (https://access.redhat.com/solutions/1958#comment-1338251)


RB Robert Bean (/user/23552222)
(/user/23552222)
Worked great. For REHL 7. Great appreciated.
NEWBIE

https://access.redhat.com/solutions/1958#initrd 6/8
6/6/2020 How to rebuild the initial ramdisk image in Red Hat Enterprise Linux - Red Hat Customer Portal

7 Points
≤ Reply (/Ajax_comments/Reply/1958/1338251)
(https://access.redhat.com/)

9 August 2018 7:04 AM (https://access.redhat.com/solutions/1958#comment-1340111)
MR Mushfiqur Rahman (/user/20306341)
(/user/20306341)
good one, dra.cut starter
RED HAT

GURU ≤ Reply (/Ajax_comments/Reply/1958/1340111)


1407
Points

26 September 2019 12:02 PM (https://access.redhat.com/solutions/1958#comment-1630681)


KL Krzysztof Labiak (/user/4824083)
(/user/4824083)
It is also worth to see the content of file /boot/grub/device.map if the disk name
COMMUNITY match.
MEMBER

22 Points
≤ Reply (/Ajax_comments/Reply/1958/1630681)

25 October 2019 9:14 AM (https://access.redhat.com/solutions/1958#comment-1651661)

Nicholas Cross (/user/9784243)


(/user/9784243)
Can we get this updated for RHEL8 please? thanks
COMMUNITY
MEMBER
≤ Reply (/Ajax_comments/Reply/1958/1651661)
81 Points

4 May 2020 1:24 PM (https://access.redhat.com/solutions/1958#comment-1802121)


PN Paul Novak (/user/35188871)
(/user/35188871)
Needs RHEL 8 info, or a link to the correct location for the RHEL 8 procedure. Even
NEWBIE better would be if this were actually part of the documentation. The knowledgebase is
11 Points good, but this should be in the actual documentation also under troubleshooting /
recovery.

≤ Reply (/Ajax_comments/Reply/1958/1802121)


All systems operational (https://status.redhat.com)
https://access.redhat.com/solutions/1958#initrd 7/8
6/6/2020 How to rebuild the initial ramdisk image in Red Hat Enterprise Linux - Red Hat Customer Portal

(https://access.redhat.com/)
Privacy Statement (http://www.redhat.com/en/about/privacy-

policy)
Customer Portal Terms of Use
(https://access.redhat.com/help/terms/)
All Policies and Guidelines
(http://www.redhat.com/en/about/all-policies-guidelines)

Copyright © 2020 Red Hat, Inc.


https://access.redhat.com/solutions/1958#initrd 8/8

You might also like