Unable to allocate the root disk device of arbitrary size when LVM is used


(Leonid Fainshtein) #1

I am using LXD 3.0.3 on Ubuntu 18.0.4 with LVM storage.
I created a profile where I defined size of the root disk device as 3500MB:
root: path: / pool: default size: 3500MB type: disk
I created a container with this profile but I see in lvs output that the LVM volume is 3 GB instead of expected 3.5GB
When I define the device size as 3700MB then I get volume 4GB. in other words, the actual disk size is a rounded number of the requested size…
The problem doesn’t happen when ZFS backend is used.
Is this a bug?

Thank you,
Leonid


(Leonid Fainshtein) #2

Also, when the size is rounded down sometimes it is impossible to start the container:

$lxc start leo35
Error: Common start logic: Mount /dev/default/containers_leo35 onto /var/lib/lxd/storage-pools/default/containers/leo35: invalid argument
Try lxc info --show-log leo35 for more info

But there is nothing in the log…


(Stéphane Graber) #3

That’s because you most likely mean 3500MiB rather than 3500MB, that’s the usual 1000 vs 1024 kB issue with storage. I actually updated our container documentation earlier this week to directly list both units.


(Leonid Fainshtein) #4

I made two tests:

  1. I defined size=3400MiB in a profile, created a container and successfully started it. The LV was created as 4GB:
    $ lxc profile copy default p3400
    $ lxc profile edit p3400 (configure “size: 3400MiB”)
    $ lxc init cpbx-5.0.63 c3400 -p p3400
    Creating c3400
    $ lvs ( it shows “4.00g” for “containers_c3400”)
    $ lxc start c3400

  2. I defined size=3200MiB in a profile, created a container and was not able to start it. The LV was created as 3GB:

$ lxc profile copy default p3200
$ lxc profile edit p3200 (configure “size: 3200MiB”)
$ lxc init cpbx-5.0.63 c3200 -p p3200
Creating c3200
$ lvs ( it shows “3.00g” for “containers_c3200”)
$ lxc start c3200
Error: Common start logic: Mount /dev/default/containers_c3200 onto /var/lib/lxd/storage-pools/default/containers/c3200: invalid argument
Try lxc info --show-log c3200 for more info

The log doesn’t show any error:
$ lxc info --show-log c3200
Name: c3200
Remote: unix://
Architecture: x86_64
Created: 2019/01/11 07:09 UTC
Status: Stopped
Type: persistent
Profiles: p3200

Log:

The lxd.log:
t=2019-01-11T07:09:52+0000 lvl=info msg=“Creating container” ephemeral=false name=c3200
t=2019-01-11T07:09:52+0000 lvl=info msg=“Created container” ephemeral=false name=c3200
t=2019-01-11T07:10:04+0000 lvl=warn msg=“Unable to update backup.yaml at this time” name=c3200
t=2019-01-11T07:10:09+0000 lvl=warn msg=“Unable to update backup.yaml at this time” name=c3200

My conclusion:

  1. The same problems happen for both MB and MiB. I mean that the LV size is always rounded down or up depending on the requested size and the suffix (MB or MiB).
  2. When LV size is rounded down then container fails to start.
  3. The problem doesn’t happen when ZFS is used.