How to check real available storage space in LEDE (wrt1900acs)

Hi

I would like to get the real available storage space in my router. When I use df -h I get the following:

root@LEDE:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 2.8M      2.8M         0 100% /rom
tmpfs                   250.8M      1.1M    249.7M   0% /tmp
/dev/ubi0_1              23.5M     56.0K     22.2M   0% /overlay
overlayfs:/overlay       23.5M     56.0K     22.2M   0% /
ubi1:syscfg              29.6M    252.0K     27.8M   1% /tmp/syscfg
tmpfs                   512.0K         0    512.0K   0% /dev

The WRT1900ACS v2 comes with 128MB Flash; 512MB DDR3 RAM, LuCI reports Free space: 100% (23.46 MB) how can I find such info through terminal. I am used to lsblk but such is not available on busybox.

I think that 23.46MB is 23.5M (Size) - 56.0K (Used). The math doesn't fit perfectly, but maybe you should omit the '-h'.

@Mijzelf So is 23.46Mb available to install packages then?

root@LEDE:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                 2816      2816         0 100% /rom
tmpfs                   256800      1204    255596   0% /tmp
/dev/ubi0_1              24084        56     22764   0% /overlay
overlayfs:/overlay       24084        56     22764   0% /
ubi1:syscfg              30276       252     28440   1% /tmp/syscfg
tmpfs                      512         0       512   0% /dev

No. That 23.46M is uncompressed space, I guess, while compression is used in the filesystem. So how much data you can store is dependent on it's compressibility.

@Mijzelf so how can I find out the real space available to store new applications please.

If you just want to install packages via opkg, use that 23 MB as the reference. The exact consumed file space will depend on the on-the-fly compression, but that might not be much for binaries.

Additionally, for data files, you also have the "syscfg" partition that is mounted to /tmp/syscfg and has about 28 MB free space. Note that syscfg is visible both alternative firmware partitions, so it can be used to store private files that should be usable regardless if you are runnign the firmware from the secondary or primary firmware partition. (LEDE only uses it to store settings during sysupgrade)

This is from wrt2300acm, so the number are slightly larger. You can notice how df only shows one kernel & rootfs partition, the alternative is hidden, but the syscfg is visible. "/proc/mtd" and kernel log show all partitions.

root@router2:~# dmesg 
...
[    1.046316] nand: 256 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 128
[    1.054009] pxa3xx-nand f10d0000.flash: ECC strength 16, ECC step size 2048
[    1.061183] Bad block table found at page 131008, version 0x01
[    1.067378] Bad block table found at page 130944, version 0x01
[    1.073492] 11 ofpart partitions found on MTD device pxa3xx_nand-0
[    1.079696] Creating 11 MTD partitions on "pxa3xx_nand-0":
[    1.085212] 0x000000000000-0x000000200000 : "u-boot"
[    1.090478] 0x000000200000-0x000000220000 : "u_env"
[    1.095638] 0x000000220000-0x000000260000 : "s_env"
[    1.100778] 0x0000007e0000-0x000000820000 : "devinfo"
[    1.106095] 0x000000820000-0x000000a00000 : "sysdiag"
[    1.111405] 0x000000a00000-0x000005a00000 : "kernel1"
[    1.116874] 0x000001000000-0x000005a00000 : "ubi"
[    1.121993] 0x000005a00000-0x00000aa00000 : "kernel2"
[    1.127448] 0x000006000000-0x00000aa00000 : "rootfs2"
[    1.132905] 0x00000aa00000-0x000010000000 : "syscfg"
[    1.138289] 0x000000260000-0x000000820000 : "unused_area"

.
root@router2:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00200000 00020000 "u-boot"
mtd1: 00020000 00020000 "u_env"
mtd2: 00040000 00020000 "s_env"
mtd3: 00040000 00020000 "devinfo"
mtd4: 001e0000 00020000 "sysdiag"
mtd5: 05000000 00020000 "kernel1"
mtd6: 04a00000 00020000 "ubi"
mtd7: 05000000 00020000 "kernel2"
mtd8: 04a00000 00020000 "rootfs2"
mtd9: 05600000 00020000 "syscfg"
mtd10: 005c0000 00020000 "unused_area"
.
root@router2:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                 5888      5888         0 100% /rom
tmpfs                   256608      1092    255516   0% /tmp
/dev/ubi0_1              55508        76     52564   0% /overlay
overlayfs:/overlay       55508        76     52564   0% /
ubi1:syscfg              71908       424     67780   1% /tmp/syscfg
tmpfs                      512         0       512   0% /dev
/dev/ubi1_0              71908       424     67780   1% /mnt/ubi1_0

@hnyman thanks for the help. In my case tmpfs is really large compared to the rest, is this the norm. Can this be resized and increase the overlay

No. The tmpfs is in ram, so it won't survive a reboot.

Ok thanks. My last questions please if you don't mind me asking can I make a swap file on an external usb?

Why?
Usually that wastes performance.

General consensus is that swap is not necessary if you have well RAM like your device has.

If you have a particular need for a swapfile for a very specific situation, maybe this guide is what you are after:
https://wiki.onion.io/Tutorials/Extending-RAM-with-a-swap-file