how to order the Output of df -h ?

Hello,

I am new to SLES. We will be moving from AIX to SLES and I have a question about how to define the output order of the df -h command.
In AIX you can define the order of the output in /etc/filesystems. But in suse it doesn’t work if you set the order in /etc/fstab.

Is there a way to accomplish this in SLES? I have read the man pages, and googled, but no luck so far. Hopefully one of you can help me. :slight_smile:

Best Regards,
Nancye

[QUOTE=nancyemac;54373]Hello,

I am new to SLES. We will be moving from AIX to SLES and I have a question about how to define the output order of the df -h command.
In AIX you can define the order of the output in /etc/filesystems. But in suse it doesn’t work if you set the order in /etc/fstab.

Is there a way to accomplish this in SLES? I have read the man pages, and googled, but no luck so far. Hopefully one of you can help me. :slight_smile:

Best Regards,
Nancye[/QUOTE]
Hi and welcome to the Forum :slight_smile:
You can use the sort command, eg;

df -h | sort

Note it also depends on the file systems in use, for example if / is of type btrfs then the above command may not be accurate esp if snapper is in use for snapshots. Plus it uses volumes. If your / is btrfs then use;

btrfs fi usage /

Thank you, malcolmlewis. Piping the output into sort was the first thing I had thought of also. However my colleague has asked me to research if there is a way to do this with the basic df command. Do you know if it is possible to edit a config file or something similar that would determine the order the output is displayed?

Thanks again for the help.

Hi nancyemac,

“df” determines the list of mounted file systems by accessing “/proc/self/mountinfo”. This file is kernel-created (see https://www.kernel.org/doc/Documentation/filesystems/proc.txt for a description) and I’ve not seen any information on ordering in there, so likely its ordering is not reliable.

Please remember that there are many more ways to initiate mount but /etc/fstab - for instance, mount and automount units in systemd (or autofs, if you’re using that) - so there will be no reliable single source of ordering that may cover all possibly mounted file systems anyhow.

Regards,
J

Thanks a lot J. I appreciate the explanation and am glad to know where the info from the df command comes from. :slight_smile: I might not have a reliable solution, but I definitely learned some things while researching.