Guide to build a "sys-mini" template for all service-qubes

Idea

  • Any updates or changes to the template of your service qubes imply the risk of a hidden error, making your service qubes unbootable.
  • A separate template / disposable template only for service qubes should decrease this thread.
  • Having one complete step-by-step guide to save much time for seeking the not mentioned details …
  • There are a few guides around this theme complex, but none of them is covering all aspects, so one has to jump between multiple sources.

Thoughts

  • Building a separate template for each service qube is space consuming, as the system-disk of each template will use about 10 to 20 GB.
  • Using a mini-template as base for the “sys-…” qubes reduces the number of packages and therefore the needed space and attack surface.
  • As an additional security aspect, we’ll make the service qubes disposable.
  • It should work, starting with “fedora-xx-minimal” or “debian-xx-minimal”. The work is nearly the same and we can use the official Qubes’ book for this installation part.
  • As shown up in the discussion about this guide, I didn’t see the point of hardening the template. Until finding a solution for this, I’ll state a big

WARNING

  • The new “sys-mini” template isn’t hardened in any way, what may open other attacking vectors, already closed in the default templates. Even the guide itself is complete, you must be aware that it doesn’t cover any aspect of hardening.
  • Installing/configuring of apparmor, selinux or grsecurity is left open

In so far, even if the guide itself is no rocket science and mostly any user should be able to follow, it’s this subsequent part you should be aware of, before starting.

Requirements

  • You’ll need Qubes-OS 4.3 as we are using some enhancements of Qubes GUI-Tools, not available before.
  • You should have basic knowledge, how to use the different Qubes GUI-Tools.
  • You should be able to use a terminal in dom0

What we will get:

  • One very small template as base for our service qubes: “sys-mini”
  • One named disposable template “sys-mini-dvm” between “sys-mini” and the service qubes
  • New disposable service qubes: “sys-net”, “sys-firewall”, “sys-usb”
  • Possibility for easy building additional service qubes, for example: “sys-vpn”, “sys-audio”, …

It would be nice

  • to get this guide checked by some users, experienced or not
  • any improvements are welcome

There’s the problem of seeing the single trees, but not the complete forest …

Let’s start:

First is to create “sys-mini” and prepare it with needed packages:

  • Use the template manager to install the minimal-template of your choice.
  • Make a clone of it and name it: “sys-mini”
  • Follow this doc (Minimal templates — Qubes OS Documentation) to install
    • passwordless-root
    • xfce4-terminal, thunar and qubes-core-agent-thunar (mostly for convenience)
  • Shutdown “sys-mini”, change its applications: Add xfce4-terminal and thunar.
  • Restart “sys-mini” and from now on use xfce4-terminal for having copy and paste available.
  • Resume following the doc:
    Install the needed packages for your planned tasks:
    • “sys-net” look at NetVM
    • “sys-firewall” look at FirewallVM
    • “sys-usb” look at USB qube
    • Maybe you’ve installed some more service qubes like sys-vpn or so. In that case you should know what you’ve done to make them run and repeat your work.
  • Don’t forget to install needed firmware packages for your wifi or ethernet device!
  • Shutdown sys-mini.

Now we’ll create the “sys-mini-dvm” as a named disposable template for all service qubes.

For this start a terminal in dom0: (only three commands, as I found no way to do this in the Qubes Manager)

user@dom0:~$ qvm-create --template sys-mini --label black sys-mini-dvm
user@dom0:~$ qvm-prefs sys-mini-dvm template_for_dispvms True
user@dom0:~$ qvm-features sys-min-dvm appmenus-dispvm 1

(It’s ok to use --label black for sys-mini-dvm, as it is as safe as any other template, as long as you don’t expose it to the internet.)

Now as it already exists, we can use the Qubes Manager to configure “sys-mini-dvm” for our needs.

  • choose “sys-mini-dvm” and click “Settings”
    • Settings: Basic
      • Net qube: “none”
    • Settings: Advanced
      • Default disposable template: none"
    • Settings: Applications
      • Xfce Terminal, Thunar File Manager

We are ready to create the new service qubes:

Be aware: Your old service qubes are still running and many global settings depend on them. We will not touch them, until we are sure the new qubes will do their work. That’s why we’ll create the new qubes with “-new” appended to their names.

