This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UBIFS consumes more nand memory

Hi ,

I  was previously using jffs2 filesystem . Now i migrated ti ubifs ,since ubifs is the latest and effective for NAND flash  .But after loading ubifs file system to a 256 MB nand flash , i could use only 213MB. In this 256 MB 10Mb is used by spl,uboot,and linux. So effectively filesystem should get 246MB . But after loading linux , its showing only 213MB as available memory .

Even if ubifs journal used 10MB ,I should get reset of 236 MB. But UBIFS is using 33MB.

Can anyone suggest proper reason for this .Please fins ttached log snippets .

[    1.639063] 0x000000000000-0x000000020000 : "NAND.SPL"
[    1.645866] 0x000000020000-0x000000040000 : "NAND.SPL.backup1"
[    1.653257] 0x000000040000-0x000000060000 : "NAND.SPL.backup2"
[    1.660583] 0x000000060000-0x000000080000 : "NAND.SPL.backup3"
[    1.667855] 0x000000080000-0x000000180000 : "NAND.u-boot"
[    1.675420] 0x000000180000-0x0000001a0000 : "NAND.u-boot-env"
[    1.682560] 0x0000001a0000-0x0000009a0000 : "NAND.kernel"
[    1.695851] 0x0000009a0000-0x0000009c0000 : "NAND.dtb"
[    1.702366] 0x0000009c0000-0x000010000000 : "NAND.file-system"


[    2.095321] UBI: attaching mtd8 to ubi0
[    3.292491] UBI: scanning is finished
[    3.305754] UBI: attached mtd8 (name "NAND.file-system", size 246 MiB) to ubi0
[    3.313407] UBI: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[    3.320534] UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 512
[    3.327478] UBI: VID header offset: 2048 (aligned 2048), data offset: 4096
[    3.334698] UBI: good PEBs: 1970, bad PEBs: 0, corrupted PEBs: 0
[    3.340995] UBI: user volume: 1, internal volumes: 1, max. volumes count: 128
[    3.348489] UBI: max/mean erase counter: 2/0, WL threshold: 4096, image sequence number: 1924420183
[    3.357999] UBI: available PEBs: 0, total reserved PEBs: 1970, PEBs reserved for bad PEB handling: 40
[    3.367731] UBI: background thread "ubi_bgt0d" started, PID 828
[    3.433180] davinci_mdio 4a101000.mdio: davinci mdio revision 1.6
[    3.439590] davinci_mdio 4a101000.mdio: detected phy mask fffffffe
[    3.446757] libphy: 4a101000.mdio: probed
[    3.450973] davinci_mdio 4a101000.mdio: phy[0]: device 4a101000.mdio:00, driver Atheros 8031 ethernet
[    3.461321] Detected MACID = c4:ed:ba:8b:35:f6
[    3.468310] input: volume_keys.8 as /devices/volume_keys.8/input/input2
[    3.475930] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[    3.502530] UBIFS: background thread "ubifs_bgt0_0" started, PID 842
[    3.563755] UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[    3.570073] UBIFS: LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[    3.579699] UBIFS: FS size: 243159040 bytes (231 MiB, 1915 LEBs), journal size 9023488 bytes (8 MiB, 72 LEBs)
[    3.590109] UBIFS: reserved for root: 0 bytes (0 KiB)
[    3.595422] UBIFS: media format: w4/r0 (latest is w4/r0), UUID 04E018BE-FC53-437E-8090-B783A0B0FD05, small LPT model
[    3.607405] VFS: Mounted root (ubifs filesystem) on device 0:13.
[    3.615680] devtmpfs: mounted
[    3.619262] Freeing unused kernel memory: 348K (c0775000 - c07cc000)

After login:

 df -h
Filesystem                Size        Used        Available   Use% Mounted on
ubi0:rootfs             213.8M      23.5M      190.3M       11% /
devtmpfs                489.7M         0            489.7M       0% /dev
tmpfs                      501.9M      188.0K     501.7M       0% /var/volatile
tmpfs                      501.9M         0             501.9M       0% /media/ram
/tmp                        501.9M       8.0K         501.9M       0% /var/volatile/tmp

Thanks and regards

