VM Recovery
If you're here you probabaly nuked your VM. Slight skill issue but oh well. Here's some of the common issues and how to get your VM back.
Accidently Deleted Bash
If you can still login/are logged in
- Update the packages.
sudo apt update
- Force Re-install bash.
sudo apt install -f --reinstall bash
- Occasionally you will get a dpkg error
- If this happens you need to delete the dpkg cache
sudo rm /var/lib/dpkg/info/bash*
- DO NOT BLINDLY COPY/RUN THE ABOVE COMMAND. The filepath to remove might have changed, please read the error
- If this happens you need to delete the dpkg cache
- Re-run the bash force re-install
sudo apt install -f --reinstall bash
- Make sure bash was installed correctly by running
bash
If are not logged in/can't login
Please see below for recovering VM from system faults
VM won't boot up/in
Dear god I hope you have a snapshot. No? You can't recover it? Okay. Follow along:
- The first thing you need to do is boot your VM into single user (recovery) mode.
- Shutdown the VM and then turn it on. Hold down the
SHIFT
key until you get to a black and white boot menu screen (see image in step 2) - If you have an M1/2 Mac you will need to edit the boot options in vCenter. Right click on your VM and then click on edit settings. Go to VM options and then go to boot options and set the boot delay to 5000. Then repeat step 1.1.
- Shutdown the VM and then turn it on. Hold down the
- Then use the up/down arrow keys until the "Ubuntu" option is selected.
- Press
e
to edit the boot option, and then use the arrow keys to move to the end of the "linux" line (1). Then add the lineinit=/bin/dash
. This determines what shell you boot into.dash
is usually a safe option but if you know that it doesn't work for you, edit it. If you are unsure this comment likely doesn't apply to you.
- Press the
CTRL
+X
keys at the sametime (regardless of what system you are on) to begin the boot process. Once booted it should look like this: - Set the filesystem to be read-write
mount -o remount,rw /
- Change the root password so you can login using
passwd
. I recomend using a easy to type/remember password likechangeme
- Enter the system to boot into multi-usermode.
systemctl set-default multi-user.target
- Change the rootshell to
dash
(the same caveats in step 3 also apply)chsh -s /bin/dash
- Reboot the system, you should get a screen as follows:
- Login with the the username
root
and the password you set in step 6. - Repeat the steps to reinstall bash
- Enable the system GUI again:
systemctl set-default graphical.target
- Reboot the system.
- You should now be able to login again.