You are not logged in.

#1 2020-10-21 19:29:09

speshuric
Member
Registered: 2019-06-04
Posts: 2

[SOLVED] different profiles to boot in virtual and baremetal env.

I have Arch installation on dedicated SSD which is used in bare metal and Virtualbox environment.
Most of things work fine, but I think it would be better if some services/drivers/tunes will differ depends on environment.
In bare metal I don't need vbox guest tools, in virtual environment hardware sensors fail to start and nvidia/broadcom kernel modules is unneeded.

Bootloader - GRUB (BIOS, GPT partitions loaded by UUID)

I can generate separate initrd/kernel images, but:

  • How to detect VBox environment in GRUB?

  • How to enable/disable systemd services depend on environment?

Last edited by speshuric (2020-10-21 20:56:13)

Offline

#2 2020-10-21 19:47:18

loqs
Member
Registered: 2014-03-06
Posts: 19,043

Re: [SOLVED] different profiles to boot in virtual and baremetal env.

Would you consider an alternative approach where you have systemd do the detection?  Systemd#Drop-in_files

[Service]
ConditionVirtualization=false

More complex for the module loading but you could try overriding the automatic module loading rules in /usr/lib/modprobe.d/ and add a systemd service that loads the modules again with ConditionVirtualization=false

Offline

#3 2020-10-21 20:54:51

speshuric
Member
Registered: 2019-06-04
Posts: 2

Re: [SOLVED] different profiles to boot in virtual and baremetal env.

Thank you, loqs, for fast reply. That's exactly what I want. Drop-in files have solved service loading at the least. I've created /etc/systemd/system/lm_sensors.service.d/override.conf for test

[Unit]
ConditionVirtualization=false

(not the Service section, but Unit)
Now it's not loading in VBox.

Now I will try your solution for modules, I think topic can be marked as solved.

Offline

Board footer

Powered by FluxBB