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

  1. Update the packages. sudo apt update
  2. Force Re-install bash. sudo apt install -f --reinstall bash
  3. Occasionally you will get a dpkg error
    1. If this happens you need to delete the dpkg cache sudo rm /var/lib/dpkg/info/bash*
    2. DO NOT BLINDLY COPY/RUN THE ABOVE COMMAND. The filepath to remove might have changed, please read the error
  4. Re-run the bash force re-install sudo apt install -f --reinstall bash
  5. 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:

  1. The first thing you need to do is boot your VM into single user (recovery) mode.
    1. 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)
    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.
  2. Then use the up/down arrow keys until the "Ubuntu" option is selected.
  3. 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 line init=/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.
  4. 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:
  5. Set the filesystem to be read-write mount -o remount,rw /
  6. Change the root password so you can login using passwd. I recomend using a easy to type/remember password like changeme
  7. Enter the system to boot into multi-usermode. systemctl set-default multi-user.target
  8. Change the rootshell to dash (the same caveats in step 3 also apply) chsh -s /bin/dash
  9. Reboot the system, you should get a screen as follows:
  10. Login with the the username root and the password you set in step 6.
  11. Repeat the steps to reinstall bash
  12. Enable the system GUI again: systemctl set-default graphical.target
  13. Reboot the system.
  14. You should now be able to login again.