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
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 overlayRoot.sh 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.
run_protected_command(){
if [[ ! -z "$1" ]]; then
log_info "Run: $1"
eval $1
if [ $? -ne 0 ]; then
log_fail "ERROR: error executing $1"
fi
fi
}
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
I’ve updated the script in my repository: overlayRoot.sh and overlayRoot.conf… Maybe these will help with your mission…
It seems that subvolumes on btrfs volumes can be set readonly, so I’m gonna try to build a btrfs filesystem for my OS and will alter the overlayRoot.sh to use subvolumes to allow a single partition for both read-only/read-write mount points…