Automate debian-minimal based template creation

As promised pretty exactly a year ago, I have at least started work on the respective guide. Today I publish a first rough and incomplete draft, that nevertheless should be useful.

I will keep fleshing it out. Please post all feedback, question or corrections you have into this thread and I will answer here and update in the guide as we go along. If this works and turns out to be a productive use of time both for the community and me, there could be many more ‘notes’ :wink:

10 Likes

Thank you sir!

1 Like

It’s a good guide but more suitable for advanced guides.

I still like this straightforward setup Debian-10-minimal Configuration - #12 by Sven :smiling_face_with_three_hearts:

1 Like

I am eternally grateful to you for this work.

Have you already tried creating minimal templates for sys-gui, sys-gui-gpu and sys-audio ?

I would also like to hear your opinion about integrating security improvements from Kicksecure into the minimal templates.

I found your Github account, but there is only qubes-doc. Probably somewhere published your ready-made scripts to create minimal templates? It was interesting to see how they work.

Thanks :slight_smile:

Regards Gosto Colletti.

2 Likes

I am glad you find it useful.

No, I have not.

No, I have not published them and never will. What I started publishing is all the information one would need to create them and customize them.

There are two extremes:

a) A guide teaching the reader how to do it themselves and fully understand what they are doing. Then answer occasional questions and provide help in the forum. Over time there will be more people teaching other people and all of them know what they are doing.

b) I through my scripts on Github and then regularly deal with user that didn’t bother to read the guide or the scripts, try to use them and they don’t work or worse: break something. And then they come on the forum and complain.

I want a) but not b). :wink:

If you have a specific question that is not answered by the guide or struggle with a specific use case, please feel free to ask. If I can I will improve the guide and/or help you figure it out. Also all other forum members will see our conversation and hopefully teach both of us. That’s how I hope this will work out.

2 Likes

This thread is very useful for creating a debian-minimal sys-audio. Like you, I am curious about a debian-minimal sys-gui/sys-gui-gpu and will be paying attention for any new posts about it.

1 Like

Recommendation:
At the end of introduction / motivation (before chapter ‘The basics’). I would add something like:

[…] the only way to truly trust code is to understand what it does.

The final result of this guide should be a bash script *.sh, actually your personal bash script with your configuration and settings, which you need to run in dom0.

Questions:
New template available

If I understood correctly, when debian-12 is out all I have to do is change the TEMPLATE value of the script:

SOURCE_TEMPLATE=debian-11-minimal to debian-12-minimal
TARGET_TEMPLATE=deb-11-min to deb-12-min

save modifications to my my-qubes-os-config.sh and run it again in dom0.

Afterwards re-assign all AppVM to new mini-templates and delete all obsolete templates. Does it make sense to also automate this steps or would it be advisable to always to this re-assigning and remove of templates manually?

2 Likes

Thank you @whoami for your feedback, I will incorporate it in the next draft.

when debian-12 is out all I have to do is change the TEMPLATE value of the script

Ideally. That’s what I did when upgrading from debian-10 to debian-11. But of course there is no guarantee, things might break but in case of debian they are usually well documented. Like debian-11 no longer including Qt4.

I see an upgrade just as a special case of (re-)creating your qubes. Once you tested your scripts with a particular version, they will always work with that version and chances are they will continue to work with the next.

Lol. Imagine the poor folks using Fedora and having to do this every 6 months or so. How would you even keep your sanity without automating it?

Afterwards re-assign all AppVM to new mini-templates and delete all obsolete templates. Does it make sense to also automate this steps or would it be advisable to always to this re-assigning and remove of templates manually?

Here is what I do:

qvm-ls --field=name, template > tmp
chmod +x tmp
nano tmp

In nano I then

  1. remove the first line, the dom0 line, all the template lines and all the lines of qubes based on a dvm template. As a result I now have a list of all my qubes and their templates.
  2. add qvm-prefs at the beginning of each line
  3. search and replace deb-10 by template deb-11
  4. safe & exit nano

Then qvm-shutdown --all --wait && ./tmp … and done.

1 Like

Well, I’m using fedora-35 from the very beginning of my daily-driver Qubes using (last November) and fedora-36 is just out a week ago?
Regardless the fact that I started to use debian-11-minimal(s) in parallel, thanks to you, of course.

1 Like

Hi @enmus, I should have looked it up before posting:

Fedora maintains its releases for “approximately 13 months” and there is a new release “approximately every six months”. So one doesn’t have to upgrade every 6 months, but one could.

Regarding debian-minimal, I am uncomfortable with the “thanks to you”. The debian template maintainer is @unman. He does all the work and almost everything I try to (re-)contribute here is more or less a result of him answering my questions (see the archives). He and the other core team members are the ones making all this even possible.

1 Like

I am not. If there wasn’t your topic about minimal(s) I’d probably never use debian.