Gokul CG

  • Forwarding this to the SW team.
  • The 213.8MB UBIFS is reporting is not the TRUE amount of free space, it is a minimum amount.
    This item is discussed in www.linux-mtd.infradead.org/.../ubifs.html
  • Hi,

    I read that . That documentation does not mention that ubifs will not display  actual volume size .As per that documentation ,at any time free space displayed may not be accurate  not the actual volume size. Also ubifs uses an amount of memory as overhead .That can be calculated as  follows

    256 mb Nand flash

    131072 Physical eraseblock size

    126976 Logical eraseblock size


    256 mb nand flash : W =2048

    246 mb partition : P = 1968
    :SP =131072

    :SL =126976

    :BB =0

    :BR = (20 *2048)/1024 = 40

    :B =40 = max(BB ,BR)

    :O:4096

    UBI overhead is (B + 4) * SP + O * (P - B - 4)
    UBI overhead = (40+4)*131072 + 4096*( 1968 – 40 -4 )

    = 5767168 + 7880704

    = 13 MB

    So if i use a 246MB mtd partition ubifs will use 13 mb . rest of 233MB should be available to user . But here Iam getting only 213 mb


    Thanks and regards
    Gokul CG

  • ====================================
    Additional info
    ====================================
    Log for ubifs filesystem with 236 mb partition size in a 256mb nand flash

    Here a i am expected to get 223 mb available for user
    But only 204 mb available for user
    ======================================

    [ 2.095349] UBI: attaching mtd9 to ubi0
    [ 3.244249] UBI: scanning is finished
    [ 3.257379] UBI: attached mtd9 (name "NAND.file-system", size 236 MiB) to ubi0
    [ 3.265032] UBI: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
    [ 3.272160] UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 512
    [ 3.279104] UBI: VID header offset: 2048 (aligned 2048), data offset: 4096
    [ 3.286324] UBI: good PEBs: 1890, bad PEBs: 0, corrupted PEBs: 0
    [ 3.292622] UBI: user volume: 1, internal volumes: 1, max. volumes count: 128
    [ 3.300116] UBI: max/mean erase counter: 2/0, WL threshold: 4096, image sequence number: 1855120085
    [ 3.309618] UBI: available PEBs: 0, total reserved PEBs: 1890, PEBs reserved for bad PEB handling: 40
    [ 3.319309] UBI: background thread "ubi_bgt0d" started, PID 832
    [ 3.383179] davinci_mdio 4a101000.mdio: davinci mdio revision 1.6
    [ 3.389586] davinci_mdio 4a101000.mdio: detected phy mask fffffffe
    [ 3.396758] libphy: 4a101000.mdio: probed
    [ 3.400987] davinci_mdio 4a101000.mdio: phy[0]: device 4a101000.mdio:00, driver Atheros 8031 ethernet
    [ 3.411357] Detected MACID = c4:ed:ba:8b:35:f6
    [ 3.418355] input: volume_keys.8 as /devices/volume_keys.8/input/input2
    [ 3.425957] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
    [ 3.452553] UBIFS: background thread "ubifs_bgt0_0" started, PID 846
    [ 3.506596] UBIFS: mounted UBI device 0, volume 0, name "rootfs"
    [ 3.512927] UBIFS: LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
    [ 3.522536] UBIFS: FS size: 233000960 bytes (222 MiB, 1835 LEBs), journal size 9023488 bytes (8 MiB, 72 LEBs)
    [ 3.532948] UBIFS: reserved for root: 0 bytes (0 KiB)
    [ 3.538260] UBIFS: media format: w4/r0 (latest is w4/r0), UUID D7EB2384-5D76-43BA-B555-CF067D7C2297, small LPT model
    [ 3.550237] VFS: Mounted root (ubifs filesystem) on device 0:13.
    [ 3.558349] devtmpfs: mounted

    =====================================
    root@EVM:~# df -h
    Filesystem Size Used Available Use% Mounted on
    ubi0:rootfs 204.8M 23.5M 181.3M 11% /
    devtmpfs 489.7M 0 489.7M 0% /dev
    tmpfs 501.9M 184.0K 501.7M 0% /var/volatile
    tmpfs 501.9M 0 501.9M 0% /media/ram
    /tmp 501.9M 4.0K 501.9M 0% /var/volatile/tmp
    root@EVM:~#

    ==========================================

    I the boot log there is print FS size: 233000960 bytes (222 MiB, 1835 LEBs), journal size 9023488 bytes (8 MiB, 72 LEBs) ;
    Even if ubifs use journal memory from user memory i should get (222 -8) 214Mb. But currently 204mb available!!!


    What could be the actual reason ?
    did I something wrong ?

    Thanks and regards
    Gokul CG