Adjusting size of root device

Hi,

maybe I have an understanding issue and hopefully somebody could help to understand.

I have LXD 2.16 running on a Ubuntu 16.04.3 server. My default profile has following config:

config:
  environment.http_proxy: ""
  user.network_mode: ""
description: Default LXD profile
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: br0
    type: nic
  root:
    path: /
    pool: lxd
    type: disk
name: default
used_by:
- /1.0/containers/haproxy

Following the instructions on https://stgraber.org/2016/03/26/lxd-2-0-resource-control-412/ I want to set the max size for the container haproxy to 10GB by entering

lxc config device set haproxy root size 10GB.

Unfortunately the response error:

The device doesn't exist

lxc config show haproxy shows me following:

architecture: x86_64
config:
  image.architecture: amd64
  image.description: ubuntu 16.04 LTS amd64 (release) (20170811)
  image.label: release
  image.os: ubuntu
  image.release: xenial
  image.serial: "20170811"
  image.version: "16.04"
  volatile.base_image: 0ebf21fb1fef8a9230572cd68c68383018331f3f7865ded0ef86b437e5978370
  volatile.eth0.hwaddr: 00:16:3e:fe:0f:76
  volatile.idmap.base: "0"
  volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":100000,"Nsid":0,"Maprange":65536}]'
  volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":100000,"Nsid":0,"Maprange":65536}]'
  volatile.last_state.power: RUNNING
devices: {}
ephemeral: false
profiles:
- default
stateful: false
description: ""

So there is no device listed. I expected to find the devices eth0 and root but the array is empty. What did I understand wrong or what might be the issue?

Thanx!

Andy

LXD supports configuration at two places:

  • The container itself
  • Profiles

The final configuration is then computed by applying all the profiles in the order that they’re specified for the container, then applying the container configuration itself on top of it. Whichever comes last for any given device or config key wins.

In your case, the container’s disk is configured through a profile (“root” device on “default” profile). If you were to change the size setting on that profile, all containers would be affected, which I’m guessing isn’t what you want.

Instead what you need to do is add that same device to the container directly, therefore masking the one coming from the profile and letting you set config keys like the size at the container level.

lxc config device add haproxy root disk pool=lxd path=/ size=10GB
1 Like

Thank you or the reply!

So do I understand correct, that if a device is configured in the profile I am not able to change e.g. the disk size with

lxc config device add haproxy root disk pool=lxd path=/ size=10GB ?

With LXD 2.0.10 it is possible to set the root device without quota in the profile and add the quota container specific by the above mentioned command. But in 2.16 it returns the “device not found” message.

I am sure I understood the principles of how the configuration is build with profiles and container specific configuration but what I do not understand is, that in LXD 2.0.10 lxc config show haproxy shows devices and in LXD 2.16 devices array is empty with the same profile configuration.

LXD 2.0.10

architecture: x86_64
config:
  volatile.base_image: 0ebf21fb1fef8a9230572cd68c68383018331f3f7865ded0ef86b437e5978370
  volatile.eth0.hwaddr: 00:16:3e:df:40:18
  volatile.eth1.hwaddr: 00:16:3e:d4:bd:9e
  volatile.idmap.base: "0"
  volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":100000,"Nsid":0,"Maprange":65536}]'
  volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":100000,"Nsid":0,"Maprange":65536}]'
  volatile.last_state.power: RUNNING
devices:
  root:
    path: /
    type: disk
ephemeral: false
profiles:
- default
stateful: false

LXD 2.16

architecture: x86_64
config:
  image.architecture: amd64
  image.description: ubuntu 16.04 LTS amd64 (release) (20170811)
  image.label: release
  image.os: ubuntu
  image.release: xenial
  image.serial: "20170811"
  image.version: "16.04"
  volatile.base_image: 0ebf21fb1fef8a9230572cd68c68383018331f3f7865ded0ef86b437e5978370
  volatile.eth0.hwaddr: 00:16:3e:fe:0f:76
  volatile.idmap.base: "0"
  volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":100000,"Nsid":0,"Maprange":65536}]'
  volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":100000,"Nsid":0,"Maprange":65536}]'
  volatile.last_state.power: RUNNING
devices: {}
ephemeral: false
profiles:
- default
stateful: false
description: ""

That doesn’t seem to make any sence for me.

Andy

That’s normal. With LXD 2.9 and the storage pool changes, LXD stopped generating automatic “root” devices for the containers, instead relying on inheritance from the default profile.

So in LXD < 2.9, every container had a local “root” device which you could then set properties directly on. With those LXD versions, adding a “root” device to your default profile would be entirely ignored as all containers would override it.

In LXD > 2.9, containers don’t have any devices by default, they instead rely on inheritance. Meaning that if you want to override it, you have to add a new device to the container with the same name so that it overrides the one coming from the profiles.

“lxc config show NAME” vs “lxc config show --expanded NAME” is pretty useful to see how this all works.

Understand. Thank you for the good explanation!

Andy

$ lxc config device add CONTAINER root disk path=/ size=10GB
Error: Update will cause the container to rely on a profile's root disk device but none was found

Not sure where to go from here?

You forgot the pool= part of what I gave you earlier.

$ lxc config device add Proxy root disk pool=lxd path=/ size=10GB
Error: The "lxd" storage pool doesn't exist

$ lxc config device add Proxy root disk pool=default path=/ size=10GB
Device root added to Proxy
$ lxc exec Proxy -- df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       112G   40G   65G  38% /
$ lxc restart Proxy
$ lxc exec Proxy -- df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       112G   40G   65G  38% /

What’s your storage pool driver? (lxc storage list)

If it’s anything but ZFS, CEPH or LVM, then the output above is expected.
If it’s btrfs, then the quota will still be enforced, if it’s dir, then quotas don’t exist for that.

+---------+-------------+--------+------------------------------------------------+---------+
|  NAME   | DESCRIPTION | DRIVER |                     SOURCE                     | USED BY |
+---------+-------------+--------+------------------------------------------------+---------+
| default |             | btrfs  | /var/snap/lxd/common/lxd/storage-pools/default | 13      |
+---------+-------------+--------+------------------------------------------------+---------+