Skip to main content

·412 words·2 mins
Vimal A R
Author
Vimal A R
Still figuring it out!

https://wiki.centos.org/TipsAndTricks/CreateNewInitrd

If you have changed a motherboard or moved a disk to a different system it may fail to boot due to the lack of appropriate drivers in the initial RAM disk image (initramfs for CentOS 6, initrd for CentOS 5).

Boot in Rescue Mode
#

  1. Boot from a CentOS installation disc (for example, CD #1 or DVD).
  2. Type "linux rescue" at the "boot:" prompt.
  3. Mount all filesystems in read-write mode.

Create the New Initramfs or Initrd
#

Change root to real root ('/') on your hard disk and make the new initramfs or initrd.

1mount --bind /proc /mnt/sysimage/proc
2mount --bind /dev /mnt/sysimage/dev
3mount --bind /sys /mnt/sysimage/sys
4chroot /mnt/sysimage

For CentOS 7 and multipathed root ('/') issue the following before chroot-ing to '/mnt/sysimage':

1mount --bind /run /mnt/sysimage/run
2systemctl start multipathd.service

For CentOS 6:

  • Create a backup copy of the current initramfs:

    1cp -p /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
  • Now create the initramfs for the current kernel:

    1dracut -f 
  • If you need to build it for a specific kernel version (replace the version appropriately):

    1dracut -f /boot/initramfs-2.6.32-358.el6.x86_64.img 2.6.32-358.el6.x86_64
  • One useful option you might want to add is -H (--hostonly). With this option dracut installs only what is needed for booting your system. Otherwise dracut by default adds many drivers to the initramfs making its size larger than necessary. Many other options may be exercised. Please see man dracut, man dracut.conf and the upstream Deployment Guide.

For CentOS 5:

  • Create a backup copy of the current initrd:

    1cp -p /boot/initrd-$(uname -r).img /boot/initrd-$(uname -r).img.bak
  • Now create the initrd for the current kernel:

    1mkinitrd -f -v /boot/initrd-$(uname -r).img $(uname -r)
  • If you need to build it for a specific kernel version (replace the version appropriately):

    1mkinitrd -f -v /boot/initrd-2.6.18-371.el5.img 2.6.18-371.el5
  • If you are migrating a physical machine to a virtual one using the Xen hypervisor, replace the last command above with:

    1mkinitrd --with-xenblk initrd-2.6.18-371.el5xen.img 2.6.18-371.el5xen
  • Many other options may be exercised, such as adding non-loaded modules manually. See man mkinitrd for details. It may be necessary to modify /boot/grub/grub.conf and/or /etc/fstab depending on the details of your installation. This depends on your use of LABEL and/or UUID versus physical devices in the files, and is too complex an issue to get into in any detail in a TipsAndTricks article.

Reboot

1cd /
2sync
3telinit 6

This page was created by PhilSchaffner. Other Wiki contributors are invited to make corrections, additions, or modifications.

The page was inspired by this forum thread. Please see the thread for additional discussion.

Related

·309 words·2 mins
Difference between grubx64 and shimx64? # https://askubuntu.com/questions/342365/what-is-the-difference-between-grubx64-and-shimx64 Typically, EFI/ubuntu/grubx64.efi on the EFI System Partition (ESP) is the GRUB binary, and EFI/ubuntu/shimx64.efi is the binary for shim. The latter is a relatively simple program that provides a way to boot on a computer with Secure Boot active. On such a computer, an unsigned version of GRUB won't launch, and signing GRUB with Microsoft's keys is impossible, so shim bridges the gap and adds its own security tools that parallel those of Secure Boot. In practice, shim registers itself with the firmware and then launches a program called grubx64.efi in the directory from which it was launched, so on a computer without Secure Boot (such as a Mac), launching shimx64.efi is just like launching grubx64.efi. On a computer with Secure Boot active, launching shimx64.efi should result in GRUB starting up, whereas launching grubx64.efi directly probably won't work.

·6525 words·31 mins
Get started with GRUB2 # https://www.certdepot.net/rhel7-get-started-grub2/ Note: This is an RHCSA 7 exam objective. Presentation of GRUB2 # GRUB2 is the new Linux bootloader. GRUB2 stands for GRand Unified Bootloader version 2. As GRUB was not maintained for some time and lacked some critical features like GPT management needed to handle disks bigger than 2.4TB, it was decided to start a new version from scratch with modularity in mind.