Monitoring flash writes in OpenWrt

I use this script:

#!/bin/sh /etc/rc.common
# Copyright (C) 2007 OpenWrt.org

export PATH=/usr/sbin:/usr/bin:/sbin:/bin
export HOME=/root

exec &> /tmp/mount-onedrive.log

START=97
STOP=4

start() {
        rclone mkdir /tmp/OneDrive
        rclone mount "OneDrive:/Scanned Documents/" /tmp/OneDrive/ --use-mmap --buffer-size 0 --cache-dir /tmp --vfs-cache-mode writes --vfs-cache-max-age 0s --umask 000 --allow-other --daemon
}

stop() {
        fusermount -zu /tmp/OneDrive
        rclone rmdir /tmp/OneDrive
}

Is there any way I can verify that this does not result in any writes to flash memory? Is there a way to monitor ongoing writes to flash so I can verify this myself?

1 Like

I guess regular Linux would have iotop or blktrace/blkparse for such purpose but I could not find it readily available in any package feed.

1 Like
opkg install inotifywait
echo 160000 > /proc/sys/fs/inotify/max_user_watches
showwatch() {
	while read THING; do
		case $THING in
			'/dev/pts'*) continue; ;;
			'/tmp/rrd'*) continue; ;;
			'/tmp/ MODIFY 0.db') continue; ;;
			'/dev'*) continue; ;;
			###################################
			'/proc'*) continue; ;;
			'/sys'*) continue; ;;
		esac
		echo $THING
	done
}
inotifywait -e modify -e attrib -e move -e create -e delete -m -r / | showwatch

collectd-mod-disks will give you a broad level... had to use the script above yesterday after seeing something going in collectd-disks... turned out to be;

#option adb_reportdir '/restorefiles/service-dpata/adblock/report'
3 Likes

Thank you so much @anon50098793!

1 Like

The easy quick & dirty approach is to manually look at the overlay filesystem at /overlay/upper

All your changes are written there in a normal rom firmware + r/w overlay flash approach. (Non-overlay systems like SD cards are different.)

Normally the contents are rather small, mainly the /etc/config changes, SSH certificates etc. You can pretty quickly see from the file timestamps if there are any new changes.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.