The idea is to extend the existing flash memory in the router hardware containing the rootfs by a writable filesystem on a USB connected SSD. Follow this guide for using an external SSD as extroot overlay to the system.

Installation prerequisits

opkg update
opkg install block-mount kmod-fs-ext4 kmod-usb-storage kmod-usb-ohci kmod-usb-uhci e2fsprogs fdisk blkid

Extroot configuration

The old root from /dev/ubi0_1 is mounted to /rwm. In case that the external SSD is not attached to USB at boot time, /dev/ubi0_1 is used as root instead.

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

Optional, if not already existing: Check external SDD plugged to router by block info. Assuming /dev/sda1 is the USB plugged SSD, first create a ext4 filesystem on it:

DEVICE="/dev/sda1"
mkfs.ext4 ${DEVICE}

Create a mount point in fstab for mounting the external SSD to /overlay at next reboot:

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

Optional, if not already copied: Temporarily mount SDD from /dev/sda to /mnt and copy over all content from actual /overlay to the SSD:

mkdir -p /tmp/cproot
mount --bind /overlay /tmp/cproot
mount ${DEVICE} /mnt
tar -C /tmp/cproot -cvf - . | tar -C /mnt -xf - 
umount /tmp/cproot /mnt
reboot

After a reboot, the mount points /overlay and / should have same free space.

sysupgrade

Sysupgrade replaces kernel and base packages of the openwrt install. With extroot it's not just simple to sysupgrade to the latest image. Also base-files are not upgradeble anymore. This guide is only a directive.

  • Create a list of all installed packages with

    opkg list-installed | awk '{ printf “%s ”,$1 }' > /etc/config/installed_packages
  • Backup the configuration via the luci System → Backup → Actions → Generate Archive button and download it to the PC. This will only save all files listed in System → Backup → Configuration → Open list

  • Reboot without the external SSD

  • The system should be booting into the fallback root overlay mounted from /dev/ubi0_1.

  • Perform a sysupgrade from System → Backup → Actions → Flash new firmware image and take the latest sysupgrade-image from openwrt while keeping configuration

  • Reinstall missing packages according saved list with

    cat /etc/config/installed_packages | xargs opkg install
  • Mount external SSD to local filesystem and copy important base files from /etc to the SSD (see description of temporary mount of SSD above)

  • Reboot with external SSD

After reboot, /dev/sda1 must be mounted to /overlay instead /dev/ubi0_1. If this is not the case, check logread. If

block: extroot: UUID mismatch (root: a04c837c-0c0e-44d9-928d-4538b4898125, overlay: 810d3a76-e866-44cb-bdb8-b5359c92b072)

is reported, the extroot-uuid file in the etc dir of the extroot device must be deleted.

mount /dev/sda1 /mnt
rm /mnt/etc/.extroot-uuid
umount /mnt
reboot

Previous Post Next Post