This morning I had a go at using ubifs on my dockstar. The journey was far from smooth.
I followed examples from the official ubifs documentation and faq (where possible), supplemanting with some bits and pieces here and there as the official documentation does not guide you trough the whole process step by step (very usefull if you're doing it for the first time).
I've the tree I want to create the image from in /root_image
I've decided to use custom mtd layout:
Code:
root@printserver:/# cat /proc/mtd
dev: size erasesize name
mtd0: 00100000 00020000 "u-boot"
mtd1: 0ff00000 00020000 "rootfs"
root@printserver:/#
I formated /dev/mdt1, attached is and create a ubi volume:
ubiformat /dev/mtd1
ubiattach -p /dev/mtd1
ubimkvol /dev/ubi0 -N rootfs -m
I then create the ubifs image with mkfs.ubifs:
mkfs.ubifs -r /root_image -o /tmp/rootfs.img -R 1MiB -e 128KiB -m 512 -c 1500
I then update the volune with the image:
ubiupdatevol /dev/ubi0_0 /tmp/rootfs.img
But when I mount it I get this error:
root@printserver:/# mount -t ubifs ubi0_0 /mnt/floppy/
mount: wrong fs type, bad option, bad superblock on ubi0_0,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount.<type> helper program)
In some cases useful info is found in syslog - try
dmesg | tail or so
root@printserver:/#
Ok upon better look at dmesg it was lamenting that I issued incorrect parameters during image creation. Well I don't have any idea what would be sensible so I used stuff from examples, erroneously thinking that at worse I'd have bad performance.
After several attempts, each time correcting one option at a time, this created something I was able to write to volume and mount:
mkfs.ubifs -r /root_image -o /tmp/rootfs.img -R 2MiB -e 129024 -m 2048 -c 1500
but I still cannot boot because the initrd incorrectly parses cmdline ignoring the ubi root device spefification, replacing it with the content of rootdev in the initrd resulting in this error:
Code:
[ 15.756468] UBIFS error (pid 156): ubifs_mount: cannot open "/dev/sda2", error -22
mount: mounting /dev/sda2 on /mnt failed: Invalid argument
ERROR: No /sbin/init found on rootdev (or not mounted). Trouble ahead.
You can try to fix it. Type 'exit' when things are done.
/bin/sh: can't access tty; job control turned off
/ #
I think that something like this need to go in the cmdline parsin section:
Code:
root=ubi*)
ROOTDEV=$(echo $ARG | cut -f2- -d=)
;;
There was still more trouble ahead:
I mounted the volume manually and hoped that it would then boot but when rc.S is executed I started getting errors dew to not correctly remounting root rw and fsck.ufifs missing.
To make a dirty quick workaround I sckipped fsck on root alltogether and changed the remounting lines as follows :
# /sbin/mount -n -o remount,ro /
/sbin/mount -n -o remount,ro /dev/ubi0_0 /
# /sbin/mount -w -v -n -o remount /
/sbin/mount -w -v -n -o remount /dev/ubi0_0 /
and this got the thing booting right.
To workaround the initrd parsing problem I just recreated the initrd with "-r /dev/ubi0_0" amongst the options so that even if it's not parsed at least the content of rootdev is right.
Regards
David