You are here: Home / Attic / Sheevaplug Notes / Ubifs

Ubifs

notes about ubifs, the filesystem for raw memory devices

Mount existing ubifs volume

ubiattach /dev/ubi_ctrl -m 2
mount -t ubifs ubi0 /media/
...
umount /media
ubidetach /dev/ubi_ctrl -m 2

Create ubifs filesystem

# ubiformat /dev/mtd2
ubiformat: mtd2 (nand), size 531628032 bytes (507.0 MiB), 4056 eraseblocks of \
    131072 bytes (128.0 KiB),\
    min. I/O size 2048 bytes
libscan: scanning eraseblock 4055 -- 100 % complete
ubiformat: 4055 eraseblocks have valid erase counter, mean value is 0
ubiformat: 1 bad eraseblocks found, numbers: 3209
ubiformat: formatting eraseblock 4055 -- 100 % complete
# ubiattach /dev/ubi_ctrl -m 2
UBI device number 0, total 4055 LEBs (523192320 bytes, 499.0 MiB), \
    available 4011 LEBs (517515264 bytes, 493.5 MiB), \
    LEB size 129024 bytes (126.0 KiB)
# ubimkvol /dev/ubi0 -m -N rootfs
Set volume size to 517515264
Volume ID 0, size 4011 LEBs (517515264 bytes, 493.5 MiB), LEB size 129024 bytes (126.0 KiB), \
    dynamic, name "rootfs", alignment 1
# mkfs.ubifs -r /tmp/empty -m 2048 -e 129024 -c 4096  -o ubi.img
# ubiupdatevol /dev/ubi0_0  ubi.img
# mount -t ubifs ubi0:rootfs /media/

build ubifs tools

you also need zlib, i already build it during the creation of my cross-compiler chain. Also the cross-compiler binary must be in your PATH.

export CROSS=armv5tel-softfloat-linux-gnueabi
export SYSROOT=/.../sysroot

lzo

wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.03.tar.gz
./configure --build=$(gcc -dumpmachine) \
  --host=$CROSS \
  --prefix=$SYSROOT
make
make install

util-linux-ng

wget ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/v2.18/util-linux-ng-2.18.tar.bz2
CFLAGS="-I$SYSROOT/include" \
./configure \
        --build=$(gcc -dumpmachine) \
        --host=$CROSS \
        --prefix=$SYSROOT \
        --without-ncurses \
        --disable-makeinstall-chown \
        --disable-makeinstall-setuid

mtd-utils

git clone git://git.infradead.org/mtd-utils.git
cd mtd-utils/ubi-utils
# thanks for requiring the minus...
make
make DESTDIR=$SYSROOT install
cd mtd-utils/mkfs.ubifs
# edit Makefile to include sysroot
# CPPFLAGS += -I../include -I../ubi-utils/include  -I$(SYSROOT)/include
# edit Makefile to include libubi
# LDLIBS_mkfs.ubifs = -lz -llzo2 -lm -luuid -L$(currentpath)mtd-utils/ubi-utils/$(CROSS) -lubi
make
make DESTDIR=$SYSROOT install