I use autofs to mount some iso files in folder /mnt/iso:
Fedora-13-x86_64-DVD.iso
Fedora-14-x86_64-DVD.iso
Fedora-15-x86_64-DVD.iso
The autofs is working fine and I can see the contents of iso files:
# ls /mnt/iso/fedora.13/
# ls /mnt/iso/fedora.14/
# ls /mnt/iso/fedora.15/
After finish the autofs testing. I force unmount all iso folders:
# umount -l /mnt/iso/*
I then export the /mnt/iso in /etc/exports:
/mnt/iso 192.168.0.0/24(ro,insecure,crossmnt,all_squash)
The NFS service is working fine too. I may mount the /mnt/iso from another machine via nfs client:
# mount -t nfs4 <nfs-server>:/mnt/iso /mnt
I can see all iso mount in /mnt/ folder:
# ls /mnt
dr-xr-xr-x 15 nobody nobody 4096 2011-06-11 10:23 .
drwxr-xr-x 24 root root 4096 2011-02-08 08:45 ..
drwxr-sr-x 7 nobody nobody 4096 2010-05-13 09:06 fedora.13
drwxr-sr-x 7 nobody nobody 4096 2010-10-22 02:32 fedora.14
drwxrwsr-x 7 nobody nobody 4096 2011-05-14 03:50 fedora.15
However, when I try to list the contents for each folder:
# ls /mnt/fedora.13
Nothing shown on screen. Using command like this
# ls /mnt/fedora.13/*
prompt
ls: cannot access /mnt/fedora.13/*: No such file or directory
The only case I success to list out the content of the iso folders in nfs client machine is using this steps:
Unmount nfs share from client machine:
# umount /mnt
using ls to show all sub-trees of /mnt/iso in nfs server:
# ls /mnt/iso/*
The autofs will mount all iso files automatically.
Mount the nfs folder in client machine:
# mount -t nfs4 <nfs-server>:/mnt/iso /mnt
List the sub-trees of /mnt:
# ls /mnt/*
You may then see all the contents in nfs client machine.
However, this defeat the purpose of autofs, as I need to show the contents once in the autofs machine first.
Does anyone has any ideas? I am using the following:
- Fedora 13 x86_64
- autofs-5.0.5-28
- nfs-utils-1.2.2.2-2
I think you have a cart before the horse problem here in that when you export a file system using NFS it locks on to the source direcotory. You are trying to not even have that source directory available at that time and only put something there via a mount later.
This will not work, because once you give NFS a handle on something to share, it will always share that thing, even if it ends up underneath a layer of mounts.
Let's say you setup a directory with a file 'frog' and export it with nfs:
Then you mount it on a client somewhere, you will see the file frog as expected:
Now let's say you mount something else on top of that folder on the server:
Spiffy. But what is nfs serving up?
You can't even get to that file frog on the server because it's got a different thing mounted on top of it, but NFS is serving up that under layer!
To make a long story short, if you want to export your file systems via NFS you will need to have them mounted up properly at the time NFS starts up and exports them and they will need to stick around. Exporting file systems that are themselves mounted using autofs will never work quite right. You will need to permanently mount those ISOs in order to export them via NFS.