[HOWTO] compare base/ folders md5sums

Post tutorials, HOWTO's and other useful resources here.
User avatar
Rava
Contributor
Contributor
Posts: 5424
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

[HOWTO] compare base/ folders md5sums

Post#1 by Rava » 21 Nov 2023, 08:21

HOWTO compare base/ folders md5sums, the idea behind this HOWTO is the following:

You have at least 2 different base/ folders, best on different devices (because of backup reasons), and both should have identical modules in them.

For ease of use you have all your main modules in your base/ folder (that is, not only your 00[0123]-* modules, but all of the normally loaded modules)

If that is not the case for you, you have to at least have two files for each setup: one for base/ and one for either /modules or /optional
Or three if you use base/ and /modules and /optional
Then you would move into all these folders and create slightly different named files, e.g. files named like so:

Code: Select all

/tmp/sda1.md5sum_base
/tmp/sda1.md5sum_modules
/tmp/sda1.md5sum_optional
when you use base/ and /modules and /optional

or when all three folders should hold the same amount of files on e.g. sda1 and on e.g. sdc1 and these should all be identical, you can also do this: (for sda1, adjust the path for your base accordingly)

Code: Select all

   # cd /into/sda1/porteus/base
   # md5sum *xzm >/tmp/sda1.md5sum
   # cd ../modules
   # md5sum *xzm >>/tmp/sda1.md5sum
   # cd ../optional
   # md5sum *xzm >>/tmp/sda1.md5sum
In this case, take great care that the first redirect only uses a ">" to overwrite a possible existing file, and all others use ">>" to append their output at the end of the target file.

But this HOWTO assumes all your modules are simply in base/ and we therefore only create one md5sum checklist text file for each Porteus installation.

Let's say one is your main hard drive base/ and the other acts as backup on some external device, and you use some settings modules and some other programs like your main browser and/or yt-dlp that get updated on a regular basis.

Therefore you now want to check if both set of module files are identical.

1. let's assume one base/ folder is on sda1, the other on sdc1
2. therefore we name the resulting files in /tmp sda1.md5sum and sdc1.md5sum
3. let's furthermore assume the base/ on sda1 is also $PORTDIR/base/
4. the base in sdc1 is /mnt/sdc1/porteus/base/
5. make 1st. md5sum checklist text file:

Code: Select all

   # cd $PORTDIR/base/
   # md5sum *xzm >/tmp/sda1.md5sum
6. make 2nd md5sum checklist text file:

Code: Select all

   # cd /mnt/sdc1/porteus/base/
   # md5sum *xzm >/tmp/sdc1.md5sum
7. either compare these two files when the filenames are identical, like so:

Code: Select all

   # cd /tmp/
   # diff sd[ac]1.md5sum
8. If they are not because you use symlinks to symlinks (like I do, because
doing so lets you use the most recent files from the target partition without
any updating of dozens of base/ folders - you only have to update one single
symlink on the target partition that links to the actual module file) do this
to only compare the md5sum checksums and leave out the file names:

Code: Select all

   # cd /tmp/
   # cat sda1.md5sum| cut -c 1-34 >sda1.md5sum.cut
   # cat sdc1.md5sum| cut -c 1-34 >sdc1.md5sum.cut
   # diff sd[ac]1.md5sum.cut
9. In both cases (7. and 8. diff's) the diff command should give no difference, aka no output.
If one or more md5sums differ, investigate and fix the issue.
10.In my case, the files sd[ac]1.md5sum differ because of different filenames
for some modules, but the md5sums compared via sd[ac]1.md5sum.cut are identical:

Code: Select all

   root@rava:/tmp# ls -o *md5sum*
-rw-r--r-- 1 guest 1371 2023-11-20 09:41 sda1.md5sum
-rw-r--r-- 1 guest  700 2023-11-20 09:44 sda1.md5sum.cut
-rw-r--r-- 1 guest 1510 2023-11-20 09:41 sdc1.md5sum
-rw-r--r-- 1 guest  700 2023-11-20 09:45 sdc1.md5sum.cut
   root@rava:/tmp# diff sd[ac]1.md5sum.cut
   root@rava:/tmp# 
Cheers!
Yours Rava