I'm trying to compare the file systems among many other basic services, before and after server reboot to check if any mismatches are present.
I'm currently saving the data to a file and am comparing using diff command
As there are many servers this is not being effective, as this is also checking the difference in the FS size too; as can be seen from below.
diff -rs ./prechecks/file ./postchecks/file
10c10
< udev 7.8G 164K 7.8G 1% /dev
---
> udev 7.8G 156K 7.8G 1% /dev
13c13
< /dev/mapper/vg01-lvopt_IBM 9.9G 8.2G 1.2G 88% /opt/IBM
---
> /dev/mapper/vg01-lvopt_IBM 9.9G 8.3G 1.2G 88% /opt/IBM
18,19c18,19
I've tried If we can use ignore option, but I couldn't get through the logic.
I want to check if we can overcome this.? This is taking toll as I have to deal with many hundreds of servers each time.
Else, Is there a way to ignore the tabs – Size; Used; Avail; Use%; in the output of df -h as seen below which will eliminate the check in the first place.
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-lvroot 20G 16G 4.5G 78% /
Help me solve the challenge. Thanks.!
EDIT1:
df --output=source,fstype,target
is my first choice, but I'm unable to do it on another servers
df: unrecognized option '–output=source,fstype,target'
Try `df –help' for more information.
Any other workaround.?
Best Answer
The
df
command output fields are adjustable via--output
option:The above will output only filesystem names list
If some options are unsupported try the following workaround with
awk
: