What is using my Flash?

I have 256MB of Flash. How can I tell how it is divided up and what is using it?

To look at the flash partitioning, use

cat /proc/mtd

for simple use in file systems, use standard command "df".
another method of getting full information for MTD devices is the kernel log:

dmesg | more

search for MTD and you will see all paritions (start+end).

WARNING: flash partition are defined by system environemnt and MAY overlap.

1 Like

Additionally for the root mountpoint you can examine the utilization with du -skh /*
For both du and df use the -h option to produce a more human friendly way to display sizes.

1 Like

Further to the suggestions....

root@OpenWrt:/# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00100000 00020000 "u-boot"
mtd1: 0ff00000 00020000 "ubi"
root@OpenWrt:/# du -skh /*
592.0K  /bin
0       /dev
476.0K  /etc
4.0K    /init
1.4M    /lib
0       /mnt
0       /overlay
0       /proc
4.0K    /rom
0       /root
528.0K  /sbin
0       /sys
72.0K   /tmp
4.0M    /usr
0       /var
296.0K  /www
root@OpenWrt:/# df -h
Filesystem                Size      Used Available Use% Mounted on
tmpfs                    60.2M     72.0K     60.1M   0% /tmp
tmpfs                   512.0K         0    512.0K   0% /dev
oot@OpenWrt:/# mount
rootfs on / type rootfs (rw)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
root@OpenWrt:/# cat /proc/cmdline
console=ttyS0,115200n8 earlyprintk root=/dev/sda1 rootdelay=10

dmesg showed:-

[    0.728669] nand: device found, Manufacturer ID: 0x2c, Chip ID: 0xda
[    0.735079] nand: Micron MT29F2G08AAD
[    0.738760] nand: 256 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[    0.746439] Scanning device for bad blocks
[    0.967493] 2 fixed-partitions partitions found on MTD device orion_nand
[    0.974240] Creating 2 MTD partitions on "orion_nand":
[    0.979401] 0x000000000000-0x000000100000 : "u-boot"
[    0.984945] 0x000000100000-0x000010000000 : "ubi"
    1.233967] UBI error: no valid UBI magic found inside mtd1


bootcmd=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec; run bootcmd_lede
bootcmd_exec=if run load_uimage; then; if run load_initrd; then if run load_dtb; then bootm $load_uimage_addr $load_initrd_addr $load_dtb_addr; else bootm $load_uimage_a
ddr $load_initrd_addr; fi; else if run load_dtb; then bootm $load_uimage_addr - $load_dtb_addr; else bootm $load_uimage_addr; fi; fi; fi
bootcmd_lede=run set_bootargs_lede; ubi part ubi; ubi read 0x800000 kernel; bootm 0x800000
bootcmd_uenv=run uenv_load; if test $uenv_loaded -eq 1; then run uenv_import; fi
devices=usb ide mmc
disks=0 1 2 3
if_netconsole=ping $serverip
led_error=orange blinking
led_exit=green off
led_init=green blinking
load_dtb=echo loading DTB $dtb_file ...; load $bootdev $device $load_dtb_addr $dtb_file
load_initrd=echo loading uInitrd ...; load $bootdev $device $load_initrd_addr /boot/uInitrd
load_uimage=echo loading uImage ...; load $bootdev $device $load_uimage_addr /boot/uImage
preboot=run preboot_nc
preboot_nc=setenv nc_ready 0; for pingstat in 1 2 3 4 5; do; sleep 1; if run if_netconsole; then setenv nc_ready 1; fi; done; if test $nc_ready -eq 1; then run start_net
console; fi
scan_disk=echo running scan_disk ...; scan_done=0; setenv scan_usb "usb start";  setenv scan_ide "ide reset";  setenv scan_mmc "mmc rescan"; for dev in $devices; do if t
est $scan_done -eq 0; then echo Scan device $dev; run scan_$dev; for disknum in $disks; do if test $scan_done -eq 0; then echo device $dev $disknum:1; if load $dev $disk
num:1 $load_uimage_addr /boot/uImage 1; then scan_done=1; echo Found bootable drive on $dev $disknum; setenv device $disknum:1; setenv bootdev $dev; fi; fi; done; fi; do
set_bootargs=setenv bootargs console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 $mtdparts $custom_params
set_bootargs_lede=setenv bootargs console=ttyS0,115200 $mtdparts
start_netconsole=setenv ncip $serverip; setenv bootdelay 10; setenv stdin nc; setenv stdout nc; setenv stderr nc; version;
uenv_import=echo importing envs ...; env import -t $uenv_addr $filesize
uenv_init_devices=setenv init_usb "usb start";  setenv init_ide "ide reset";  setenv init_mmc "mmc rescan"; for devtype in $devices; do run init_$devtype; done;
uenv_load=run uenv_init_devices; setenv uenv_loaded 0; for devtype in $devices;  do for disknum in 0; do run uenv_read_disk; done; done;
uenv_read=echo loading envs from $devtype $disknum ...; if load $devtype $disknum:1 $uenv_addr /boot/uEnv.txt; then setenv uenv_loaded 1; fi
uenv_read_disk=if test $devtype -eq mmc; then if $devtype part; then run uenv_read;  fi; else if $devtype part $disknum; then run uenv_read; fi;  fi

When I try installing any pkgs, I'm unable to because there is no room, but I can't tell what is using it all.

you have a NAND flash. This seems not to be initialized (at least from your dmesg listing). But there seems to be a boot device /dev/sda1 (sounds like some USB or fixed disk). The root file system stores only 8MB of data. Is there really OpenWRT running?

It looks very strange, that "df -h" lists only two temporary file systems but not the root file system. Could you make a listing of your device directory /dev ("ls -lR /dev").

There are some instructions in this thread, which I notice you have been referred to in another forum: https://forum.doozan.com/read.php?3,28772,29034#msg-29034

On the bottom of page 1 and the beginning of page 2 someone else has had the same broken mtd partition layout and seem to have found a way to fix it.

1 Like

Many thanks.

I'm trying to follow that thread. I've tried so many different uBoots and variables that I'm not clear as to exactly which variables are required for which system. It looks like I need to set:-

fw_setenv mtdparts 'mtdparts=orion_nand:1M(u-boot),4M(uImage),32M(rootfs),-(data)'

We'll see...

The problem I have is that I need to interrupt the boot loader and boot OpenWrt from the USB stick which I need to do before I can flash it.

That is my understanding anyway...

You're running from RAM (initramfs build). The only drive you have active is a RAM disk.

Use the sysupgrade command to install the regular (not initramd) version to the flash. Then reboot from flash it should work. Assuming you are running the version built for your hardware, sysupgrade is designed to unpack everything and get it in the right place. Directly using mtd write is not likely to work.

Fixed-partition scheme means that the kernel does not use the command line to define partitions. What the kernel does and where it expects to find its filesystems is hard-coded. This is common in OpenWrt since it avoids the often-found problem of having a wrong bootloader configuration. The bootloader configuration does not matter, but the kernel has to be the one built for this model hardware.

This saga would be easier to follow if you quit making new threads related to the same issue.


I was hoping apply sysupgrade using a file on my attached USB stick, but can't work out how to mount the USB stick in OpenWrt.

mount /dev/sda1 /mnt doesn't work. For that I would need to install various pkgs for which I don't have room, hence the thread about used storage in Flash.

Bring up the network and wget or scp the file over to /tmp the usual way.

wget doesn't work with https without additional pkgs, and I don't know if I have enough space left anyway.

Is this what I need?


Just tried anyway using the Shell Link option in Midnight Commander to copy the file, and it seems to have worked.

Is there anything I should try to see if everything is installed as it should be?

The OpenWrt server should also allow http downloads, just change the https to http.

After installing, reboot and watch the console (don't press any keys) to see if it boots from flash.

1 Like

I assumed it needed https because I read somewhere that I needed to install these pkgs before doing the upgrade...

root@LEDE:/# opkg install ca-bundle ca-certificates libustream-openssl ubi-utils

maybe that was unnecessary....

Yes, it boots back up so it appears to be working finally. Phew!!!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.