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.

Problem Automatically Mounting UBIFS Partition with fstab

Hello,

I am using a custom board based on the BeagleBoneBlack, but using NAND instead of eMMC. Linux kernel is 3.12. I am having some problems using UBIFS. We would like to use a UBIFS partition to store some of our application specific log files.

In Linux, I can create a UBIFS partition fine following http://processors.wiki.ti.com/index.php/UBIFS_Support#Mounting_a_NAND_partition_using_UBIFS as follows:

root@beaglebone:~# ubiformat /dev/mtd10 -s 2048 -O 2048
ubiformat: mtd10 (nand), size 8388608 bytes (8.0 MiB), 64 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 63 -- 100 % complete  
ubiformat: 64 eraseblocks have valid erase counter, mean value is 0
ubiformat: formatting eraseblock 63 -- 100 % complete 
root@beaglebone:~# ubiattach /dev/ubi_ctrl -m 10 -O 2048
UBI device number 0, total 64 LEBs (8126464 bytes, 7.8 MiB), available 38 LEBs (4825088 bytes, 4.6 MiB), LEB size 126976 bytes (124.0 KiB)
root@beaglebone:~# ubimkvol /dev/ubi0 -N ubifs_volume -m
Set volume size to 4825088
Volume ID 0, size 38 LEBs (4825088 bytes, 4.6 MiB), LEB size 126976 bytes (124.0 KiB), dynamic, name "ubifs_volume", alignment 1
root@beaglebone:~# mount -t ubifs ubi0:ubifs_volume /mnt/test
root@beaglebone:~# echo hello>/mnt/test/hello.txt
root@beaglebone:~# cat /mnt/test/hello.txt
hello

Now if I reboot the system and reattach the UBIFS, my file is still there, data in tact:

root@beaglebone:~# ubiattach /dev/ubi_ctrl -m 10 -O 2048
UBI device number 0, total 64 LEBs (8126464 bytes, 7.8 MiB), available 0 LEBs (0 bytes), LEB size 126976 bytes (124.0 KiB)
root@beaglebone:~# mount -t ubifs ubi0:ubifs_volume /mnt/test
root@beaglebone:~# cat /mnt/test/hello.txt
hello

Everything looks great at this point. I would now like to have this partition mounted automatically at system boot,  which is where I am having problems. Here is my /etc/fstab, where I have added the last line to automount my UBIFS:

root@beaglebone:~# cat /etc/fstab                                                                                                                                                                            
rootfs               /                    auto       defaults              1  1
proc                 /proc                proc       defaults              0  0
devpts               /dev/pts             devpts     mode=0620,gid=5       0  0
tmpfs                /tmp                 tmpfs      defaults              0  0
ubi0:ubifs_volume    /mnt/test            ubifs      defaults,noatime,rw   0  0

Now when I boot my system, it comes up in emergency mode, and the following errors are printed

UBIFS error (pid 92): ubifs_mount: cannot open "ubi0:ubifs_volume", error -19

Anyone have any idea of what I am missing here? Everywhere I have searched for on the way seems to do it this way, seems pretty straightforward but I just cant get it to work. Any ideas will be greatly appreciated, thank you! - Anthony

  • Hi Anthony,

    If "fstab" not works then try to use "scripting" or add the lines of code which is used to mount, in init starting scripts for auto mounting.

    Ex:

    etc/rc5.d/S99rmnologin  --> linked to --> init.d/rmnologin

    Add the below lines in end of the file "S99rmnologin" or "rmnologin"

    ubiattach /dev/ubi_ctrl -m 10 -O 2048
    mount -t ubifs ubi0:ubifs_volume /mnt/test

    Are you getting my point ?

  • Hi Anthony,

    I agree with the Titus, because in a fstab file missing "ubiattach /dev/ubi_ctrl -m 10 -O 2048" line. Try by explained way.

    BR
    Ivan

  • In addition to that, have a try by adding the following line in fstab file.

    /dev/ubi0_0    /mnt/test    ubifs    defaults,noatime,rw    0 0

  • I don't think that there's a way to automount a ubifs. The ubi volume ubi0_0 does not exist at boot. There's no getting around the fact that ubiattach must run to create it. You could create a custom udev rule that runs ubiattach, but if the kernel tries to mount the ubifs before the volume exists, there will be a panic. Rather than use udev, I'd create a systemd mount unit to perform the commands.