Nanopi R4S Installation

I’ve just ordered a nanopi R4S to replace my ISP router, Hopefully it will improve things, I have a 500/70 connection plan and I would like to have SQM to improve my bufferbloat, I know this router can do 1 gigabit up and down with SQM enabled so that shouldn’t be a problem, Just a few things I’m unsure of.

  1. Has I need to flash the openwrt file onto a micro SD, What capacity should I go for? I was thinking something like a 128 GB SanDisk Ultra SDXC.

  2. When flashing the openwrt image there is two options, ext4 or squashfs, Which one is preferable.

  3. I’ve used openwrt before on a few older routers when i was on a much slower connection plan and setup SQM perfectly, However, I don’t want to configure openwrt via the SHH/cams as this will blow my mind, I just want to flash the image on the micro SD card and configure the settings via the web GUI.

If there is anymore stuff I should consider or got any tips please let me know :wink:

Thank you

  1. if you actually need more than 100-200 MB (and that only because of the inefficient f2fs fs overhead), you're doing something wrong - it's a router, not a general purpose server (and you really want to reduce your attack surface on your border gateway).
  2. matter of preference, squashfs allows factory resetting.
  3. not seeing a real question here
1 Like

Thank you for your reply.

What Capacity do you recommend to use on the SD card?

(and you really want to reduce your attack surface on your border gateway) - What do you mean in a non technical way :wink:

I was going to flash it with the Squashfs but I’ve seen a few people suggesting to use the ext4 file, what’s the difference? This will be the first time using Openwrt on a SD card I’ve always flashed openwrt on the stock firmwares of routers what support Openwrt, so it’s a learning curve for me,

Previously my R4S was running with an ancient 2GB micro SD :stuck_out_tongue:

For comparison you can see this:

1 Like

There’s me thinking I need a good capacity SD, I will just get a 32GB one, Saved me a few quid thanks :wink:

Now I know I don’t need a decent SD card, on to the Openwrt image, Which image file did you use to flash Openwrt EXT4/Squashfs?

I’ve always used squashfs when flashing the file on standard routers but this is my first time using a SD card with Openwrt so not sure what’s what.

From the previous comment, Squashfs can do factory reset which I prefer as I’ll be using that until I get more familiar around Openwrt, Has long as I can configure the nanopi R4S via a web browser and not the SHH I should be fine from there, and I can install the SQM, my aim, Openwrt/Nanopi R4S - SQM, UpNp as I’m a gamer :+1:

You can have another SD card clone to become a backup when a reset is required.

1 Like

Thank you for the tips really appreciate.

Then plan is to get a 32GB SD card, Flash the (SquashFS) Openwrt Image, Then pop it in the Nanopi R4S and configure the settings via Browser/GUI.

Hopefully all goes well :wink:

Ive just received the R4S I’ve successfully flashed the SquashFS image on to a 32GB microSD card and all running perfect fine, However I’ve noticed I only have around 98 storage/disk space, What’s the easiest way to increase the capacity?

At the moment I just have UpNp LuCI-App package installed but I will be installing SQM soon and other packages but I will hit a wall soon will the limited storage.

As I’m still learning how openwrt works etc I appreciate if step by step instructions please :stuck_out_tongue_winking_eye:

Because system upgrades flash an image to the raw flash storage just like your new installation did, wiping the partition table and filesystem etc, you lose any data in the extended area as well and you need to resize the filesystem every time and restore all your data from backups. I chose to use a ext4 filesystem on a usb flash drive and mount it. It usable on OpenWrt and my linux computer.

After a system upgrade on the sd card, I restore my config, reboot and all works as before with access to the data on the usb drive.

I write the statistics data files to the usb drive so I have long term stats etc. and reduce wear on the sd card minimizing the risk of a system failure due to media going bad. I also keep config backups and other data on the usb storage as well as on my pc.

Using the "Customize installed packages and/or first boot script" at lets you build an image with your added packages.

@efahl has an excellent script to automate the creation of the list of what is installed. See this topic for more info: How to upgrade correctly? (Nanopi R4S)

I have expanded the upper writable portion of the squashfs and can assist in that if you want to learn that process. Let me know.

1 Like

A larger layout will need ext4, but seriously, re-read what slh and you yourself wrote above, and just stick with squashfs. Squashfs is easy - it keeps your settings when you flash an OpenWrt update or reset.

You'll have to work incredibly hard to make use of just ~100MB storage on a gateway router operating system. So don't work so hard. Keep things easy. And for goodness sake, stop worrying about all that unused space on your 32 GB SD card. Let it go to waste already!

No walls in your future. Certainly not soon. Probably never. I'm using squashfs on my R4S with those packages and more and I'm not even close to a wall.

In the unlikely event you ever get close, build your images with the firmware selector and add your packages to its customize list. The squashfs image with packages will be smaller than the alternative of adding the packages to an image later. You'll grab the packages compiled for whatever kernel version snapshot is on if you try snapshot someday. Your packages will already be included no matter what version you choose. It's easier that way. Starting to see the recurring theme here yet :wink: ?


Thanks guys for the support, a lot to take in as you can imagine, I guess 100 MiB isn’t to bad, I have just setup DNS over HTTPS which required two packages leaves me now with 44% used.

I’m trying my best to setup SQM with my connection, Trying to get a A+ plus isn’t not playing ball, I do get a A which isn’t to bad considering and is a step up, Link layer I don’t quite understand I’ve just set that to 42 going on some research from other people threads, I use PPPoE - 500/70

Looking at the docs for the nanopi R4S on openwrt it says: If you restart or change settings with SQM, it will reset the CPU affinity and you will need to re-apply settings.

