If I create an empty file and format a file system on it:

dd if=/dev/zero of=foo bs=1 count=0 seek=10G
mkfs.xfs foo
mkdir bar

How can I non-root mount foo on bar? I was able to do it using udevil, but that didn't mount it rw - ro only.

  • 1
    In general mounting requires privilege. If it didn't then you could mount your own file with known passwords as /etc/shadow and use "su" to become anyone you want. Unix had the idea of a SUID bit to allow programs to have privilege, so it is only a small matter of programming to write a wrapper of the mount system call, and then get "root" to give this program the needed privilege. I don't know udevil, but it seems from a 30 second web search just to need the correct config file to allow you to mount something r/w. Did you try "-o rw"?
    – icarus
    Jul 31, 2022 at 19:08

2 Answers 2


There are several options to mount filesystems as a user.

  • The udisks command can do this, but it only works for removable devices by default.
  • If you have root access, but want to mount the filesystem as a user, you can add an entry to /etc/fstab with the user option to allow mounting of a preconfigured specific mount.
  • The autofs package has a lot more flexibility than the static entry in fstab, and can be configured to allow automatic mounting of images in a specific directory just by referencing a simiarly named sub-mount point in a configured autofs directory.
  • fusermount (and similarly, subtools like squashfuse) can mount filesystem images in some very specific circumstances if configured to allow this.
  • Regarding udisks: What do you mean "by default"? Do you know of an option or patch that removes this limitation?
    – 1N4001
    Sep 21, 2023 at 11:59
  • Figured it out. It works by first using udisksctl loop-setup on the file.
    – 1N4001
    Sep 21, 2023 at 12:50

I'm using RHEL 8...

sudo yum install libguestfs libguestfs-tools -y
guestmount -a xfs.file -m /dev/sda some_dir

mounts the file system in the file xfs.file on the local dir some_dir. Can't tell you why /dev/sda works; the -m is supposed to specify a dir in the disk image that's getting mounted. This isn't an image, but it works nonetheless. It mounts is as type fuse. If sudo is available, modifying /etc/fstab also works as @user10489 pointed out:

/nfs/xfs.file       /nfs/some_dir   xfs rw,user 0  0

That mounts it as a loopback device.

@icarus, fusermount no longer mounts file systems; it only unmounts. udisksctl asks for the root password. Yes, you have to be root to mount (except for the times you don't). I tried -o rw with udevil; it accepts the flag and proceeds to mount it ro anyway.

I tried gio, sucessor to gvfs-mount, and it doesn't seem it's for this case.

  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Aug 4, 2022 at 15:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .