If he router has very low storage, in my case router is DIR-842.
Here is tutorial to expend storage using USB flash drive.
Original guide is from HERE.
Plug in flash drive into USB port.
Open terminal and excute following commands via SSH.
Step 1: Install the required packages
opkg update opkg install block-mount kmod-fs-ext4 e2fsprogs parted
Step 2: Configure rootfs_data
Configure /etc/config/fstab
to mount the rootfs_data
in another directory in case you need to access the original root overlay to change your extroot settings:
DEVICE="$(sed -n -e "/\s\/overlay\s.*$/s///p" /etc/mtab)" uci -q delete fstab.rwm uci set fstab.rwm="mount" uci set fstab.rwm.device="${DEVICE}" uci set fstab.rwm.target="/rwm" uci commit fstab
Or, you can identify the rootfs_data
partition manually, if it is in an MTD partition:
grep -e rootfs_data /proc/mtd
If your rootfs_data
is a UBIFS volume, the above will not work. However, the sed
command at the start of the section should pick up the correct device.
The /rwm
mount will not mount via block
until you've already successfully booted into your extroot configuration. This is because block
has a restriction to only mount from devices that are not currently mounted. And /rwm
should already be mounted at /overlay
. Once booted into your extroot, you can edit /rwm/upper/etc/config/fstab
to change your extroot configuration (or temporarily disable it) should you ever need to.
Step 3: Configure exroot
First command is to define the DEVICE. B'coz the following command will be using DEVICE instead of /dev/sd*.
Second command is (OPTIONAL!) to format the flashdrive to ext4 format and name it as extroot.
DEVICE="/dev/sda1" mkfs.ext4 -L extroot ${DEVICE}
Now we configure the selected partition as new overlay via fstab UCI subsystem:
eval $(block info ${DEVICE} | grep -o -e "UUID=\S*") uci -q delete fstab.overlay uci set fstab.overlay="mount" uci set fstab.overlay.uuid="${UUID}" uci set fstab.overlay.target="/overlay" uci commit fstab
Step 4: Transferring data
mount ${DEVICE} /mnt tar -C /overlay -cvf - . | tar -C /mnt -xf - reboot
Video tutorial: