astro / microvm.nix

NixOS MicroVMs
https://astro.github.io/microvm.nix/
MIT License
1.24k stars 93 forks source link

Unable to access volume on ZFS disk on systemd service #246

Closed ztr-pen closed 3 months ago

ztr-pen commented 3 months ago

Hi - I am having an issue accessing a volume when i point to a zfs pool on a separate disk and when starting the vm via systemctrl:

microvm = {
 volumes = [{
  mountPoint = "/var";
  image = "/sol/nixos/image.img";
  size = 256'
  }];
....

I have included the following in my configuration.nix on my host:

users.users.microvm.extraGroups = [ "disk" ];

the "journalctl -xe" output is: touch: cannot touch '/sol/images/mvm-adguard.img': Permission denied

When running vm via the cli microvm -r command the filesystem is available and the vm starts.

Is there anything further i need to add to the vm's flake.nix or the host's configuration to access the ZFS location?

Many thanks - Zooter

ztr-pen commented 3 months ago

I will add them I am using qemu as my hypervisor.

astro commented 3 months ago

Does the ZFS dataset have options -o xattr=sa -o acltype=posixacl set?

You do not seem to need the disk group because your block device is not a zvol but a proper file.

ztr-pen commented 3 months ago

@astro - thanks for the repsonse.

I went ahead and set both the existing directory and created a new data set with the -o xattr=sa -o acltype=posixacl set.

the "journalctl -xe" output is still : touch: cannot touch '/sol/microvms/mvm-adguard.img': Permission denied noting i changed the directory location with the new zfs dataset.

Can I chmod the directory to another user? For backup purposes i would prefer the image data be stored on the zfs pool and not in /var

astro commented 3 months ago

Now I see that this is a plain permissions issue. chown away!

Sorry for the confusion, the dataset properties were only important for microvm.shares.

ztr-pen commented 3 months ago

sudo chown microvm /sol/microvms (the zfs directory) did the trick. One thing I need to improve on is file permissions in linux. Thank you @astro