[libvirt-users] how to add mount options for root filesystem inside lxc container

mxs kolo kolomaxes at gmail.com
Mon Nov 13 17:33:31 UTC 2017


 Hi all

We use libvirt 3.0.0 + lxc, disk for container described with
<filesystem/> tag, example:
 <filesystem type='block' accessmode='passthrough'>
      <source dev='/dev/data/lvm-part1'/>
      <target dir='/'/>
</filesystem>
Now we start use ssd disk and think how to provide additional options
for mount root FS in container: "discard" and "nobarrier" options for
XFS.
All level below XFS configured for support trim command ("options
raid0 devices_discard_performance=Y" and "issue_discards = 1")
I try set options inside container in /etc/fstab, it's not worked:
/dev/root       /       rootfs  discard,nobarrier,defaults      0       0
or
/dev/root       /       rootfs  discard,nobarrier      0       0
or
/dev/root       /       rootfs  remount,discard,nobarrier,defaults
 0       0
or
/dev/root       /       rootfs  remount,discard,nobarrier      0       0

I found 2 solutions:
1) use 2 lvm partitions - one for base OS system, and second - for
data. Second lvs attach as block device /dev/vdX inside container.
Now we can mount /dev/vd? with desirable options inside container
2) more tricky variant - before container start, mount her root
filesystem on hardware node with desirable options. Then after
container started, her filesystem would be mounted with same options
as on hardware node.
But probably exists another way ? Has <filesystem/> support for mount options ?

b.r.
 Maxim Kozin




More information about the libvirt-users mailing list