sys-net

  • click “New qube”, use “Named disposable”

    • Name: sys-net-new
    • Label: red
    • Disposable qube template: sys-mini-dvm
    • Network: Choose “No network connnetion”
    • Applications: xfce4-terminal, thunar
    • Advanced Options: Tap “Provides network-access to other qubes”
  • choose “sys-net-new” and click “Settings”

    • Settings: Advanced
      • Initial memory: 300 MiB
      • Max memory: 300 MiB
      • Untap “Include in memory balancing”
      • Default disposable template: “none”
      • Virtualization - Mode: “HVM”
    • Settings: Devices
      • choose your network devices
    • Settings: Applications
      • Xfce Terminal, Thunar File Manager
    • Settings: Services
      • choose (custom…) - Add
        • Name of the service: “minimal-netvm”
      • choose (custom…) - Add
        • Name of the service: “clocksync”

sys-firewall

  • click “New qube”, use “Named disposable”

    • Name: sys-firewall-new
    • Label: green
    • Disposable qube template: sys-mini-dvm
    • Network: Choose “sys-net-new”
    • Applications: xfce4-terminal, thunar
    • Advanced Options: Tap “Provides network-access to other qubes”
  • choose “sys-firewall-new” and click “Settings”

    • Settings: Advanced
      • Initial memory: 400 MiB
      • Max memory: 3000 MiB
      • Default disposable template: “none”
      • Virtualization - Mode: “HVM”
    • Settings: Applications
      • Xfce Terminal, Thunar File Manager
    • Settings: Services
      • choose (custom…) - Add
        • Name of the service: “qubes-updates-proxy”

sys-usb

  • click “New qube”, use “Named disposable”

    • Name: sys-usb-new
    • Label: red
    • Disposable qube template: sys-mini-dvm
    • Network: Choose “No network connnetion”
    • Applications: xfce4-terminal, thunar
  • choose “sys-usb-new” and click “Settings”

    • Settings: Advanced
      • Initial memory: 300 MiB
      • Max memory: 300 MiB
      • Untap “Include in memory balancing”
      • Default disposable template: “none”
      • Virtualization - Mode: “HVM”
    • Settings: Devices
      • choose your usb devices
    • Settings: Applications
      • Xfce Terminal, Thunar File Manager
    • Settings: Services
      • choose (custom…) - Add
        • Name of the service: “minimal-usbvm”

It’s time to check our work!

Keep in mind: We havn’t changed any global settings.

  • During the next tests we will have some problems with using usb-devices.
  • It will be no good idea to use the Update Manager.
  • sys-whonix shouldn’t be started, as it still depends on your old “sys-net” and “sys-firewall”.
  • Maybe it’s a good idea, to save this guide locally, as you’ll need to stop all virtual machines connected to the net!

Stop “sys-net” and “sys-firewall”.

Start “sys-net-new”.

  • If sys-net-new declines running, most probably one of your network devices needs “strict reset”.
  • If the Network-Manager-Applet appears and you are able to see and connect your network-connections, all is good.
  • On any other problems recheck the steps before. :wink:

Start “sys-firewall-new”

  • change the network setting of “personal” (for example) to “sys-firewall-new”, start it and check if you can reach the web!
  • On any problems recheck the steps before. :wink:

Stop “sys-usb” and start “sys-usb-new”.

  • Your devices should get disconnected and should reappear now connected to “sys-usb-new”.
  • For me I got a system message, that my usb-mouse and usb-keyboard were declined for input to dom0. - That’s normal!
  • On any other problems recheck the steps before. :wink:

If until now all works as expected, we’ve done the main work. Now we can change the system to fully use the new service qubes:

Changing the system

  • Rename sys-net to “sys-net-old”, “sys-firewall” to “sys-firewall-old” and “sys-usb” to “sys-usb-old”.
  • Untap the “autostart”-setting of each.
  • Stop “sys-net-new”, “sys-firewall-new” and “sys-usb-new” and rename them to “sys-usb”, “sys-firewall” and “sys-usb”
  • Tap the “autostart”-setting of each.
  • If needed, open the settings of “sys-firewall” and change network to “sys-net”.
  • Restart the new service qubes, now correctly named.
  • Check and change the network settings of all qubes, maybe they actually use “sys-firewall-old”?! :wink:

Open the “Global Settings Manager” and check if all settings point to the correct quebes.
After this your usb-mouse and usb-keyboard should work correctly even in dom0. Maybe you’ll need to restart “sys-usb”.

Start the Update Manager and make a full update to see if all these settings are correct.

Last check: Restart your Qubes System! - It should run without any problems.

Worth mentioning, but not enough for another guide …

Without being an expert in hardening a linux system, it makes no sense, to compete with the Qubes team. They did this work already for the standard debian-XX-xfce and fedora-XX-xfce templates.
As long as they don’t release some hardened mini-templates, it could be senseful, to use this guide, but startup with an xfce-template to clone.
In that case instead of installing needed packages, the task is to strip down all unneeded packages. You have to install the needed packages for your hardware only.