Putting the commands in rc.local should work, assuming the IRQ numbers are somewhat static, which they seem to be. You may want to double check the IRQ numbers in /proc/interrupts and then do a reboot and check again to make sure they stay the same.

#eth0 IRQ on A53 cores echo f > /proc/irq/35/smp_affinity #eth1 IRQ on A53 cores echo f > /proc/irq/87/smp_affinity #eth0 queue on A72 cores echo 30 > /sys/class/net/eth0/queues/rx-0/rps_cpus #eth1 queue on A72 cores echo 30 > /sys/class/net/eth1/queues/rx-0/rps_cpus

I’m not sure if this is still a ongoing issue with the latest openwrt build, Also I’m not good with SHH only the Web GUI interface.

You are very welcome.

I am no expert on the details of how OpenWrt fills up space with packages, but I can at least share my experience with you. I run snapshot squashfs images built with the firmware selector after adding my custom packages list. This is how much space I have left on my R4S...

After adding these packages to the "customize" list.

luci luci-app-ddns drill luci-app-sqm luci-proto-wireguard luci-app-wireguard curl ca-certificates stubby luci-app-https-dns-proxy luci-app-statistics collectd-mod-thermal collectd-mod-cpufreq luci-app-adblock tcpdump-mini openvpn-openssl openvpn-easy-rsa luci-app-openvpn openssh-sftp-server diffutils iperf3 irqbalance htop coremark speedtest-netperf luci-app-p910nd kmod-usb-printer luci-app-ksmbd ksmbd-hotplug kmod-usb3 kmod-usb-storage kmod-usb-storage-uas f2fs-tools kmod-fs-f2fs hdparm luci-app-hd-idle e2fsprogs kmod-fs-ext4 kmod-fs-exfat libblkid1 kmod-nls-utf8 kmod-nls-cp437 kmod-fs-vfat kmod-fs-ntfs3 wsdd2 hfsfsck kmod-fs-hfs kmod-fs-hfsplus ksmbd-avahi-service luci-app-minidlna pbr luci-app-pbr

Note my package list also includes DNS over HTTPS, SQM, VPNs, and several other goodies, and I still 82 MiB free. If you have significantly less free space left, you might give the firmware selector a try to next time you upgrade your image.

1 Like

Thanks for the Tip, Will definitely keep that in mind, How are you find the R4S performing with SQM enabled? I’m having mixed results

I have DOCSIS 3.0 ISP service, so my baseline unloaded latency is nothing to brag about. But layer CAKE on my R4S is definitely an improvement for loaded latency. I've also had no issues with fairness across my home network with WFH video conferencing, Netflix streaming and kids downloading Steam games in parallel. I'm on a 500/20 speed plan though, so I can't comment personally on Gigabit SQM capability - my R4S CPU is grotesquely underutilized.

I tune CAKE on a wired PC, but I rarely make use of it on a wired client. For the most part I'm on WiFi. And that adds another wrinkle to whether the latency is at the Gateway or in the WiFi connection.

The reason I asked was you need to reset the CPU after a SQM change but I’m not sure if this is just when your running the Full gigabit, I’m on a 500/70 plan but having a issue getting A+ on the bufferbloat score.

What’s your bufferbloat score if you don’t mind me asking?

My ISP throughput is a bit variable throughout the day, so I don't get too greedy on my ingress/egress SQM limits. Waveform is a bit inconsistent in my location as well. I do not set manual CPU affinity in irqbalance. Packet steering is checked. Software flow offloading is checked. I'm running SNAPSHOT r25773-766ec55966 on the R4S and dumb AP. With that, here are my Waveform results today.

Over WiFi on Intel 2x2 ax200 client (in same room as RT3200 dumb AP):
Layer CAKE; Ingress/Egress set 450/20 Mbps
SQM Disabled

Layer CAKE; Ingress/Egress set 450/20 Mbps
SQM Disabled

So basically A+ with SQM, C without. Oh, and per packet overhead is set at 26 bytes.

1 Like

I thought software offloading would interfere with SQM well from what I’ve read anyways, Not quite sure what packet steering does? I now changed to layer of cake with cake, and seeing better results. Link layer 44 again I haven’t a clue what’s the correct number just going on research again. I think the CPU run on the lowest with SQM enable and not the bigger cores, I wouldn’t have a clue how to manually set the cores up.

Software offloading doesn't help SQM directly, but doesn't interfere with it in my experience. I formerly used an ER-X as my gateway and noticed SQM throughput improved slightly with software flow offloading enabled - perhaps due to it freeing up a little CPU for SQM by offloading the few packets not processing through the CPU for SQM on the WAN interface. I leave it on out of habit. It probably makes no difference at all to SQM throughput on the R4S due to there being plenty of CPU to go around regardless on the R4S.

There is one other thing a little different I have set. I've set the min CPU frequency on all cores to 600 MHz to reduce the need for the clock rate to be increased throughout the day to handle CPU load increases. Either way, my ISP speed is by no means maxing out the R4S CPU.

1 Like

I think the main R4S forum thread has a few good discussions on packet steering. NanoPi R4S-RK3399 is a great new OpenWrt device
Search/read through that for good info on packet steering, irq affinity, SQM etc.

Also, the OpenWrt docs wiki has some info. Search that area as well.
One such page that you may find interesting is:

1 Like

I’ve just enabled packet steering and installed the Irqbalence package and now getting A+ happy days, I will try the offloading option and see how I get on as well.

Do you have a issue sometimes when you reboot the device something the LAN doesn’t work, Ive had the issue about three times now?