ZyXEL Armor Z2 (NBG6817)

From InToSSH's Tutorials & Scripts
Jump to navigation Jump to search
ZyXEL Armor Z2

OpenWrt installation

  1. Install the OpenWrt factory package using OEM web interface as firmware upgrade This can be found in OpenWrt repo with a name zyxel_nbg6817-squashfs-factory.bin As of writing this the link is here
  2. After flashing is done, the router should reboot and launch with OpenWrt
  3. Connect using LAN port and open address http://192.168.1.1


Increasing the size of rootfs_data partition

When you install the OpenWrt the root_fs (overlay) partition will be only 64MiB, this device has an additional partition /dev/mmcblk0p10 which has 3GiB of space available. To utilize this space you need to replace the built in overlay with this partition.

Unfortunatelly it's not that easy, you have to build your own image from the git source with a patch applied.


  1. Follow this guide to download the source code: https://openwrt.org/docs/guide-developer/quickstart-build-images
  2. Apply the patch to block.c file in this location: <openwrt_source_root>/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/fstools-<version>/ - This can be done using command patch block.c <patch_filename> - patch is included below
  3. Enter the make menuconfig command, select the correct target, add Luci package and few other modules: kmod-fs-autofs4, kmod-fs-ext4, kmod-fs-f2fs, kmod-lib-crc32, block-mount, blockd
  4. Compile images from source and flash the sysupgrade to already flashed router. (Note: You have to run make as normal user, not root)
  5. After flashing is done, follow this tutorial https://openwrt.org/docs/guide-user/additional-software/extroot_configuration - with slight change, mount the old overlay to /tmp/overlay, not to /rwm as the tutorial says
  6. Reboot and you should have working extroot with 3GB
  • Complete .config file which is created by make menuconfig for this specific target is linked below, just rename it correctly.


Beware!! - After doing this mod, if you upgrade OpenWRT using sysupgrade, the extroot won't be available because of UUID mismatch. You have to mount mmcblk0p10 to some other folder, go to <mount>/etc and delete .extroot-uuid file. It might be even necessary to go through the partition definition process (from the extroot tutorial) using the new UUID of extroot.

The patch


 1 ---
 2  block.c | 17 +++++------------
 3  1 file changed, 5 insertions(+), 12 deletions(-)
 4 
 5 diff --git a/block.c b/block.c
 6 index 39212d2..3dfc4a5 100644
 7 --- a/block.c
 8 +++ b/block.c
 9 @@ -1301,7 +1301,7 @@ static int find_block_ubi_RO(libubi_t libubi, char *name, char *part, int plen)
10  	return err;
11  }
12  
13 -#else
14 +#endif
15  
16  static int find_root_dev(char *buf, int len)
17  {
18 @@ -1332,8 +1332,6 @@ static int find_root_dev(char *buf, int len)
19  	return -1;
20  }
21  
22 -#endif
23 -
24  static int test_fs_support(const char *name)
25  {
26  	char line[128], *p;
27 @@ -1363,25 +1361,20 @@ static int check_extroot(char *path)
28  	struct probe_info *pr = NULL;
29  	char devpath[32];
30  
31 -#ifdef UBIFS_EXTROOT
32  	if (find_block_mtd("\"rootfs\"", devpath, sizeof(devpath))) {
33  		int err = -1;
34 +#ifdef UBIFS_EXTROOT
35  		libubi_t libubi;
36  
37  		libubi = libubi_open();
38  		err = find_block_ubi_RO(libubi, "rootfs", devpath, sizeof(devpath));
39  		libubi_close(libubi);
40 -		if (err)
41 -			return -1;
42 -	}
43 -#else
44 -	if (find_block_mtd("\"rootfs\"", devpath, sizeof(devpath))) {
45 -		if (find_root_dev(devpath, sizeof(devpath))) {
46 +#endif
47 +		if (err && find_root_dev(devpath, sizeof(devpath))) {
48  			ULOG_ERR("extroot: unable to determine root device\n");
49  			return -1;
50  		}
51  	}
52 -#endif
53  
54  	list_for_each_entry(pr, &devices, list) {
55  		if (!strcmp(pr->dev, devpath)) {
56 @@ -1585,7 +1578,7 @@ static int main_extroot(int argc, char **argv)
57         }
58  #endif
59  
60 -	return mount_extroot(NULL);
61 +	return mount_extroot("/tmp/overlay");
62  }
63  
64  static int main_mount(int argc, char **argv)
65 -- 
66 2.21.0

Files

File:.config.txt - rename to .config and put to root directory of OpenWrt source. (new version with ipv6 kernel modules compiled in)
File:Diffconfig.txt - Diff of the config file (added Luci, OpenVPN, OpenSSL and IPv6 modules, which are not needed)