If anyone is able to give a list of needed packages, I would be glad to append it to this guide!

I’ll close my work on this guide now, but I’ll follow the discussion …

1 Like

I have not fully read this guide but if you don’t mind, here are some random thoughts:

  • you have to tell the user it’s for Qubes OS 4.3 because 4.2 is still supported
  • I still don’t understand the purpose of this guide
  • there is a confusion between “template” and “disposable template”, the real purpose are to change both, right?
  • there should be an advice telling users to avoid this guide unless they are advanced (See Why Use Minimal Templates? - #15 by adw)
  • with that in mind, a lot of the text could be stripped down to remove things that an advanced user should know (and get a more readable guide)
  • why are you installing optional software in a minimal template?
  • why are you creating new sys-net and so on, instead of just changing the disposable template?
  • why are you changing the default settings?

I like the idea of a checking procedure.

2 Likes

I’ve added the requirements and edited some steps to have the guide more straight-line.

This is a guide for all users. Even a totally newbie should be able to reach the goal. Especially for some of them it will save much time, when not getting cut from the internet.

All steps have got a short description what happens.
Following each step one by one should lead to the target.

Advanced users may jump over my comments. For all others those comments should help following the guide.

The optional software is not much compared to the convenience when working on/with the service qubes.

I’ve changed default settings only for security reasons, especially the settings for the net qube and the default disposable template.

I was just following the default path of dependencies:

  • fedora-42-xfce4 → default-dvm → sys-XXX

and changed this to:

  • sys-mini → sys-mini-dvm → sys-XXX

That’s better, but:

I strongly disagree with you about the use of minimal templates, everything is in the link so I have nothing more to say.

According your guide all services qubes will work without selinux or apparmor.
I prefer to think twice before drop extra layer of protection from sys-usb and sys-net, better to clean up xfce\gnome template with already function apparmor\selinux from unnecessary content.

Navigate to start menu, Qubes tools → Template switcher, use it to switch templates.
As more advanced user you can perform same process with CLI in fail save way for sys-usb:

@parulin, @WhiteShadow

Ok to your remarks.

As you see, my first idea was not that I wanted to use minimal templates, but to have separate templates for the service qubes.

The smaller those separate templates are, the better they are, but this mustn’t set down the security level.

Without seeing the problem, minimal templates were the logical choice.

I’ve got no experience in setting up selinux or apparmor. - I’ll start looking for this, trying out and see, if I’m able to add this part.

Meanwhile I’ll put a warning at the beginning.

You drop security measures on the way for this extra tiny template, how much MB of storage and RAM you save by that?
In security perspective you open already closed attacked vectors.

I’ll change the last part … to use the Template switcher. - Sorry, but this will not work as expected: The net-vm has to be changed here, not the template.

As my tasks between shutdown of sys-usb (old) and startup of sys-usb (new) are a bit different, it’s not as easy as in your example. - I’ll have to find the correct commands and to check the new script before adding them to the guide.

Look at my answer, I agree …

You don’t list any of the qubes core packages required by the sys-qubes.

New users blindly following your guide risk ending up with a system that can’t access the internet or use mouse and keyboard.

https://doc.qubes-os.org/en/latest/user/templates/minimal-templates.html

The official guide explains what needs to be installed, and you are missing some important packages.

Sorry, what packages do I miss?

If you look into the doc, the needed packages for sys-net, sys-firewall and sys-usb are listed. I didn’t want to copy the list, as the packages changed between releases of the minimal templates.

Maybe this is your problem:
The doc uses NetVM instead of sys-net, FirewallVM instead of sys-firewall and USB qube instead of sys-usb.

I installed nothing else and my system is running without a problem.

Requested packages for minimal functionality stay same, as critical aspect of stability.

NetVM could be sys-net, sys-usb, sys-lte, sys-wifi, sys-unique-pci-adapter, it refer to idea of HVM that provide network.
FirewallVM same idea Qube that serve as fw - could be sys-firewall, but also sys-whonix, nosys-whonix, fw-not-whonix-and-not-sys-it-is-gentoo-fw and so on :grin:

Maybe you should read same another guides in Qubes networking as reference for terminology and “qubesOS logic”, it will help you to better understand same idea’s behind why things work as they

Yeah, but it is not the intention of this guide, to handle all of these special aspects.
I want to make clear, what packages are needed for the three default service qubes …

1 Like

check this on how to install the apparmor Apparmor in minimal template not working