Im having issue with my script that calulates intergity on this version of ubunutu :
cyber@ubuntu:/$ hostnamectl
Static hostname: ubuntu
Icon name: computer-vm
Chassis: vm
Machine ID: 48d13c046d74421781e6c6f771f6ac31
Boot ID: 847b838897ac47eb932f6427361232d1
Virtualization: vmware
Operating System: Ubuntu 20.04.4 LTS
Kernel: Linux 5.13.0-51-generic
Architecture: x86-64
Im wondering if /sys/kernel/tracing/per_cpu/cpu45 is not by any chance an alive file ? because calculating the hash of the files inside takes ifinite time.
If you want to check filesystem integrity, skip the whole /sys
folder - it is an interface to the kernel.
Also it would be better if you also skip /proc
(also kernel interface) and /dev
(special or device files) folders. F.e - you can read from /dev/zero
or /dev/urandom
forever. Network mounts can give you a lot of bright moments too.
Also your script can freeze on reading pipes - it there is enough permissions it can read from a pipe forever.
If I was building such a script, I'll start from the mounts, checked their filesystems and scanned only needed ones. For example if a mount is tmpfs
- it's contents is located in RAM and will be wiped after reboot.
And you totally should check it out - https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard