The reason appVMs based on a template with your own OS doesn't work

This text was originally posted in Portuguese. I’ve made a translation, hope you guys can understand it…
.
.

If you want to go straight to the point, skip the text and start reading from “conclusion”.

Hello. It’s been a while since I was trying to create a Manjaro Linux template on a VM I made, but so far it didn’t work, and I’ve find out the reason.

Although I was able to create the template VM, and install Manjaro on it, when I used this template to make an appVM, the appVM was not saving data. After reading a Qubes documentation, I find out that in a standard Qubes appVM, there are 4 virtual disks, the xvd (xen virtual block device).

The disks in a standard appVM are:

  • xvda -Here is where the root of the operating system is located. The root is taken from the template. xvda basically contains everything that is out of the /home directory¹ (that is, /dev,/root, /boot, /etc…).
    Anything modified on this disk will be discarded after shutting the appVM down.

  • xvdb -The data you save on your appVM is stored here. It is the only disk that saves the modifications made on it. The /home directory is mounted here, that is, all that is placed in the /home directory will stay on this disk.

  • xvdc -Here a swap is placed (which is kind of using a disk piece as RAM), and temporary modifications made out of /home.
    Anything modified on this disk will be discarded after shutting the appVM down.

  • xvdd -Where is stored the kernel of the appVM. The kernel that is placed here, comes from dom0. To be more specific, from the /var/lib/qubes/vm-kernels directory.
    Anything modified on this disk will be discarded after shutting the appVM down.

(As my appVM does not use a kernel from Qubes, it only has the first 3 disks.)

Anyway, in my first installation of the Manjaro, I installed EVERYTHING, including the /home, on the xvda disk. As I have already written,

Anything modified on this disk will be discarded after shutting the appVM down.

This explains why it was not saving the data.

I thought the solution would be just create a partition on the xvda disk, and mount it in the /home directory, that is, to save the /home contents on the xvdb disk.

The problem is that when I did it on my template, the appVM did not finish the booting, and had only text interface, saying that it could not find the /home. After re-reading this part of the documentation, I realized that:

Nothing on the xvdb disk of your template will be copied to the xvdb disk of the appVM

After booting the AppVM and using CLI, I saw that the xvdb disk was completely empty. There wasn’t even partition table there. I managed to create a partition in my appVM’s xvdb, but when I set the /etc/fstab to mount the partition at /home, I realized that it was not working. Then I realized that the fstab file was part of the OS root, and was being written on the xvda disk. As I said before,

Anything modified on this disk will be discarded after shutting the appVM down.

Conclusion

If you install all your OS on your template’s xvda disk, the template’s appVMs will act as disposable, discarding all change made in it.

If you install part of your OS in xvda, and install the /home on the xvdb disk, you will need to put some program to run during boot that mounts the partition of the xvdb disk at the /home directory, and if the partition does not exist, the program creates it.

Comments

Since I am a beginner, it is likely there is some mistake in my text. If you guys realize some mistake, please correct me.

1- Technically, it’s all out of the /rw directory, but to simplify, I just said /home.

1 Like

Have your AppVm template as Debian or Fedora and than change it to Majaro. You will have 2GB (at least) of disk that you can mount. The updates 2 weeks ago wiped a lot of flexibility on my HVMs templates install including some partitioning BTRFS, XFS etc.