Questions about x86_64 openwrt as a vm host

Hi, I am trying to build a vm guest, on top of an x86_64 openwrt host.

The hardware of host is quite limited: an Atom D525 CPU, 2GB memory. The present load of router is pretty light, next to nil.

The guest is planned to be a light weight x86 linux distro, with gui and latest firefox browser. Nothing more.

I only run it occasionally in case some trivial browser-server activities call for a modern desktop browser,
but then I am too lazy or inconvenient to fire up my main desktop PC.

I will connect to the said guest via remote desktop with my pad, so the vm guest would be running headless.

I know that there is a qemu package for openwrt, and D525 does not support vt-x. It's expected the VM guest would not be running at native speed.

Is it feasible? Or the vm guest would simply crash.

I can tolerate a boot time of 5 mins, since I used to run Win 10 X64 natively on the same hardware before I converted it to an openwrt router.

Win10 experience is unpleasant but usable.

Has anyone tried set up such vm host on openwrt with limited hardware like this, would you mind sharing your experience?

Thank you.

The CPU in question doesn't support VT-x, which means virtualization (kvm) is not an option, leaving you with containers (lxc) at best.

Good point. I will also look into lxc.
Thanks.

You should only need about 256 MB RAM for the OpenWrt machine, the rest can go to the big Linux.
Do this to dump the caches the immediately run free to see how much RAM is absolutely being used.
https://www.tecmint.com/clear-ram-memory-cache-buffer-and-swap-space-on-linux

Thank you all.
I have just compiled a build with lxc packages selected. And trying to get through lxc manpage then do some experiments..
The alpine linux images at images.linuxcontainers.org look promising to me.
I'll get back later to share what I find.

Hi, I have messed with lxc a little bit this week. Thanks to all continuously making lxc and luci-app-lxc better and better.

I have just compiled a build with luci-app-lxc package with all its dependencies automatically selected built in. and I also enabled all cgroup and namespace kernel symbols named in make menuconfig, lxc package build config section. Otherwise, lxc will be throwing all kinds of 'unsupported' errors, rendering it unusable.

Thanks again for putting these symbols together for easy access, I have no need to get through various kernel_menuconfig pages.

I have also selected all lxc related packages. Maybe an overkill here, but I don't know which are unnecessary for my experiment.

When the openwrt build is up and running, I simply accessed luci-app-lxc page to create container following a nice guide from Project Turris on luci-app-lxc usage:
https://doc.turris.cz/doc/en/howto/lxc
All are quite the same except my target x86_64, and images from linuxcontainers.org.

Alpine linux container started successfully without network. Performance impact seems to be minimal for my light use.

Now here is the hard part I am not quite there yet, the network config. I'd like to expose the container on the host lan, obtaining lan ip address, to allow remote desktop access, but it's not so easy as Virtualbox "bridged network".

I am trying to figure out how veth and macvlan work, and how to config under openwrt host. Most of the documents online are for big linux distros as host, and not a router distro as openwrt.

I am still trying. Any hint on lxc network is welcomed. Thanks.

I think there are two alternative solutions, enslaving the veth to br-lan, or use macvlan. In the latter case you probably need to also use a macvlan in br-lan instead of the physical interface.

I'm using the following configuration in a lxd profile on Ubuntu. I don't know how the corresponding configuration in lxc would look like.

devices:
  eth1:
    host_name: veth0
    name: eth1
    nictype: p2p
    type: nic
  eth2:
    name: eth2
    nictype: macvlan
    parent: enp1s0f1
    type: nic

aint the real question: why use openwrt as a vm/container host?

Because my needs are quite basic, as original post explained. And the only device running 24x7 in my household,besides the refrigerator, is the openwrt router itself.
I don't want any big distro, or baremetal hypervisor running 24x7, and openwrt as a guest. To me, the network config would be equally complicated, let alone possible performance penalty and much wasted cpu power on this dated platform.
Surely I can invest some resource on a Sandybridge+ platform, then go for a more generic solution. But not now. As a hobby, I am interested to see how much I can do on openwrt as a home server.

You might get farther though with Debian as the host and openwrt as the guest, at least I doubt it would require compiling anything and you would get newer kernels. Still it seems you got stuff working on openwrt. Congrats. Now I think all you need is to set up a veth and bridge one end into br-lan and put the other into the lxc namespace. I imagine there is some way to tell the lxc stuff to do this automatically when you spawn the container?

1 Like