OpenWRT installation instructions for APU2/APU3/APU4 boards
Article updated on 2021-02-13
OpenWRT doesn't have a typical installation process like pfSense or IPFire. OpenWRT needs to be "flashed" on the disk.
If you have an APU2, APU3 or APU4 router and don't want to go through the manual installation procedure, you can use the automatic OpenWRT installer.
Easy, step by step instructions:
- Prepare Debian bootable USB
- Connect your Debian USB to APU board and boot
- download OpenWRT image onto the Debian USB
- Flash the SSD drive with the OpenWRT image
- Resize the OpenWRT partition to use entire disk space
- Boot OpenWRT from the SSD
Prepare a bootable Debian USB
It doesn't need to be Debian; you can use any Linux distribution. We are recommending Debian because it's relatively quick to create a live USB.
Download a "standard" Debian ISO image from here https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/.
At the time of writing, I'm using debian-live-10.8.0-amd64-standard.iso file. You may see a more recent version, but make sure you download the "-standard.iso" file.
If you are using Windows, flash the image using Rufus: https://rufus.akeo.ie/ if you are using Linux, use dd.
Connect a Serial cable to APU, and a LAN cable to the first NIC port (closest to serial), insert the newly flashed USB and boot the system.
Connect power to APU to boot the system. Your Debian Live USB should now boot and display a boot menu as shown on the screenshot below.
Select the first option and press Tab. Add "console=ttyS0,115200n8" to the end of the command to make the serial connection usable. It should look similar to this:
The password and username to the live Debian USB are
After logging in, type "sudo su" to become root.
Download OpenWRT image onto the Debian USB
Now you should be logged in either via ssh or through the serial cable as shown above. Make sure you have the WAN cable connected, so you have a connection to the internet.
You can now download the latest OpenWRT image from here http://archive.openwrt.org/releases/. Make sure to download x86 / 64 / combined-ext4.img.gz file. We need an image called "combined-ext4.img.gz". Make sure you get the ext4 image; otherwise, you won't be able to resize the partition and use the entire disk space.
At the time of writing, the latest image is 19.07.5, so my wget command looks like shown below.
root@debian:~# wget http://archive.openwrt.org/releases/19.07.5/targets/x86/64/openwrt-19.07.5-x86-64-combined-ext4.img.gz
This should go relatively quickly. Once it's downloaded, unpack it with
root@debian:~# gunzip openwrt-19.07.5-x86-64-combined-ext4.img.gz
This should produce a file named "openwrt-19.07.5-x86-64-combined-ext4.img" (without the .gz extension).
Flash the SSD drive with the OpenWRT image
Once you have the image downloaded, you can flash it on the SSD with the following command:
root@debian:~# dd if=openwrt-19.07.5-x86-64-combined-ext4.img of=/dev/sda bs=4M; sync;
This will take only a second or two because the SSD is relatively fast.
Output should look similar to this:
root@debian:/home/user# dd if=openwrt-19.07.5-x86-64-combined-ext4.img of=/dev/sda bs=4M; sync; 68+1 records in 68+1 records out 285736960 bytes (286 MB, 272 MiB) copied, 1.50062 s, 190 MB/s
At this point, you have a bootable OpenWRT installation. You could power off, remove the USB and boot your APU, but should probably also complete the last step to gain access to the entire space on the SSD.
Resize the OpenWRT partition to use the entire disk space
This is an optional step, but you probably want to do this. When we flashed the OpenWRT image, the partition table was already set to about 270M partition for system. Since we have a 16G disk, we would like to use the entire space.
Make sure you have parted installed (apt-get install parted) .
Boot your debian USB and issue the following command to see your patition table:
root@debian:~# parted /dev/sda print Model: ATA SATA SSD (scsi) Disk /dev/sda: 16.0GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 262kB 17.0MB 16.8MB primary ext2 boot 2 17.3MB 286MB 268MB primary
There are 2 partitions, one for boot and the other one for the data/system. We want to resize the latter partition to use the entire space.
Issue the following command to resize the partition:
root@debian:~# parted /dev/sda resizepart 2 16G Information: You may need to update /etc/fstab.
One this completes, run the previous command again to verify that the entire space is now allocated to the partition
root@debian:~# parted /dev/sda print Model: ATA SATA SSD (scsi) Disk /dev/sda: 16.0GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 262kB 17.0MB 16.8MB primary ext2 boot 2 17.3MB 16.0GB 16.0GB primary
And now the last step is to extend the filesystem on this partition. Run:
root@debian:~# resize2fs /dev/sda2 resize2fs 1.43.4 (31-Jan-2017) Resizing the filesystem on /dev/sda2 to 3902026 (4k) blocks. The filesystem on /dev/sda2 is now 3902026 (4k) blocks long.
Note, if you upgrade OpenWRT from the web interface to a new version, this step will need to be executed again.
OpenWRT web interface
Now you should be able to connect the second port on OpenWRT to your computer and have access to the web interface. From here you can reconfigure WAN and LAN settings as well as install all additional software you may want.
Recommended software packages
When we install OpenWRT on routers for customers, we typically install drivers and other software packages using terminal because it's a little faster.
Here are the packages we are installing by default. You can copy-paste these commands.
opkg update opkg install kmod-leds-apu2 kmod-leds-gpio kmod-crypto-hw-ccp kmod-sp5100_tco kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-usb3 kmod-sound-core kmod-pcspkr amd64-microcode flashrom irqbalance fstrim usbutils curl
opkg install hostapd kmod-ath9k ath9k-htc-firmware ath10k-firmware-qca988x kmod-ath10k
If you have a Quectel 4G modem, you will need these additional packages
opkg install qmi-utils kmod-usb-net-qmi-wwan libqmi luci-proto-qmi uqmi
If you want to run Wireguard, we recommend these packages
opkg install luci-proto-wireguard luci-app-wireguard
And here are packages for OpenVPN (NordVPN etc)
opkg install openvpn-openssl ip-full luci-app-openvpn
If you want to upgrade all packages already installed on your system, you can do it with the following command.
opkg update opkg list-upgradable | cut -f 1 -d ' ' | xargs opkg upgrade
If you have WiFi in your router, you may also be insterested in our OpenWRT AccessPoint / WiFi configuration tutorial
If you have a LTE/4G modem you may find OpenWRT 4G WAN configuration useful.
You may also find some additional instructions about APU hardware in the official OpenWRT documentation.
Tip: check out many similar articles in our Knowledge Base.