Creating a stateful vm

I’m trying to save the state of a vm. I tried;
lxc stop --stateful also lxc snapshot --stateful
and I got an error ‘Error: Stateful stop requires migration.stateful to be set to true’ .
So I tried;
lxc config edit and tried to edit ‘stateful’ to true. But seems you can’t edit it directly. Any solution to this?

Try lxc config set <instance> migration.stateful=true with the VM stopped.

Error: Stateful start requires that the instance limits.memory is less than size.state on the root disk device

I see limits.memory but size.state, i’m lost on that.

Size.state is the size of the state volume, which by default is small as it only stores the VM metadata. But to do stateful operations you need to set that to sufficiently big to store the vm’s memory. So suggest setting it to same size as vm’s limits.memory setting.

lxc config device override VMNAME root size.state=4GiB

‘Error: The device already exists’

If the device exists use “set” rather than “override” command.

Working great! These commands will definitely take some getting used to, for those of us just joining the lxc wagon. Thanks for the assist and patience!

1 Like