1

I have rootfs / but within that I have /mnt/another_rootfs which contains a second mounted rootfs.

I want to compare the files in them... but when I do somthng like: diff -r / /mnt/another_rootfs I start to get all the mount points being compared (which I am not so interested in) but also the / rootfs will also contain the second mounted /mnt/another_rootfs ... that is causing issues as well.

So I really just want to diff the files that are actually mounted on / vs the files mounted on /mnt/another_rootfs and not recurse into other mounts.

Is that possible?

2 Answers2

1

A command line solution is easy, when you reverse the question to "I want to diff /mnt/another_rootfs /":

find /mnt/another_rootfs -xdev -type f -print0 | \
    xargs -0 -r $HOME/bin/diffwithslash

Where $HOME/bin/diffwithslash is something like:

#!/bin/bash
while [[ $# -gt 0 ]] ; do
   afile="$1"
   shift
   bfile="${afile#/mnt/another_rootfs}"
   if [[ -f "$afile" ]] && [[ -f "$bfile" ]] ; then
       diff "$bfile" "$afile"
   fi
done
exit 0
waltinator
  • 36,399
  • This would work : ) - but its more a script solution, I didn't really want to write a script if I could avoid it :o – code_fodder Oct 02 '18 at 08:08
1

You can mount the partition which holds the /-file-system of the currently booted installation to a second mount-point and compare this mount-point with the mount-point of the other /-file-system.

Use lsblk -f to check which partition is mounted at /.

Then mount the partition with

sudo mount -t ext4 /dev/sdXY /mnt (replace XY with the found value)

Compare /mnt with the the folder which is the mount-point of the other /-file-system.

Unmount with sudo umount /mnt

mook765
  • 15,925
  • That helps - but the sub-mount points will still be there (like /proc and /sys etc...) is there a way to not recurse into these? – code_fodder Oct 02 '18 at 08:07
  • The mount-points /proc and /sys are empty folders on the disk. They are only populated in a running system. E.g the procfs provided by the kernel will be mounted to /proc. – mook765 Oct 02 '18 at 08:29