Setup and Install Docker Netclient on OpenWRT

Prerequisite: Expand Storage

Installing large packages on OpenWRT can be challenging due to the limited storage space typically available on many routers. While there are several methods to address this limitation, this guide will focus on expanding the root filesystem using an external storage volume, such as a USB device or disk.

This demonstration uses OpenWRT hosted in a cloud infrastructure, but the instructions should also apply to physical routers running OpenWRT. The following steps assume you already have shell access to your OpenWRT device. For more detailed information, please refer to the official OpenWRT extroot documentation: https://openwrt.org/docs/guide-user/additional-software/extroot_configuration

1

Install Required Packages

First, update the package lists and install the necessary packages:

opkg update
opkg install block-mount kmod-fs-ext4 e2fsprogs parted kmod-usb-storage
2

Attach and Identify the Volume

Identify the connected storage device:

ls -l /sys/block
3

Partition and Format the Disk

Partition and format the disk with ext4:

DISK="/dev/sda"
parted -s ${DISK} -- mklabel gpt mkpart extroot 2048s -2048s
DEVICE="${DISK}1"
mkfs.ext4 -L extroot ${DEVICE}
4

Configure the Extroot Mount Entry

Create the extroot mount entry:

eval $(block info ${DEVICE} | grep -o -e 'UUID="\S*"')
eval $(block info | grep -o -e 'MOUNT="\S*/overlay"')
uci -q delete fstab.extroot
uci set fstab.extroot="mount"
uci set fstab.extroot.uuid="${UUID}"
uci set fstab.extroot.target="${MOUNT}"
uci commit fstab
5

Configure a Mount Entry for the Original Overlay

Create a mount entry for the original overlay:

ORIG="$(block info | sed -n -e '/MOUNT="\S*\/overlay"/s/:\s.*$//p')"
uci -q delete fstab.rwm
uci set fstab.rwm="mount"
uci set fstab.rwm.device="${ORIG}"
uci set fstab.rwm.target="/rwm"
uci commit fstab
6

Transfer the Current Overlay to the External Drive

Copy the contents of the current overlay to the external drive:

mount ${DEVICE} /mnt
tar -C ${MOUNT} -cvf - . | tar -C /mnt -xf -
7

Reboot the Device to Apply Changes

Reboot your device:

reboot
8

Modify /etc/config/fstab

Update the /etc/config/fstab configuration:

config 'global'
    option anon_swap '0'
    option anon_mount '0'
    option auto_swap '1'
    option auto_mount '1'
    option delay_root '5'
    option check_fs '0'

config mount
    option target '/overlay'
    option device '/dev/sda1'
    option fstype 'ext4'
    option options 'rw,sync'
    option enabled '1'
    option enabled_fsck '0'

This configuration sets up your external drive as the primary storage for installing packages.

9

Reboot Your Router

Reboot the router to finalize the changes:

reboot

Install Docker

Refer to the OpenWRT Docker guide for more details: https://openwrt.org/docs/guide-user/virtualization/docker_host

Generally, you may need to run containers as specific users, requiring the creation of new users, groups, and setting up the appropriate folder permissions. However, for simplicity in this demo, we’ll use the root user.

Install Docker:

opkg install dockerd docker

Install WireGuard

The safest way to install WireGuard on OpenWRT is via the Web GUI.

1

Update package lists via Web GUI

Navigate to System -> Software and click the Update lists… button.

2

Search and install WireGuard

Search for WireGuard and install wireguard-tools and luci-proto-wireguard (for Web GUI integration).

3

Reboot

Reboot the router after installation.

Join Netmaker Network Via Docker

In the Netmaker UI, add a device by selecting Docker. Copy the docker run command (omitting sudo) and run it on your OpenWRT device.

Last updated

Was this helpful?