Backup of a ubi file system with dd

disk-imagefilesystemsmountubifs

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?

Best Answer

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
Related Question