How to Add a USB drive or a SD card as Overlay

When you want to install the Openwrt packages and find our router does not have enough flash memory, you can mount a USB drive or SD card as an external disk to install those packages onto it, like AdGuard Home.

Example with GL-MT1300

Connect your router to the internet, use SSH to login the Openwrt and run below:

root@GL-MT1300:~# opkg update

root@GL-MT1300:~# opkg install block-mount kmod-usb-storage kmod-fs-ext4 e2fsprogs

Check the mount point and format your USB/SD and, for example, /dev/sda1:
root@GL-MT1300:~# ls /dev/sd* (if you are using SD card, it should be ls /dev/mmcblk0*)
root@GL-MT1300:~# mkfs.ext4 /dev/sda1 << EOF



Create the root for USB/SD
root@GL-MT1300:~# mount -t ext4 /dev/sda1 /mnt
root@GL-MT1300:~# mkdir /tmp/root
root@GL-MT1300:~# mount -o bind / /tmp/root
root@GL-MT1300:~# cp /tmp/root/* /mnt -a
root@GL-MT1300:~# umount /tmp/root
root@GL-MT1300:~# umount /mnt


Set auto mount and restart your router
root@GL-MT1300:~# block detect > /etc/config/fstab
root@GL-MT1300:~# uci set fstab.@mount[0].target='/overlay'
root@GL-MT1300:~# uci set fstab.@mount[0].enabled='1'
root@GL-MT1300:~# uci commit fstab
root@GL-MT1300:~# reboot

After reboot, please check if the USB/SD is mounted normally.
For example, if you mounted an 8G USB, you will see the return like this

root@GL-MT1300:~# df -h

If you upgrade or factory reset your router, you need to do it once again.

1 Like