Volume.block.mount_options not working

Hey, I got issues with the mount options in LXD. I just build a testsetup with Ubuntu 18.04 and LXD 4.1 via snap install and created a default storage on LVM. Then I created a test container with Ubuntu 18.04 to check if i get noatime working as mountoption. But it does not work. The container still shows these mountoptions:
root@vast-tick:~# cat /proc/mounts
/dev/vg00/containers_vast–tick / ext4 rw,relatime,discard,stripe=16,data=ordered 0 0

lxc config show vast-tick:
architecture: x86_64
config:
image.architecture: amd64
image.description: ubuntu 18.04 LTS amd64 (release) (20200519.1)
image.label: release
image.os: ubuntu
image.release: bionic
image.serial: “20200519.1”
image.type: squashfs
image.version: “18.04”
volatile.base_image: 70d3dcaabcffb1aa1644d0ce866efcb141742179e94ad72aefb8d3502338a71f
volatile.idmap.base: “0”
volatile.idmap.current: ‘[{“Isuid”:true,“Isgid”:false,“Hostid”:1000000,“Nsid”:0,“Maprange”:1000000000},{“Isuid”:false,“Isgid”:true,“Hostid”:1000000,“Nsid”:0,“Maprange”:1000000000}]’
volatile.idmap.next: ‘[{“Isuid”:true,“Isgid”:false,“Hostid”:1000000,“Nsid”:0,“Maprange”:1000000000},{“Isuid”:false,“Isgid”:true,“Hostid”:1000000,“Nsid”:0,“Maprange”:1000000000}]’
volatile.last_state.idmap: ‘[{“Isuid”:true,“Isgid”:false,“Hostid”:1000000,“Nsid”:0,“Maprange”:1000000000},{“Isuid”:false,“Isgid”:true,“Hostid”:1000000,“Nsid”:0,“Maprange”:1000000000}]’
volatile.last_state.power: RUNNING
devices: {}
ephemeral: false
profiles:

  • default
    stateful: false
    description: “”

lxc storage show default:
config:
lvm.thinpool_name: LXDThinPool
lvm.vg_name: vg00
source: vg00
volatile.initial_source: vg00
volume.block.mount_options: noatime
description: “”
name: default
driver: lvm
used_by:

  • /1.0/containers/vast-tick
  • /1.0/images/70d3dcaabcffb1aa1644d0ce866efcb141742179e94ad72aefb8d3502338a71f
  • /1.0/profiles/default
    status: Created
    locations:
  • none

Is there something wrong? I got the config parameter via https://lxd.readthedocs.io/en/latest/storage/ documentation.

@tomp can you take a quick look at that one?

Hi @stgraber and @tomp

I also tested this option yesterday.
I checked that noatime does not apply when the container is executed and looking at the contents of /proc/mounts.

There are two questions.

First, from the container’s point of view, is root(/) recognized as a block device of lvm? It doesn’t seem to be my opinion.
Because if I install lvm2 in the container and run the vgs, lvs, pvs commands, nothing happens.

Second, there is a saying in the Red Hat documentation that it is safe to assume that there is no overhead for atime from at least version 6.
Why we need to do noatime when mounting?

Thank you.

Yep will take a look

You wont be able to run LVM commands inside an unprivileged container.

@tobias I have identified that the behaviour in the LVM driver is slightly different to the Ceph driver in resolving mount options, in that the LVM driver does not consider the pool’s volume.block.mount_options setting if the volume’s block.mount_options setting is empty. This can be fixed easily.

However for both LVM and Ceph drivers, when creating new volumes the value of the storage pool’s volume.block.mount_options is copied to the volume’s block.mount_options setting at create time.

Furthermore, we can guarantee that all existing LVM and Ceph volumes (that have not been modified manually) have a block.mount_options set, even if the storage pool doesn’t have a volume.block.mount_options value set, because the VolumeFillDefault populates the volume’s block.mount_options key with discard if nothing else is available.

So changing volume.block.mount_options on the storage pool will not affect existing volumes anyway (unless someone has purposefully gone in and unset the volume’s block.mount_options setting).

So in this case, even with the LVM bug fixed, you would still need to modify the volume’s block.mount_options setting as so:

lxc storage volume set lvm container/c1 block.mount_options=discard,noatime

Also, worth mentioning, that unless you have very specific requirements, the default mount options (in my kernel at least) is to use relatime with ext4. This seems to be generally preferable to noatime because it provides similar before benefits (avoiding the write to disk every time a file is accessed) whilst still maintaining compatibility with applications that expect the access time to be same or newer than the modified time. It also helps maintain a course-grained (24 hour resolution) access time for each file.

See https://blog.confirm.ch/mount-options-atime-vs-relatime/

@stgraber I’ll put up a PR to unify the mount option resolution logic for ceph and LVM, but is what I describe above what you would expect in relation to the way that volume.block.mount_options is ignored if volume’s block.mount_options is set (and it is always set with something by default)?

PR opened here:

Oh I also spotted another issue in the LVM driver that will prevent the command I suggested from working. It was looking for the volume’s block.mount_options setting in the pool config only. So would never find it. The PR above fixes it though.