NFS and mounted subdirectories

mountnfs

I have two physical disks mounted as such:

sda1 -> /mnt/storage

sdb1 -> /mnt/storage/homes

I've exported /mnt/storage as an NFS share. The client sees all of the contents of /mnt/storage, but it does not show the contents of sdb1 when browsing the /mnt/storage/homes folder. It does display any contents within /mnt/storage/homes before sdb1 is mounted there. Is this a limitation of NFS or are there mount parameters that can be used to follow the other mount as I was expecting?

Best Answer

The client sees all of the contents of /mnt/storage, but it does not show the contents of sdb1 when browsing the /mnt/storage/homes folder. It does display any contents within /mnt/storage/homes before sdb1 is mounted there.

This doesn't make sense. There shouldn't be any contents of /mnt/storage/homes before sdb1 is mounted there, right?

Let's ignore the NFS client for a minute and just focus on the server.

  1. Stop your NFS server, how to do this depends on your linux distribution

  2. umount /mnt/storage/homes
  3. umount /mnt/storage
  4. ls /mnt/storage
  5. mount /dev/sda1 /mnt/storage
  6. ls /mnt/storage
  7. ls /mnt/storage/homes
  8. mount /dev/sdb1 /mnt/storage/homes
  9. ls /mnt/storage/homes

When you list the directory contents in step 4 and step 7, there should be nothing displayed. The files and folders you expect to be in each mountpoint should appear in step 6 and step 9.

The answer to your question is that you have to export both /mnt/storage and /mnt/storage/homes. If you only have a single client, you can use the nohide option on /mnt/storage/homes to avoid needing to explicitly mount it on the client. See the exports man page for more details. That said, I'd recommend avoiding nohide and mounting both filesystems for clarity.

Related Topic