Install LXC and KVM in same host machine in ubuntu

Hi there,
I want to install LXC and KVM in same host in ubuntu but I faced with the package conflict issue in ubuntu .
As you know apt command checking for dependency conflict feature dont let us to install packages that have conflicts.
Currently I used the dpkg with force-all command to install same packages with all conflicts in the same host .
Please let me know is there any official solution to resolve this issue ?

1 Like

Hello @Saeed_Tabrizi,

Installing both LXC and KVM on the same Ubuntu host can lead to package conflicts, particularly between opennebula-node-lxc and opennebula-node-kvm.

Probably the best way is to

  • install opennebula-node-kvm
  • install the dependencies of opennebula-node-lxc
  • run
#!/bin/sh

set -e

ONE_USER=oneadmin
ONE_GROUP=oneadmin

if [ "$1" = "configure" ]; then
    # Make sure required kernel modules are loaded
    modprobe loop
    modprobe nbd

    # Define UID/GID mappings for unprivileged contatiners
    usermod --add-subuids 600100001-600165537 root
    usermod --add-subgids 600100001-600165537 root

    # Provide enough permission for unprivileged users
    chmod o+x /var/lib/lxc

    # Create LXC binding folder
    mkdir -p /var/lib/lxc-one
    chown oneadmin:oneadmin /var/lib/lxc-one
    chmod 751 /var/lib/lxc-one
fi

Then, on the CLI you can check:

root@ubuntu2404-lxc-marketplace-6-99-scpgd-0:~# apt show opennebula-node-lxc | grep Conflicts

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Conflicts: opennebula-node-firecracker, opennebula-node-kvm, opennebula-node-lxd

Eventually, we have some suggestion on this post: https://opennebula.io/blog/experiences/using-lxd-and-kvm-on-the-same-host (which is for LXD, but should work for LXC too).

In any case, you might see some updates on the Issue opened about this, that you have commented already.

Cheers

1 Like

@FrancJP This solution works for me . Thanks

1 Like