- Views 82
- Likes 0
The Virt-Manager and QEMU/KVM combination is awesome! So is the Virt-Manager lxc management!
But creating an LXC Operating System container? Try an internet search … a total lack of information and old stuff. Virt-manager throws out a useless error about virt-bootstrap, and mentions it won’t work on remote systems, which is what I have. Sure, if you’ve been doing this forever, you know how its done. But if you are just starting, there’s a very steep learning curve.
So, here is how I got this working.
First, my systems, so you can understand how its all connected. I have multiple physical systems that just run my VM’s, and now, my containers. I manage everything though my laptop, that has virt-manager installed on it. Everything runs archlinux, my OS of choice, except for my Ubuntu Minecraft Bedrock Dedicated Servers (BDS) (more on that later). I try to keep everything as lean as possible, and hate installing or running services that are unnecessary.
On my laptop, I installed virt-manager. It includes virt-bootstrap, but it states it only works on the local system, not on the remote server. So, useless.
On my servers, I installed and enabled libvirt. It is not necessary to install lxc, as libvirt will manage your containers. Libvirt, however, has no clear way of creating the rootfs necessary for OS containers.
The solution? Install, but do not enable lxc. Then you can do this:
# lxc-create -n ubuntu1804 -t download
That command creates an OS container called ubuntu1804, and then nicely asks you which linux OS you wish to use. For example, I chose Ubuntu, Bionic (18.04), AMD64 (more than likely the architecture you have…) Then it creates the necessary file system. SWEET!
Now, I like to keep things separated and organized. I didn’t want to use that container for libvirt, cause, to be honest, I don’t know how it impacts everything else… So I created another folder and copied those files into it. That also allows me to copy it in the future to make other containers:
# mkdir /lxc-containers
Then create in there the folder to contain the rootfs:
# mkdir /lxc-containers/bds-hudson
FYI, bds-hudson stands for Minecraft Bedrock Dedicated Server, and hudson is the name of the world…
They copy it over:
# cp -a /var/lib/lxc/ubuntu1804/rootfs/* /lxc-containers/bds-hudson/
The -a flag preserves permissions, ownerships, etc. Not sure if necessary, but why not…
Back in virt-manager, a few things are necessary,
- Make sure you add the lxc connection to your server
- Add the the lxc container storage path ( /lxc-containers )
- Create your container! In the details page, make sure you are pointing to the correct root filesystem path (for example, /lxc-containers/bds-hudson )
Lastly, Ubuntu does not assign root a password, so you will not be able to login to the container. To fix, on the server itself, chroot into it and update your password. For example:
# chroot /lxc-containers/bds-hudson/
Then, while in the container:
Then exit out.
Now you should be able to login and and everything should be working.
Let me add, all this is provided as a means for me to remember and document changes to my systems. Follow at your own risk.