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

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@ucartz ~]# 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 arm on the rescue image in /boot directory. There are other entries such as in the menu entry 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 deleted.

# 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 menu entry is now removed from the grub2 configuration file.

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

 

Was this answer helpful? 0 Users Found This Useful (0 Votes)