3

I can run the shell command:

unionfs-fuse /changedata=RW:/immutedata=RO -o cow /data

This mounts the filesystem exactly how I want to. Now I need to incorporate it into the automounter so that it's remounted upon demand.

What I tried in /etc/auto.misc:

/data -fstype=fuse,cow /changedata=RW:/immutedata=RO

What automount --debug -f /etc/auto.master says when I do ls /data:

handle_packet: type = 5
handle_packet_missing_direct: token 19, name /data, request pid 6063
attempting to mount entry /data
lookup_mount: lookup(file): looking up /data
lookup_mount: lookup(file): /data -> -fstype=fuse,cow /changedata=RW:/immutedata=RO
parse_mount: parse(sun): expanded entry: -fstype=fuse,cow /changedata=RW:/immutedata=RO
parse_mount: parse(sun): gathered options: fstype=fuse,cow
parse_mount: parse(sun): dequote("/changedata=RW:/immutedata=RO") -> /changedata=RW:/immutedata=RO
parse_mapent: parse(sun): gathered options: fstype=fuse,cow
parse(sun): invalid location 
dev_ioctl_send_fail: token = 19
failed to mount /data

Google reveals little. Man pages are rather empty on the incorporation of this filesystem.

Maybe I should just put it in /etc/fstab and ask users to remount?

2
  • 4 years on and I can't find an example on the web. Jan 22, 2018 at 3:47
  • 1
    @Sridhar-Sarnobat I have provided an answer that works :)
    – rwenz3l
    Sep 3, 2018 at 21:04

2 Answers 2

3

I know it is too late to answer but adding the following to /etc/fstab in Ubuntu works,

/dir/A=RW:/dir/B=RO /dir/my-union fuse.unionfs-fuse allow_other,cow,use_ino  0   0
2
  • Where should that line be written to? edit your answer to amend it!
    – guntbert
    Mar 7, 2015 at 12:57
  • 2
    I specifically am trying automount since some of this stuff is remote the mount can go stale and/or missing for a variety of reasons Jan 19, 2016 at 16:49
2

automounting unionfs with autofs

TLDR: create the following entry in /etc/auto.misc and include it in your etc/auto.master (as outlined below).

data    -fstype=fuse,cow,allow_other :unionfs\#/changedata=RW\:/immutedata=RO

Bonus: Creating a unionfs automount on top of nfs automounts (to illustrate how to properly configure autofs)

When using NFSv4, enable IMAPD in /etc/default/nfs-common

NEED_IDMAPD=yes

If you want autofs to always create directories for your mounts, enable browse_mode in /etc/autofs.conf

browse_mode = yes

Now to the core part: in your /etc/auto.master add the following lines

# automount all nfs volumes under /nfs and misc filesystems under /mnt
/nfs   /etc/auto.nfs
/mnt   /etc/auto.misc

autofs will mount all filesystems specified in /etc/auto.nfs under /nfs/<mount> and all filesystems specified in /etc/auto.misc under /mnt/<mount>.

In my /etc/auto.nfs I have the following (example) entries:

# FileServer: nfs data configuration
data01 -fstype=nfs4,ro,soft,intr,rsize=8192,wsize=8192,nosuid,tcp,allow_other 192.168.3.100:/mnt/data01
data02 -fstype=nfs4,ro,soft,intr,rsize=8192,wsize=8192,nosuid,tcp,allow_other 192.168.3.100:/mnt/data02
data03 -fstype=nfs4,ro,soft,intr,rsize=8192,wsize=8192,nosuid,tcp,allow_other 192.168.3.100:/mnt/data03
data04 -fstype=nfs4,ro,soft,intr,rsize=8192,wsize=8192,nosuid,tcp,allow_other 192.168.3.100:/mnt/data04
data05 -fstype=nfs4,ro,soft,intr,rsize=8192,wsize=8192,nosuid,tcp,allow_other 192.168.3.100:/mnt/data05

And in my /etc/auto.misc I added the following entry for unionfs

# unionfs mount of all /nfs/data* mounts into /mnt/data
data    -fstype=fuse,allow_other,use_ino,ro,noatime :unionfs\#/nfs/data01=RO\:/nfs/data02=RO\:/nfs/data03=RO\:/nfs/data04=RO\:/nfs/data05=RO

Make sure all files have a permission of 644 ( adjust with chown 644 /etc/auto.{nfs,misc} if necessary)

Then you can enable autofs and restart the service.

# reload autofs to enable all shares
systemctl enable autofs
systemctl restart autofs

You should now be able to do a ls /mnt/data

You must log in to answer this question.

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