Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mount options for disk device mounts #6225

Open
KsaRedFx opened this issue Sep 21, 2019 · 6 comments

Comments

@KsaRedFx
Copy link

commented Sep 21, 2019

Currently you can mount a device into a container by adding it as disk to your containers configuration using: lxc config device add <container> <name> disk source=/dev/<device> path=<relativepath>

While this works great for basic filesystems like ext4, this makes using specific mount options difficult for anything more complex like btrfs.

I'm trying to specifically mount a btrfs subvol inside of a container, and while I can always mount it on the host manually, or just include it in the fstab pointing into /var/snap/lxd/common/lxd/containers/<container>/rootfs/<mountpoint> with my mount options, it seems like a messy solution especially when you get into multiple mount points, and possibly migrating containers.

Unless I've missed already implemented somewhere, or I should be approaching this differently, I believe this would be a useful feature to add.

@stgraber

This comment has been minimized.

Copy link
Member

commented Sep 22, 2019

So I'm still not fond of the idea (this has been suggested before) but as we don't really have a better answer to it, I suspect a raw.mount.options config option on the disk device would probably be okay.

Once we start implementing project restrictions (#6170) this would then get restricted in the same way a raw.lxc config option would be.

@stgraber stgraber added this to the later milestone Sep 22, 2019
@splett2

This comment has been minimized.

Copy link

commented Sep 23, 2019

Hi, Lily and I would like to claim this issue for our group.

@stgraber

This comment has been minimized.

Copy link
Member

commented Sep 23, 2019

Excellent, for this one, I'd expect roughly the following commits:

  • api: Add container_raw_mount API extension
    • Add that string to shared/version/api.go
    • Add a matching entry to doc/api-extensions.md
  • lxd: Add support for `raw.mount.options:
    • Add the new option to lxd/device/disk.go
    • Make the logic in disk.go add the mount options to the returned RunConfig
    • Add matching logic to pass the flags through to forkmount for hotplug
  • doc/containers: Add raw.mount.options
    • Add the new config option to the disk section
  • tests: Add test for raw.mount.options
    • Extend test/suites/container_devices_disk.sh to test the new configuration option. One idea to test it would be to use a tiny vfat filesystem on a loop device, add it to the container with some mount options (I'd suggest using uid= and gid=) and confirm that this is properly used in the container.
    • For loop device handling, you'll want to use truncate to create a small (10MB should do) file, then use mkfs.vfat on top of that file, lastly map it to a loop using our configure_loop_device helper, cleaning things up after the test with deconfigure_loop_device.
    • The test should validate that this works both on at boot time and when hot plugging the device into the container.

@tomponline should be able to help you with any question you may have regarding this issue.

@tomponline

This comment has been minimized.

Copy link
Member

commented Sep 24, 2019

@splett2 Yep let me know if you have any questions.

@splett2

This comment has been minimized.

Copy link

commented Sep 28, 2019

@tomponline

I'm guessing most of the logic we're implementing for lxd: Add support for `raw.mount.options:
would be in the Start() function, and I see that there are already a number of mount options. If a user decides to pass in options via raw mount options, should we ignore any other potential mount parameters?

@stgraber

This comment has been minimized.

Copy link
Member

commented Sep 28, 2019

I think raw.mount.options should get appended to anything we already came up with internally

@stgraber stgraber modified the milestones: later, soon, lxd-3.19 Oct 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants
You can’t perform that action at this time.