A broad variety of problems can be resolved by the tools provided through the rescue mode environment. Often these problems refer to booting problems but can also be from different types, such as forgetting the root password. Rescue mode can be a lifesaver and understanding it is a very important skill to learn. It was felt that such a recipe should thus remain close at hand.
This post describes the steps to boot a KVM guest into rescue mode.
1. Stop the KVM Guest. This is important, and if not done, it can corrupt the Guest vDisk.
# virsh shutdown [Guest]
2. Install libguestfs-tools.
# yum install libguestfs-tools
3. Use virt-rescue to initiate the rescue shell:
# virt-rescue -d [Guest]
Example output of when the rescue shell has been initiated:
Welcome to virt-rescue, the libguestfs rescue shell. Note: The contents of / (root) are the rescue appliance. You have to mount the guest’s partitions under /sysroot before you can examine them. > fdisk -l Disk /dev/sda: 300 GiB, 322122547200 bytes, 629145600 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x3e094520 Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 2099199 2097152 1G 83 Linux /dev/sda2 2099200 629145599 627046400 299G 8e Linux LVM