A have a root file system (file system - image containinf folder structure and content) on a flash drive. The flash drive uses UBI as the underlying file system file system - the way the data blocks are mapped into files, like when you say that you're using ext4).

rootfs on / type rootfs (rw)
ubi0:root on / type ubifs (rw,sync)

I know how to do a backup with dd when there is a physical drive as the first parameter (example. instead of rootfs there would be a /dev/sda), however here I don't know how to address the drive in the current scenario (what is the path for rootfs).

How do i detect to which file does footfs or ubi0:root correspond to?

  • rootfs is an in-memory filesystem which is used only during boot, there's nothing to back up there. What you need to back up is the image that's mounted on ubi0:root. Why not back up the file on the Windows partition? Apr 14, 2014 at 21:41
  • @Gilles I cant access it, the flash is a storage for an embedded device. The only approach is through ssh or serial cable. Apr 15, 2014 at 6:23
  • Duh, for some reason I read Wubi instead of UBI. Forget my last sentence, sorry. Apr 15, 2014 at 11:12

2 Answers 2


If you want to backup/restore UBIFS partition, make an UBI image with dd from the UBI mount then restore using the ubiupdatevol program from mtd-util.

Example -

Make the image:

dd if=/dev/ubi0_0 of=/save_loc/rfs1.ubi

Unmount the target partition:

umount /.rfs2

Restore the image to the target partition:

ubiupdatevol /dev/ubi1_0 /save_loc/rfs1.ubi

Remount the re-flashed partition:

mount -t ubifs -o compr=zlib,ro ubi1:rootfs /.rfs2

Edit: To clarify on finding the ubi# to name, run the mtd-util 'ubinfo':

Volumes count:                           1
Logical eraseblock size:                 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks:     960 (121896960 bytes, 116.2 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes                 128
Count of bad physical eraseblocks:       0
Count of reserved physical eraseblocks:  80
Current maximum erase counter value:     288
Minimum input/output unit size:          2048 bytes
Character device major/minor:            250:0
Present volumes:                         0

Volume ID:   0 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        874 LEBs (110977024 bytes, 105.8 MiB)
State:       OK
Name:        rootfs
Character device major/minor: 250:1

rootfs mounted on / is an in-memory filesystem which typically only contains the tools needed to mount the “real” root filesystem and is emptied after this is done. The initial content of the rootfs are loaded from an initramfs image stored inside or next to the kernel binary and loaded by the bootloader.

The root filesystem on flash is ubi0:root. This is a three-layer system:

  • At the top, the UBIFS filesystem.
  • In the middle, the UBI volume which provides wear leveling on top of raw flash.
  • At the bottom, the raw flash interface (MTD).

(Take the rest of this answer with caution, I've never actually worked with UBI.)

The ubi0:root volume is created by arguments to the ubi module or the ubiattach utility. This is not a block device, because the interface between the UBI level and the filesystem on top of it is more complex than “write this byte at this location”. You can create a read-only block device on top of UBI with the ubiblock command, then back that up — something like

ubiblock --create /dev/ubi0_0
cat /dev/ubi0_0 >backup
ubiblock --remove /dev/ubi0_0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .