Monday, May 21, 2018

Troubleshooting boot issues in Linux


Missing boot loader
Error:


  


  - this means your boot loader cannot be found
  - it might be removed (rm -fr /boot/grub2)
  - or corrupted (dd if=/dev/zero of=/dev/sda bs=1 count=446)

Solution:
1. Insert installation disc and boot into rescue mode
2. Acces /: # chroot /mnt/sysimage
3. Rebuild grub: # grub2-install /dev/sda
4. Check if grub.cfg is present, if not, recreate it: # grub2-mkconfig -o /boot/grub2/grub.cfg
5. # exit
6. # exit
Missing initramfs/initrd
Error:






- initramfs might be deleted

Solution:
1. Insert installation disc and boot into rescue mode
2. Access /: # chroot /mnt/sysimage
3. Check if initramfs is really gone: # cd /boot && ls -l *initramfs*
4. Build an initramfs: # dracut
5. # exit
6. # exit
Missing kernel
Error:


  




- vmlinuz* might be deleted

Solution:
1. Insert installation disc and boot into rescue mode
2. Copy kernel rpm to sysimage: # cp /run/installer/repo/Packages/kernel-3.10*rpm /mnt/sysimage/tmp
3. Switch to /: # chroot /mnt/sysimage
4. Install unpatched/base kernel: # rpm -ivh /tmp/kernel-3*rpm --force
5. # exit
6. # exit
GRUB 2 config file is missing but you don't have a rescue disc
Error:
A reboot will drop you to this shell







  - if GRUB cannot find the config file (grub.cfg), it will drop you down to a shell shown above
  - from that shell, you will be able to enter commands interactively

Solution:
1. Since we don't have a rescue disc, we cannot boot into rescue mode and recreate grub.cfg
2. So we are left with a grub shell
3. Determine what partitions holds the grub.cfg, kernel, and initrd
      grub> ls (hd0)/
      grub> ls (hd0,1)/
      grub> ls (hd0,msdos2)/
      grub> ls (hd0,msdos1)/
4. If you got it, set it as root partition
      grub> set root=(hd0,msdos1)
5. Set the path to kernel and specify location of root filesystem
      grub> linux /vmlinuz-3.10.0-514.el7.x86_64 root=/dev/mapper/cl-root
6. Set the initramfs path
      grub> initrd /initramfs-3.10.0-514.el7.x86_64.img
7. Boot now
      grub> boot
8. Once you are able to login, you can now recreate grub.cfg
      # grub2-mkconfig -o /boot/grub2/grub.cfg
9. You have now a working grub menu
      # systemctl reboot
some modules are missing from the GRUB 2 folder
Error:

  




- this is the grub rescue shell

Solution:
Most of the minimal modules that is used by Grub has been corrupted so best thing
to do is a rebuild grub from resuce disk.
Recreating GRUB 1 config file in RHEL 6
If /boot/grub/grub.conf is lost, there is no "grub-mkconfig" command to help you. So you need to recreate it from scratch. You can do it in several ways.

* Recreating grub.conf from rescue mode *

1. Insert installation disc and boot from rescue mode
2. Go and access your files: # chroot /mnt/sysimage
3. Create grub.conf: # /boot/grub/grub.conf
4. Enter the following:
default=0
timeout=5

splashimage=(hd0,0)/grub/splash.xmp.gz
title Red Hat 6
root (hd0,0)
  kernel /vmlinuz-2.6.0-514.el7.x86_64 root=/dev/mapper/VolGroup-lv_root
  initrd /initrd-2.6.0-514.el7.x86_64.img
5. Save and quit
6. Exit chrooted environment: # exit
7. Exit rescue mode to reboot: # exit

* Via grub shell method*

1. When you reboot while grub.conf is missing, you will be dropped to grub shell
2. Enter the following commands from grub shell
  grub> root (hd0,0)
  grub> kernel /vmlinuz-2.6.0-514.el7.x86_64 root=/dev/mapper/VolGroup-lv_root
  grub> /initrd-2.6.0-514.el7.x86_64.img
  grub> boot
3. Onced you are on the OS shell, recreate grub.conf
  # vi /boot/grub/grub.conf
  # enter the following:
default=0
timeout=5

splashimage=(hd0,0)/grub/splash.xmp.gz
title Red Hat 6
root (hd0,0)
  kernel /vmlinuz-2.6.0-514.el7.x86_64 root=/dev/mapper/VolGroup-lv_root
  initrd /initrd-2.6.0-514.el7.x86_64.img
4. Save and quit
5. Reboot
Non-existent device in /etc/fstab
Problem:
If you have a non-existent entry in fstab, let's say you removed a filesystem from LVM but forgot to remove it from /etc/fstab, your next boot will look like this:

This is your clue - during bootup, systemd/init will tell you that it cannot find a specific device. So you need to check fstab for non-exsiting devices.








Then you will be dropped to emergency shell:








Solution:
1. Provide the root password and enter
2. Check fstab for non existent devices by: # mount -a
3. Remove or comment it from fstab
4. Check again if all are OK: # mount -a
5. Reboot: # systemctl reboot
Missing /etc/grub.d contents
Reinstall grub2-tools:
# yum reinstall grub2-tools -y
Wrong kernel boot parameters
These are the errors/issues you will encounter when the corresponding boot parameter is incorrect/missing

# wrong root=/path/to/rootfilesystem
  -> your kernel might panic (seen on centos 7)
  -> or you will see dracut timing out (seen on centos 7)

No comments:

Post a Comment