• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

CentOS / RHEL 6 : How to rebuild Initial Ramdisk Image

By admin

When adding new hardware to a system, or after changing configuration files that may be used earlier 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. In the examples below 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.

Procedure

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

# cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
# ll /boot/initramfs-$(uname -r).img*
-rw-r--r--. 1 root root 16209434 Oct 11 14:43 /boot/initramfs-2.6.32-358.el6.x86_64.img
-rw-r--r--. 1 root root 16209434 Apr  9 07:38 /boot/initramfs-2.6.32-358.el6.x86_64.img.bak

2. Now rebuild the initramfs for the current kernel version:

# dracut -f

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

# dracut -f /boot/initramfs-2.6.39-400.17.1.el6.x86_64.img 2.6.39-400.17.1.el6uek.x86_64

The -f option will force an overwrite of any existing initial ramdisk image at the path you have specified

Working with Backups

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 required, 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 (2.6.32-358.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=LABEL=/ 
initrd /initramfs-2.6.32-358.el6.x86_64.img
title Red Hat Enterprise Linux w/ old initrd (2.6.32-358.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=LABEL=/ 
initrd /initramfs-2.6.32-358.el6.x86_64.img.bak

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 /initramfs-2.6.32-358.el6.x86_64.img.bak)
– Press Enter to temporarily save the changes you have made
– Press b for boot

Note: This procedure does not actually make any persistent change. At the next boot, the system will continue using the original grub.conf configuration unless it is updated.
CentOS / RHEL 5 : How to rebuild Initial Ramdisk Image

Filed Under: Linux

Some more articles you might also be interested in …

  1. Understanding Basic File Permissions and ownership in Linux
  2. What are the Network Bonding Modes In CentOS / RHEL
  3. CentOS / RHEL 6,7 : Why the files in /tmp directory gets deleted periodically
  4. CentOS / RHEL 7 : How to set default target (default runlevel)
  5. How to configure IPtables to open Ports in CentOS / RHEL
  6. CentOS / RHEL : iptables troubleshooting guide
  7. How to Calculate Memory Usage in Linux using sar, ps, and free
  8. UNIX / Linux : how to force user to change their password on next login after password has reset
  9. How to run rsyslog as a non-root user in CentOS/RHEL 7
  10. Linux interview questions – Special permissions (SUID, SGID and sticky bit)

You May Also Like

Primary Sidebar

Recent Posts

  • Oracle Database – Configuring Secure Application Roles
  • Extend rule sets by using factors in Oracle Database Vault
  • What are Command Rules in oracle Database
  • Using Rule Sets in Oracle Database Vault
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary