Need overlay script to run before /sbin/init

imho we need “-o loop” option to mount

mount -o loop file.ext /mnt/dir

what does run_protected_command ?

i wonder why you check about $RW/image and then set RW to the new mountpoint

I tried the command without the “run_protected_command” bit and the -o loop is assumed (at least by Debian 10.10). Just in case, I’ve added the -o loop bit to my script…

The “run_protected_command” is a function inside that logs whether the command being executed runs successfully.

# Run the command specified in $1. Log the result. If the command fails and safe is selected abort to /bin/init
# Otherwise drop to a bash prompt.
	if [[ ! -z "$1" ]]; then
		log_info "Run: $1"
		eval $1
		if [ $? -ne 0 ]; then
			log_fail "ERROR: error executing $1"

I check to make sure $RW/image.ext4 exists before I try to mount it. Only if it is successfully mounted does the RW variable get changed. Obviously, if you want to create the image file if it doesn’t exist, then additional commands are required, such as:

fallocate -l 10g $RW/image.ext4
mkfs.ext4 $RW/image.ext4
1 Like

I’ve updated the script in my repository: and overlayRoot.conf… Maybe these will help with your mission…