How do I chroot into a VM I cannot run any programs on?
Yesterday I noticed that in all my debian-based VMs (templates and standalones) I had multiple packages that could be removed.
I suspect that this was the case because I did in-place upgrades from Debian 10 to Debian 11 a while ago, rendering some old packages obsolete.
sudo apt autoremove in my Debian 11 templates and standalones.
Now I cannot start any program on any of these VMs anymore .
I followed this guide and manually attached an affected VM’s root storage to a disposable (whonix disposable, eg. having internet access).
Now I mounted
/mnt in the disposable and
chrooted into it.
I am pretty confident that the
autoremove caused this problem, so I came up with this epic command:
# don't tell me about regex repetition grep "^2022-10-04 [0-9][0-9]:[0-9][0-9]:[0-9][0-9] remove " /var/log/dpkg.log | cut -d' ' -f4 | cut -d: -f1
This should essentially give me a list of all programs that were removed yesterday (correct me if that’s not the case).
libbotan-2-17 libtspi1 linux-headers-5.10.0-10-amd64 linux-headers-5.10.0-10-common linux-headers-5.10.0-11-amd64 linux-headers-5.10.0-11-common linux-headers-5.10.0-12-amd64 linux-headers-5.10.0-12-common linux-headers-5.10.0-13-amd64 linux-headers-5.10.0-13-common linux-headers-5.10.0-14-amd64 linux-headers-5.10.0-14-common linux-headers-5.10.0-15-amd64 linux-headers-5.10.0-15-common linux-headers-5.10.0-16-amd64 linux-headers-5.10.0-16-common linux-headers-5.10.0-8-amd64 linux-headers-5.10.0-8-common linux-headers-5.10.0-9-amd64 linux-headers-5.10.0-9-common linux-image-5.10.0-10-amd64 linux-image-5.10.0-11-amd64 linux-image-5.10.0-12-amd64 linux-image-5.10.0-13-amd64 linux-image-5.10.0-14-amd64 linux-image-5.10.0-15-amd64 linux-image-5.10.0-16-amd64 linux-image-5.10.0-8-amd64 linux-image-5.10.0-9-amd64 qubes-core-agent-qrexec
I suspect that
qubes-core-agent-qrexec should not have been removed…
When trying to reinstall a package I get an error about unmet dependencies:
root@host:/# sudo apt install libbotan-2-17 sudo: unable to resolve host host: Name or service not known Reading package lists... Done Building dependency tree... Done Reading state information... Done You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies: libbotan-2-17 : Depends: libtspi1 (>= 0.3.1) but it is not going to be installed qubes-core-agent : Depends: xen-utils-guest but it is not going to be installed E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
sudo apt --fix-broken install it suggests to remove
linux-headers-amd64 which I deemed to be a bad idea (thus I declined to do so).
On my journey through the internet looking for a fix I encountered
sudo xl console 377 (where 377 was the
ID of the VM retrieved by running
sudo xl list with the VM running) in dom0 returned an error:
libxl: error: libxl_dom.c:40:libxl__domain_type: unable to get domain type for domid=377 Unable to attach console
Note: This VM was a standalone, just in case this is of importance here.
I had this problem with one VM a long time ago and simply “fixed” it by mounting the
private storage of the affected VM to a disposable and copying my files to a newly created VM.
However, this is not an option (not if avoidable), as all my Debian templates and standalones are affected.
Having to set up each VM manually again would take days / weeks.
Because of that I would like to properly
chroot into my VM (with all partitions attached,
root storage etc.) and try to reinstall the removed packages.
If there is an obvious / easy fix, please let me know.
Although I have backups, these are ca. 1 week old, there has been a lot of change since then.
PS: I do acknowledge that it is pretty silly to simply
autoremove without checking…
Yesterday I also encountered that in many of my Debian 11 VMs, my
/etc/apt/sources.list.d/qubes-r4.list contained a Qubes 4.0 entry instead of Qubes 4.1.
I changed these entries to
deb [arch=amd64] https://deb.qubes-os.org/r4.1/vm bullseye main (note the
4.1 instead of
4.0). I also ran
sudo apt update after this change, and it worked (making me believe this was no problem).
I included this here just in case it has something to do with the problem.
I hope you can help me out with this.
If we get this fixed I will submit a “How-to” topic in “Guides”