1 Like

If you wanted to automate this process and put it in a script: (it assumes all your dvm-based vms contain dvm in their name)

qvm-ls --field=name,template,class | grep AppVM | grep -v dvm | awk '{print "qvm-prefs " $1 " template " $2}' | sed 's%deb-10%deb-11%g' > tmp
1 Like

This is awesome!

Going to implement this this week. For the add-feature helper scripts, do those just need to be separate .sh files in the same directory to be called properly?

I think it makes sense to not publish the bash scripts for all the reasons you enumerate, but I wonder if the features and templates tables would make sense as a repo in Qubes-Community/contents/configuration, to enable community engagement?

Am I correct that a package won’t list dependencies that are assumed, due to them being in the base Debian image, but that are not present in Debian minimal? The missing piece that I find intimidating is knowing when a package will break, which is solved by this template/feature combination!

For example, I’d benefit from a signal-desktop or element-desktop ‘template table’ that enumerates the ‘features’ these applications rely on (presumably at least a few libraries etc).

2 Likes

Just a personal note: I found qubes-core-agent-passwordless-root not to be required for Signal.

Update: I was able to install element on the same signal-template so no further requirements should be necessary.

Update 2: since we’re talking about messaging apps, I took the liberty to try out session with the same installed packages, and… it works just fine: repo info: https://deb.oxen.io/

4 Likes

Yes. I just use ~/bin.

Once the note is complete I will offer it to the Qubes-Community project to adopt and extend. For now it’s a first draft (what I could do on one Sunday afternoon) and I intent to work a lot more on it before I’ll consider it finished.

I published it unfinished because that was better then to keep promising something and also to get all the feedback I can.

Interesting question. Unfortunately I don’t know. However I have a hard time imagining that there are “assumed” packages. That doesn’t sound like a good idea to me. I think it’s rather that some packages just have incomplete dependency information … and other dependencies are kind of bugs. Like signal hanging when there is no notification daemon. It should check before calling it.

Coming up, but I’ve also repeatedly posted this particular example to the forum. A little searching should help you find it.

2 Likes

I’m definitely a newbie, but I hate “cruft” (unused stuff), so I’ve been working through this.

I had the worst time with the firewalls. I’d create a template and try to turn it into a dvm template. And that wouldn’t work. So I’d leave it as a template and I couldn’t get the firewall vm to use it as a template.

Finally, tonight, the light dawned.

First you create a template. Install network stuff, the dom0 update thing, and so on, onto that template.

Then you create an ordinary VM from that template…and turn it into a DVM template. That’s what

    qvm-create --template OrigTemplate --label puce DVMTempl
    qvm-prefs DVMTempl template_for_dispvms True
    qvm-features DVMTeml appmenus-dispvm 1

are for and you do not run them on the (first) template!!!)

THAT–a different entity from the template you installed software onto–can now be pointed to by sys-firewall as its template.

Maybe I’m just really dense. Or maybe I’m not really dense and it should be spelled out this blatantly in the directions because most people might fail to realize this. I’ll leave that up to @Sven 's judgment.

By the way, thank you; I’ve learned a lot whilst doing this. I also have about a zillion templates right now! (Life made interesting by the fact that I am compartmentalizing wifi and ethernet, so I end up with separate sys-net and sys-firewall stuff…and all the templates they depend on.

(In fact, this is going through my minimal wifi firewall and wifi net qubes.)

1 Like

For dvm-templates used for sys vms, you could consider qvm-features DVMTeml appmenus-dispvm '' instead.
If you’re not going to generate disp vms on-demand, this will prevent the dvm showing at the top of the Q app-menu.

Good point…I probably do not want that for firewall templates.

On the other hand, for my disposable VM generator which I just created…I do want that.

Thanks!

Okay, so that template I did want to keep in the menu? It runs firefox, so I can browse and blow it away (as someone put it, a very private session).

I got tired of firefox always opening their welcome to firefox and privacy tabs on first start, and so I decided I wanted a “just barely set up” firefox on the DVM template.

No way to just run the DVM Template itself, that I could see; it invariably opens things disposable.

So, I pointed its networking to “none”, unchecked the box where it is a DVM Template, then fired up the browser. I made my changes, got rid of those two stupid tabs, closed it, and went back and made the App VM back into a DVM template.

Now, no matter what I do with that appmenus-dispvm flag, I can’t get the DVM template to show up in the menu at the top.

Is it possible that once I’ve run the template as a regular system, it is forever contaminated somehow and won’t show in the menu? (It does, if I scroll all the way to the bottom of the menu, let me start firefox from there and my settings are preserved…but I don’t want to have to do all that scrolling, it should be at the top where it’s convenient.) If so, how do I get disposable firefox to not show me those doggone tab pages? Should I run it in the AppVMTemplate just to set it up? (I know someone will scream at that thought.)

1 Like