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

The Geek Diary

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

CentOS / RHEL 7 : How to remove rescue image using grubby

by admin

The ask is to remove the default rescue image that gets installed when you install a CentOS/RHEL 7 system. To list out the rescue image under /boot directory :

[root@geeklab ~]# ls -lrt /boot
total 135164
-rw-------. 1 root root  3113253 Nov 22  2016 System.map-3.10.0-514.el7.x86_64
-rw-r--r--. 1 root root   137696 Nov 22  2016 config-3.10.0-514.el7.x86_64
-rwxr-xr-x. 1 root root  5392080 Nov 22  2016 vmlinuz-3.10.0-514.el7.x86_64
-rw-r--r--. 1 root root   277953 Nov 22  2016 symvers-3.10.0-514.el7.x86_64.gz
drwxr-xr-x. 2 root root       27 Sep 23 19:50 grub
-rw-------. 1 root root 64487503 Sep 23 20:00 initramfs-0-rescue-9cdb9ab3246a4b3f9c0849ecd597f25e.img
-rwxr-xr-x. 1 root root  5392080 Sep 23 20:00 vmlinuz-0-rescue-9cdb9ab3246a4b3f9c0849ecd597f25e
-rw-r--r--. 1 root root 10209739 Sep 23 20:00 initrd-plymouth.img
-rw-------. 1 root root 30753143 Sep 23 20:02 initramfs-3.10.0-514.el7.x86_64.img
drwx------. 6 root root      111 Sep 23 20:02 grub2
-rw-------. 1 root root 18624164 Sep 23 22:10 initramfs-3.10.0-514.el7.x86_64kdump.img

You can not simply do a rm on the rescue image in /boot directory. There are other entries such as in the menuentry in grub2 configuration file which needs to be removed as well. Follow the steps below to remove the default rescue image from the system.

Removing rescue image using grubby

1. Remove the rescue image from the /boot directory first.

rm -fr /boot/vmlinuz-0-rescue-9cdb9ab3246a4b3f9c0849ecd597f25e

2. Locate the rescue menu entry in the GRUB2 configuration file /boot/grub2/grub.cfg which needs to be delete.

# cat /boot/grub2/grub.cfg 
....
menuentry 'CentOS Linux (0-rescue-9cdb9ab3246a4b3f9c0849ecd597f25e) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-9cdb9ab3246a4b3f9c0849ecd597f25e-advanced-10bac86a-a9be-478c-b63f-46d3ca061e03' {
	load_video
	insmod gzio
	insmod part_msdos
	insmod xfs
	set root='hd0,msdos1'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  a52207e4-01fd-4f12-98b7-681d56f21dc5
	else
	  search --no-floppy --fs-uuid --set=root a52207e4-01fd-4f12-98b7-681d56f21dc5
	fi
	linux16 /vmlinuz-0-rescue-9cdb9ab3246a4b3f9c0849ecd597f25e root=/dev/mapper/cl-root ro crashkernel=auto rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet
	initrd16 /initramfs-0-rescue-9cdb9ab3246a4b3f9c0849ecd597f25e.img
}
....

3. Remove the rescue image using the grubby command with –remove-kernel option.

# grubby --remove-kernel=/boot/vmlinuz-0-rescue-9cdb9ab3246a4b3f9c0849ecd597f25e

4. Verify that the rescue image menuentry is now removed from the grub2 configuration file.

# cat /boot/grub2/grub.cfg | grep rescue

Filed Under: CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. lnav: command not found
  2. “lsb_release: command not found” – Fix in CentOS/RHEL
  3. apt-mark Command Examples in Linux
  4. chfn Command Examples in Linux
  5. RHEL / CentOS : How to shrink LVM volume
  6. How to modify the iSCSI initiator ID in Linux
  7. UNIX / Linux : Send mail with attachment using mutt
  8. How to add swap space in linux
  9. 10 Sed (Stream Editor) Command Examples
  10. archlinux-java: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright