Hyper-V image error message.

I used to test DietPi in VMware, but I wanted to boot DietPi automatically whenever I start my physical machine, Vmware 16 take away that capability so I wanted to swicth to Hyper-V version so it will start the VM automatically.

First of all, I’m new to Hyper-V. Secondly, after I created 2 GB RAM Hyper-V VM (1st gen VM) and attached the disk image downloaded from DietPi website and started the VM, it then upgraded automatically to v8.2.2. However, it’s giving the following (error?) messages. What does it mean, how do I fix it?

looks like some kind of kernel issue related to HyperV. At least I found a couple of similar issues while searching the web

https://community.clearlinux.org/t/dynamic-memory-broken-on-hyper-v/3891
https://patchwork.kernel.org/project/linux-mm/patch/20200114074435.12732-1-Tianyu.Lan@microsoft.com/
https://lkml.iu.edu/hypermail/linux/kernel/2010.1/05123.html

looks like the warning is given every 5 minutes. Wich would fit your screen print https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg2336063.html

What is the actual kernel version you are running

uname -a
Linux DietPi 5.10.0-12-amd64 #1 SMP Debian 5.10.103-1 (2022-03-07) x86_64 GNU/Linux

Memory ballooning is a mechanism to dynamically allocate the memory between host and guest VM. In Hyper-V a start memory size is defined, a minimum and a maximum, and the host can then request memory back from the guest VM, until the minimum is reached, and the guest can request memory from the host, up to the maximum, when required. You should be able to see the values in the Hyper-V-Manager.

I guess the message means that the host is requesting back more memory than the VM is able to safely free (without killing processes, of course). Generally it means that your host system memory is a bit too low to run the VM + the other host tasks/software you used while the messages appear, otherwise it shouldn’t request memory back. It should be also possible to disable ballooning, so the allocated memory size is fixed. If it cannot be done in Hyper-V-Manger, you can disabling the related kernel driver in the VM (from next boot on):

echo 'blacklist hv_balloon' > /etc/modprobe.d/disable-memory-balloon.conf
update-tirfs

OK. I saw the preset settings in Hyper-V, like this.

I then changed the max memory to 2GB.

All I want is to diable the warning message, however.

I Googled and found this, TLTR
https://lore.kernel.org/lkml/20201013135546.3c5b7feb.olaf@aepfle.de/T/ , pprobably the same link from @Joulinar?

My host machine has 32GB RAM, when I was running Hyper-V, the host was just consuming around 6GB.

Your solution could work too. I’ll try it later. Thanks!

OK. So after I set Hyper-V DietPi VM to max dymanic memory 2GB, no futher warning kept popping out on the console except message

hv_balloon: Max. dynamic memory size: 2048 MB

appeared once.

Interesting that this purely informational message is shown with “warning” severity, otherwise you wouldn’t see it on the screen but in dmesg only. Same with the original one, though for a conflict between what the host requests and what the guest can free I see a reason to keep it as warning. Additionally here Hyper-V seems to make use of ballooning without reason, when the host requests memory while it doesn’t require any (32 GiB available, only 6 GiB used). Probably changing this behaviour to only making use of the ballooning driver when really required is what would be the better approach to “fix” these warnings than degrading them to info severity :thinking:.

Btw, by running dmesg -n 3 only kernel errors are shown on screen, no warnings. You can run it at boot:

echo -e '#!/bin/dash\ndmesg -n 3' > /var/lib/dietpi/postboot.d/loglevel.sh

dmesg itself still shows all kernel messages, the above only affects which of these are printed on screen.

We just recognised that for correct ballooning, the hyperv-daemons package is required. Could you test whether this solves the warnings?

apt install hyperv-daemons