AIX

 View Only

 gnu 'df' vs AIX 'df' show differently for overmounted f/s

Owen Edwards's profile image
Owen Edwards posted 11/26/24 10:49 PM

I've noticed that if a filesystem is (wrongly) overmounted then gnu 'df' output differs from AIX 'df'.

This mostly happens when the 'second/lower' filesystem is an NFS mount, and the local filesystem is unmounted/remounted during a data-refresh exercise, but the NFS filesystem is not remounted afterwards.

eg.

$ mount

...snipped for brevity...

       /dev/testlv2      /local/fs1/mp2   jfs2   Nov 27 14:12 rw,noatime,log=INLINE
       /dev/testlv1      /local/fs1       jfs2   Nov 27 14:12 rw,noatime,log=INLINE

You can see I've mounted them the wrong way around.....just a test of what sometime happens with NFS mounts.

AIX 'df':

# /usr/bin/df -g | grep -E 'test|Use'

Filesystem    GB blocks      Free %Used    Iused %Iused Mounted on
/dev/testlv2        0.25      0.25    1%        6     1% /local/fs1/mp2
/dev/testlv1        0.25      0.25    1%        6     1% /local/fs1

vs GNU 'df':

# /opt/freeware/bin/df -h | grep -E 'otest|Use'
Filesystem                     Size  Used Avail Use% Mounted on
/dev/testlv1                    256M  2.4M  254M   1% /local/fs1

testlv2 doesn't even get a mention.

Querying them specifically, using the current working directory:

# cd /local/fs1/mp2

# /usr/bin/df -g .

Filesystem    GB blocks      Free %Used    Iused %Iused Mounted on
/dev/testlv1        0.25      0.25    1%        6     1% /local/fs1

versus GNU:

# /opt/freeware/bin/df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/testlv2     256M  2.4M  254M   1% /local/fs1/mp2

However, things are 'inaccurate' for both when you specify the full path, similar to the 1st 'df' output:

# /usr/bin/df -g /local/fs1/mp2
Filesystem    GB blocks      Free %Used    Iused %Iused Mounted on
/dev/testlv2        0.25      0.25    1%        6     1% /local/fs1/mp2

vs GNU:

# /opt/freeware/bin/df -h /local/fs1/mp2
Filesystem      Size  Used Avail Use% Mounted on
/dev/testlv2     256M  2.4M  254M   1% /local/fs1/mp2

Is this expected/known behaviour??

I realise the mounts are the real cause of the issue, but I would have expected the 'df' cmds to behave in a similar manner.

Thanks.

Owen

CHRISTOPHER WICKREMASINGHE's profile image
CHRISTOPHER WICKREMASINGHE

Hi Owen

The "expected" behaviour would typically be dictated by POSIX, but it does not seem to address over-mounts either in the df or statvfs() pages.

https://pubs.opengroup.org/onlinepubs/9799919799/

I know this was not your question, but one way to prevent accidental over-mounts is to avoid creating a mount point directory in the grand-parent file system. In your example, the /local filesystem would have a /local/fs1 directory, but not /local/fs1/mp2.  An attempt to mount /local/fs1/mp2 before /local/fs1 would then fail.

Phill Rowbottom's profile image
Phill Rowbottom IBM Champion

The difference in behaviour between the different df commands isn't something that I've noticed before.  But when I started with Unix, you always had to make sure to mount filesystems in the correct order so that a lower level mount wouldn't "hide" the parent mount(s).  I'm still particular about the order in which filesystems are mounted (/etc/filesystems, /etc/fstab) so that this issue is avoided.

Phill.

José Pina Coelho's profile image
José Pina Coelho

Depending on how the df commands identify the filesystem, you get different results.  Under POSIX, this is undefined, so all responses are "OK".

The AIX command stats() the directory to get the filesystem, and in the case of reversed mounts, /local/fs1/mp2 is a directory inside the /local/fs1 filesystem, so it gives you the df of the /local/fs1 filesystem.

The GNU command seems to use the mount points to select the filesystem.

In both cases, the result is "correct but useless/misleading".

Since it's almost impossible to avoid the creation of a /local/fs1/mp2 directory inside the /local filesystem, my workaround for these issues is:
For hierarchical filesystems, flatten the hierarchy elsewhere, then use symbolic links.

e.g.
I don't usually do this, for if you want the paranoid approach: On the rootvg, create a 1PP filesystem /flat, and a 1PP filesystem /local, create a file in each   (this will contain any mount mistakes by now allowing any meaningful writes under the mountpoints).

Change your filesystem mountpoints to:
/flat/fs1.root

/flat/fs1.mp2

On the /flat/fs1.root filesystem: rmdir mp2 ; ln -s /flat/fs1.mp2 /flat/fs1.root/mp2
On /local, rmdir fs1 ; ln -s /flat/fs1.root /local/fs1

If you want to use mp2 regardless of fs1 being mounted, before mounting fs1, create a symbolic link in the mountpoint to /flat/fs1.root/mp2

Results:

/flat: (root:system, 755)
fs1.root - directory (root:system, 755), mountpoint for test1lv
fs1.root/mp2 - symbolic link to /flat/fs1.mp2
fs1.mp2 - directory (root:system, 755), mountpoint for test2lv

/local: (root:system, 755):
fs1 - symbolic link to /flat/fs1.root

/flat/fs1.root: (test1lv)

mp2 - symbolic link to /flat/fs1.mp2

(And that's why I avoid nested filesystems like the plague)