External storage automount

Hello!

Wrote following script:

#!/bin/bash

echo "Updating packages..."
opkg update

echo "Installing necessary packages..."
opkg install block-mount kmod-usd-storage kmod-fs-ext4 e2fsprogs

echo "Checking for USB/SD card..."
DEVICE=$(ls /dev/sd* || ls /dev/mmcblk0*)
echo "Found device: $DEVICE"

echo "Formatting the USB/SD card..."
mkfs.ext4 $DEVICE << EOF
Y
EOF

echo "Mounting the USB/SD card..."
mount -t ext4 $DEVICE /mnt

echo "Creating a temporary root directory..."
mkdir /tmp/root

echo "Binding mount the root filesystem..."
mount -o bind / /tmp/root

echo "Copying the root filesystem to the USB/SD card..."
cp /tmp/root/* /mnt -a

echo "Unmounting the temporary root directory and the USB/SD card..."
umount /tmp/root
umount /mnt

echo "Setting up auto-mount..."
block detect > /etc/config/fstab
uci set fstab.@mount[0].target='/overlay'
uci set fstab.@mount[0].enabled='1'
uci commit fstab

echo "Rebooting the router..."
reboot

This script will automate this official instructions from Gl-Inet:

You do not need "extroot" to mount storage.

aaaand gl.inets Openwrt <> OpenWRT, even if the config is correct.

What? What difference?

who knows, their fw is a black box.

read How do GL-iNet devices become supported by official OpenWrt releases?