5

I have various virtual machines running as guests on a Fedora 25 Workstation host. I store virtual disks (and all other personal stuff) on different separate partitions on a second built-in disk. virt-managerruns the virtual machines as qemu user and, in order to boot the disks, I need to execute:

sudo setfacl -R -m u:qemu:rwx /run/media/cl

This lets the qemu user use those virtual disks to boot the VMs. However, if I reboot the host system, the ACL settings are lost and I have to run that command again. When I am using an Ubuntu system as host, the command only needs to be run once and the permission changes survive subsequent reboots.

What can be done to make Red Hat based systems remember the modified ACL settings after reboots as Ubuntu does?

5

It's a hack, but you could just write a quick systemd service to run it on startup, perhaps in /etc/systemd/system/set-qemu-acl.service.

[Unit]
 Description=QEMU ACL Hack
 Requires=local-fs.target
 After=local-fs.target

[Service]
 ExecStart=/usr/bin/setfacl -R -m u:qemu:rwx /run/media/cl

[Install]
 WantedBy=multi-user.target

Then, just enable it.

sudo systemctl enable set-qemu-acl.service

You could also just stick a line in the system cron table.

* * * * * root /usr/bin/getfacl /run/media/cl | grep 'user:qemu:rwx' || /usr/bin/setfacl -R -m u:qemu:rwx /run/media/cl

Or since you're manually mounting, a wrapper script could do it for you, maybe /usr/local/bin/mount-acl.

#!/bin/sh
mount $1 $2
setfacl -R -m u:qemu:rwx $2

Then, just sudo mount-acl /dev/partition /run/media/wherever would get you where you want to go, wouldn't it?

|improve this answer|||||
  • Thank you very much for the answer ! +1 for your effort :) These "hacks" are similar solutions like the ones that @terdon suggested to me as an alternative yesterday in the Ask Ubuntu chat room. Unfortunately this won't work, because the separate partitions are not getting auto-mounted. I would have to add them to the fstab file, which I don't want - for privacy and security reasons I want to continue mounting them manually. – cl-netbox Jun 21 '17 at 15:53
  • If you're actually calling the mount command manually, why not put a wrapper script in /usr/local/bin that automatically sets the ACL at the same time? – Q23 Jun 21 '17 at 16:31
  • Well, actually I was looking for a 'safe built-in' solution, which most probably should exist, otherwise it would mean that Canonical uses some kind of a "hidden hack script" in Ubuntu. Are you having an idea what they "coded" differently than the developers of fedora ? Nevertheless - you provided valid workarounds and so I accept your answer. Thanks again ! :) – cl-netbox Jun 26 '17 at 15:16
  • Workarounds are usually not my first choice, but when it's a weird problem like this, at some point you spend more time than it's worth trying to figure it out. Wish I knew what it was! Maybe the XFS vs ext4 default for Red Hat has something to do with it. – Q23 Jun 26 '17 at 15:24
  • No, I think it's got nothing to do with the file system. I always prepare the disks and partitions manually and install all operating systems on ext4 formatted partitions, the vdisks are located on an ext4 partition as well. – cl-netbox Jun 26 '17 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.