Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

/sys/class/ubi

FieldValue
SubsystemUBI subsystem (Unsorted Block Images, wear-leveling layer over MTD); implementation file not in cached tree
Config gatenot verifiable from the cached sources (cached tree has no Kconfig or driver files); /usr/include/linux/ubi-user.h absent on the host (verified)
ABI documentationDocumentation/ABI/stable/sysfs-class-ubi (26 What entries: class, version, ubiX device dirs, ubiX_Y volume dirs)
Since2.6.22 (July 2006); mtd_num 2.6.25; ro_mode 4.7
Live (5.10.134 host)class absent: not in live-sys/class-list.txt, no /sys/class/ubi (no MTD-backed UBI device in the container)
Ledger IDSYSC-ubi

What it represents

The UBI control and device class. The class directory carries the on-media format version (currently 1) and one ubiX directory per UBI device (ubi0, ubi1, …), each built over an MTD device. Each ubiX directory holds the device geometry and health files plus one ubiX_Y subdirectory per UBI volume, the dynamic/static partitions that user data lives in. Creation and deletion of devices and volumes is done through the /dev/ubiN and /dev/ubiX_Y character devices and their ioctls, not sysfs.

Relationship to the device model

ubiX directories are class views of UBI devices; dev in each gives the major:minor of the matching character device. Each ubiX sits over an MTD device identified by mtd_num, so the UBI class is a consumer view of the MTD subsystem (see mtd). Volume directories are nested under their device, not at class level - the volume’s own dev file points at the volume character device. The sibling page ubiX documents the per-device layout in isolation.

Attributes

Class level:

AttributeR/WUnit/formatConditional?Source
versionROlatest supported UBI on-media format version (currently 1)alwaysABI, 2.6.22

Per UBI device (/sys/class/ubi/ubiX/):

AttributeR/WUnit/formatConditional?Source
avail_eraseblocksROlogical eraseblocks available for new volumesalwaysABI, 2.6.22
bad_peb_countRObad physical eraseblocks on the MTD devicealwaysABI, 2.6.22
bgt_enabledROASCII 0/1, background thread statealwaysABI, 2.6.22
devROmajor:minor of the UBI character devicealwaysABI, 2.6.22
eraseblock_sizeROmax logical eraseblock size (bytes)alwaysABI, 2.6.22
max_ecROmaximum erase counter valuealwaysABI, 2.6.22
max_vol_countROmaximum number of volumesalwaysABI, 2.6.22
min_io_sizeROminimum I/O unit size (bytes)alwaysABI, 2.6.22
mtd_numROunderlying MTD device numberalwaysABI, 2.6.25
reserved_for_badROPEBs reserved for bad-block handlingalwaysABI, 2.6.22
ro_modeROASCII 1 when UBI switched to read-only after an unrecoverable erroralwaysABI, 4.7
total_eraseblocksROgood physical eraseblocks totalalwaysABI, 2.6.22
volumes_countROvolumes on this devicealwaysABI, 2.6.22

Per volume (/sys/class/ubi/ubiX/ubiX_Y/): alignment, corrupted (0/1, e.g. interrupted update), data_bytes (meaningful for static volumes), dev, name, reserved_ebs, type (dynamic/static), upd_marker (1 = update in progress or interrupted), usable_eb_size - all RO, all from the same ABI file (2.6.22).

Safety and writes

Every documented attribute is read-only; all UBI mutations (attach, detach, volume create/resize/remove, update start/end) are ioctl territory via the character devices. Two files deserve attention when troubleshooting: ro_mode = 1 means UBI gave up writing because of media errors, and upd_marker = 1 means an interrupted volume update (check corrupted). No sysfs write path exists in the ABI.

References

  • Documentation/ABI/stable/sysfs-class-ubi (cached copy; 26 What entries)
  • /usr/include/linux/ubi-user.h absent on the host (verified) - the ioctl uapi could not be cited locally
  • Implementation: not in cached tree
  • Sibling pages: ubiX, mtd; coverage: ledger
  • Live check: /sys/class/ubi absent (kernel 5.10.134, read-only enumeration)