Tuesday, May 10, 2016

How To Boot Linux Paravirtualized VM Into Rescue Mode and in Single User Mode (Doc ID 1602157.1)

How To Boot Linux Paravirtualized VM Into Rescue Mode and in Single User Mode (Doc ID 1602157.1)

APPLIES TO:

Oracle VM - Version 3.0.3 to 3.2.6 [Release OVM30 to OVM32]
Information in this document applies to any platform.

GOAL

This article describes how to configure an Oracle VM guest Virtual Machine (VM) to boot into linux rescue mode.

SOLUTION

If, for some reason, Oracle VM guest fails to start, it may be needed to boot it into rescue mode or into single user mode to be able to diagnose and recover the system.

For physical installations, this is simply a matter of inserting the installation media (e.g. DVD/CD-ROM Disk 1), booting the system, then typing 'linux rescue' at the installation prompt, and for single user mode you just need to interupt the kernel at grub prompt and edit it for single user mode.

For Virtual Machines, however, the process is somewhat different. In fact, the process differs depending on which virtualization type the guest VM is configured to use i.e. Paravirtualized (PVM) or Hardware (Fully) Virtualized (HVM). Here we will see how we can boot PVM guests into rescue mode and in single user mode.
But before we look into below method, I would like to share the most easiest method on how we can repair the vdisks for PVM guests, and for this the PVM guest in questioned needs to be shutdown, after which you can detach the vdisk and attach that vdisk to another guest with the same OS release that is functioning properly, and repair it using the tools installed in the other guest.
Paravirtualized (PVM) Guests

1. Rescue Mode

1.1 Locate the Guest VM Installation Media

Locate the installation media for the guest VM. If the installation media was imported via Oracle VM Manager, the media should reside under the /OVS/Repositories/<uuid>/ISOs directory on the Oracle VM Server(s).

1.2. Loop Mount the Guest VM Installation Media

Loop mount the guest installation media on the Oracle VM Server.
In the following example, the 64-bit EL5 DVD ISO media (Enterprise-R5-U8-Server-x86_64-dvd.iso) is used.
# mkdir /media/OL5u8
# mount -o ro,loop /OVS/Repositories/0004fb00000300003a8564212a807247/ISOs /media/OL5u8


1.3. Copy the Initial RAM Disk and Kernel from Guest Installation Media

Copy the initial ram disk (initrd.img) and kernel image (vmlinuz) from the loop-mounted guest installation media to a temporary directory on the Oracle VM Server, for example:
# cp /media/OL5u8/images/xen/initrd.img /media/OL5u8/images/xen/vmlinuz /tmp


1.4. Modify the Guest VM Configuration File

For Oracle VM Manager managed guests, the guest VM configuration file (vm.cfg) typically resides under the /OVS/Repositories/<uuid>/VirtualMachines/<VM UUID>directory, for example:/OVS/Repositories/0004fb00000300003a8564212a807247/VirtualMachines/0004fb0000060000837b90fd1f033b81/vm.cfg
Backup the existing guest VM configuration file, then modify it as follows:
Comment out the following line:
bootloader = "/usr/bin/pygrub"

Add the following lines:
kernel  = "/tmp/vmlinuz"
ramdisk = "/tmp/initrd.img"
extra   = "rescue"

Note: The above lines should be added below to "bootloader" section which you have commented out above.

1.5. Start the Guest VM

Using the 'xm' command, start the guest VM, for example:
# xm create /OVS/Repositories/0004fb00000300003a8564212a807247/VirtualMachines/0004fb0000060000837b90fd1f033b81/vm.cfg


1.6. Launch the VNC console for the guest VM

Now launch the VNC console using the OVM manager for the required guest VM.

2. Alternate Ways:

1. Since OVM 3.x can specify the network location which a vm uses as a boot device, such as a nfs export, etc., there is no need to copy initrd.img and vmlinuz from the iso media to launch the resucue mode., but we can just use network location.

a. Configure to boot up from network via ovm manager
b. Modify vm.cfg to add resucue for extra arguments, i.e. extra='rescue'
c. Power on the vm via ovm manager.
 or the best way is below:
2. Go to OVM manager GUI, and stop the guest VM (which you want to boot into rescue mode) and perform below steps:
a. Stop the VM
b. Edit the VM and go to Disks section and take the screen shot for all the available disks if it has more than 4 virtual or physical disks attached.
c. Go to Configuration tab and select the Domain Type to XEN_HVM
d. Go to Disks section again and remove the additional disk if it has more than three disks and select CD/DVD option as fourth disk. After which select the required ISO, and go to Boot Order tab and select the Boot Order as CDROM and choose CDROM as first option to boot and click OK.
e. Now, go ahead and start the VM and this should help you provide the option to boot into rescue mode like you do for physical servers.
f. Once your rescue mode part is done then you can again stop the VM and edit it back to use XEN_PVM domain and add back the existing disks and change the Boot Order if necessary and click ok and boot up the VM back in PVM mode.

3. Single User Mode

For Single User Mode, it is just needed to edit the vm.cfg file and add the below line just after bootloader="/usr/bin/pygrub"
extra = 'S'
Start the guest VM and take the VNC console. Once resolved, shutdown the VM and edit vm.cfg file and remove the parameter extra = "S", then save it, after that it is possible to boot again into the predefined runlevel.

REFERENCES

NOTE:549410.1 - Oracle VM: How to Configure a Guest VM to Boot into Linux Rescue Mode

No comments:

Post a Comment

  How to Change Instance Type & Security Group of EC2 in AWS By David Taylor Updated April 29, 2023 EC2 stands for Elastic Compute Cloud...