PDA

View Full Version : SLES 12 SP2 how to order the Output of df -h ?



nancyemac
11-Sep-2018, 17:36
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. :-)

Best Regards,
Nancye

malcolmlewis
11-Sep-2018, 18:04
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. :-)

Best Regards,
Nancye
Hi and welcome to the Forum :)
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 /

nancyemac
11-Sep-2018, 19:34
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.

jmozdzen
12-Sep-2018, 11:42
Hi nancyemac,


Do you know if it is possible to edit a config file or something similar that would determine the order the output is displayed?

"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

nancyemac
12-Sep-2018, 13:51
Thanks a lot J. I appreciate the explanation and am glad to know where the info from the df command comes from. :-) I might not have a reliable solution, but I definitely learned some things while researching.