Checking changes from original FreeBSD installation

Is there any way to tell what, if any changes have been made from the original installation of FreeBSD?

I'm only talking about a comparison of the extracted base.txz and kernel.txz wrt to what is currently installed?

I was under the impression that I could do this using mtree() but don't see how.
 
It's been a really long time since I've considered this, but I think "do initial install, run mtree before making any modifications" then "make modifications and run mtree" "compare mtree output".

Effectively:
extract base.txz and kernel.txz at say /mnt/InitialInstall
diff -ur / /mnt/InitialInstall > differ.txt
 
I was under the impression that I could do this using mtree() but don't see how.
mer is right. With mtree you can generate a specification file of a tree. Then you can compare a possibly modified tree against the specification file. Below are two examples.
Here the specification scripts of a few directories below home are generated. It is based on md5 checksum only. A few files in .mtree.ignore are not tracked. The specification files are .mtree.Archiv and so on.
Code:
cat mtree_init.sh
#!/bin/sh
#
# Build the specification files
# for some directories to track
# permissions and content.

for check in Archiv Dokumente .myconfig News PDFs Projekte
do
mtree -c -k md5 -X ~/Projekte/scripts/.mtree.ignore -p ~/$check > ~/Projekte/scripts/.mtree.$check
done
With the script below the same directories are checked. Differences are printed to STDOUT. There is a little effort which prints the name of the directory above the first line of difference for each directory.
Code:
cat mtree_check.sh
#!/bin/sh
#
# Compare the specification files
# with the actual content of
# some directories to track
# permissions and content.

for check in Archiv Dokumente .myconfig News PDFs Projekte
do
header="no"
for resp in $(mtree -k md5 -X ~/Projekte/scripts/.mtree.ignore -p ~/$check -f ~/Projekte/scripts/.mtree.$check)
do
[ $resp != "" ] && [ $header = "no" ] && echo "*** $check ***" && echo "-------" && header="yes"
echo $resp
done
done
You can add more keys to compare against of use all options and exclude keys. There are of course more checksum algorithms than md5 and so on. It is really worth to try mtree.
 
Thanks chrbr mtree basically produces a hash of a tree. So "hash this" "hash that" "compare hash" if different, deeper dive.
 
According to mtree():-

DESCRIPTION
The mtree utility compares a file hierarchy against a specification,
creates a specification for a file hierarchy, or modifies a specifica-
tion.

I can't work out if a specification for the distributed installation is included or not, so I thought I would extract base.txz and kernel.txz to some directory, say /a and try to create my own specification for comparison with what I installed some weeks ago.

How would I go about comparing this specification against what is actually installed?
 
I can't work out if a specification for the distributed installation is included or not
It is not. mtree(8) is a utility that is not specific to the FreeBSD installation. It works on "any file hierarchy".
As outlined by other in this thread you'd need to create your initial spec first and then compare to that later.
If you want an mtree spec of a "vanilla installation" you're probably best of creating one from a freshly installed host.
 
This is what I have done so far

Bash:
tar zxf base.txz  -C /mnt
tar zxf kernel.txz -C /mnt
cd /mnt
mtree -c /mtree.lst

I'm assuming that /mtree.lst contains a specification for a 'vanilla installation". If so how do I compare it with my current installation?
 
What's listed so far doesn't catch some edge cases, such as things that were hardlinks and are not anymore, and sparse files that are not anymore.

I use a combination of diff and find -ls for that.
 
Back
Top