In certain scenarios, such as incorrect modifications to fstab or filesystem errors requiring fsck, virtual machines may fail to start properly. In such cases, you can utilize rescue mode to repair the root filesystem (rootfs) or retrieve data from the system.
In the left navigation bar, click Virtualization Management > Virtual Machine Images.
Select the platform-provided Source as Image Repository, and the Operating System as either CentOS or Ubuntu. Click ⋮ > Update on the right.
Copy and save the Image Address. This document uses 192.168.1.1:11443/3rdparty/vmdisks/centos:7.9
as an example.
Click Cancel.
Access the Container Platform.
In the left navigation bar, click Virtualization > Virtual Machines.
Click ⋮ > Stop on the right side of the virtual machine that needs repair to Stop or Force Stop it.
Click ⋮ > Update on the right side of the virtual machine.
Switch to YAML and modify the following fields.
Add the following content under spec.template.spec.domain.devices.disks
. Adding a bootOrder parameter can control which disk is prioritized during the virtual machine's boot process; a lower bootOrder value indicates higher priority.
Note: If the original spec.template.spec.domain.devices.disks
field contains bootOrder: 1
, increase the original value to ensure that the newly added bootOrder value is lower than the original.
Modified YAML example:
Add the following content under spec.template.spec.volumes
.
Note: Please replace the image address in the following image
field with the one obtained from Obtain Image Address.
Modified YAML example:
Click Update.
Note: After modifying the YAML file, do not switch to Form, just click Update directly.
Click ⋮ > Start on the right side of the virtual machine.
Log in to the virtual machine using the original password or key and enter the command df -h /
to find that the rootfs filesystem has been replaced. You can use mount-related commands to mount it or fsck-related commands to check and repair the original filesystem.
After completion, shut down the virtual machine.
Follow the steps in Modify Virtual Machine YAML File to restore the virtual machine YAML file to its original state. At this point, the virtual machine can start normally.