Wednesday, July 26, 2023

Expand storage for Openwrt router

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:




Config OpenWRT for UNIFI ISP (Malaysia)

 This tutorial only guide for setup an internet connection. Not for IPTV.


Step 1:

 Login into your Openwrt router.


Step 2: Create VLAN

Navigate to Network =>Swtich. Press add VLAN and type 500 into VLAN ID. Then select "tagged" for CPU and WAN. Press save and apply.


Navigate to to Network => Interface. Press edit on WAN then change to protocol PPPOE and eth0.500 as device. Key in your unifi username and password. Press SAVE and SAVE & APPLY.
Within 1 minutes, you should have your internet connection working. 





Step 3: Incase wifi connected but no internet
Navigate to to Network => Wireless, press edit on wifi adaptor. In the Genenal Setup, select lan and wan as a network. Press save and apply.








How to flash Openwrt firmware into DIR-842 (std UNIFI router)

This tutorial valid for router DIR-842 C1, DIR-842-C2 and DIR-842-C3.

Original source is from HERE. You need to download factory firmware and sysupgrade firmware.

Rename the downloaded files into shortest name eg factory and sysupgrade, or else the flash might have error.


Step 1:

Connect your laptop/pc into lan port and the other side plug into any lan port on router. NOT PLUG INTO WAN PORT! Set laptop/pc ip address to 192.168.0.10, 255.255.255.0

Turn router power off. Then press and hold reset button underneath the router.

Then power on, wait until the led blink about 1 second on 1 send off repetedly.


Step 2 :  How to flash factory firmware:

Go to your web browser and type ip address of the router which is 192.168.0.1.

Press browse and select the downloaded factory firmware and press flash.

The flashing start and countdown timer will display in the browser. Wait until timer completed.

DO NOT POWER OFF OR RESET THE ROUTER!


Step 3 :  How to flash sysupgrade firmware:

Change laptop/pc ip address to 192.168.1.10, 255.255.255.0 and open powershell terminal then execute following command.

scp sysupgrade.bin root@192.168.1.1:/tmp/
ssh root@192.168.1.1
sysupgrade -v /tmp/sysupgrade.bin
ssh root@192.168.1.1
opkg update
opkg install luci
reboot

The below video you show you step by step (good for beginner who is new to OpenWrt)



Expand storage for Openwrt router

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 i...