STRUCT UBI_VOLUME_INFO(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 NAME 🌸

okay so this page is struct ubi_volume_info(9) from the Kernel API Manual πŸ’– and it's literally the UBI volume description data structure. That's the name, that's the vibe.

✨ SYNOPSIS ✨

here's the struct in all its glory, bestie β€” copied exactly:

struct ubi_volume_info {
    int ubi_num;
    int vol_id;
    int size;
    long long used_bytes;
    int used_ebs;
    int vol_type;
    int corrupted;
    int upd_marker;
    int alignment;
    int usable_leb_size;
    int name_len;
    const char *name;
    dev_t cdev;
    struct device *dev;
 };

πŸŽ€ Members πŸŽ€

  • ubi_num β€” the UBI device number this volume belongs to.
  • vol_id β€” the volume ID.
  • size β€” how many physical eraseblocks are reserved for this volume.
  • used_bytes β€” how many bytes of data this volume contains.
  • used_ebs β€” how many physical eraseblocks of this volume actually contain any data.
  • vol_type β€” the volume type, aka UBI_DYNAMIC_VOLUME or UBI_STATIC_VOLUME.
  • corrupted β€” non-zero if the volume is corrupted (static volumes only).
  • upd_marker β€” non-zero if the volume has the update marker set.
  • alignment β€” volume alignment.
  • usable_leb_size β€” how many bytes are available in logical eraseblocks of this volume.
  • name_len β€” volume name length.
  • name β€” volume name.
  • cdev β€” UBI volume character device major and minor numbers.
  • dev β€” yep, it's in the struct as struct device *dev;; the OG member rundown doesn't give it a separate blurb, so no invented facts here πŸ™ˆ.

πŸ’… Description πŸ’…

the corrupted flag is only relevant to static volumes and is always zero for dynamic ones. this is because UBI does not care about dynamic volume data protection and only cares about protecting static volume data. periodt.

the upd_marker flag is set if the volume update operation was interrupted. before touching the volume data during the update operation, UBI first sets the update marker flag for this volume. if the volume update operation was further interrupted, the update marker indicates this. if the update marker is set, the contents of the volume is certainly damaged and a new volume update operation has to be started. no cap, that's serious.

to put it differently, corrupted and upd_marker fields have different semantics:

  • the corrupted flag means that this static volume is corrupted for some reasons, but not because of an interrupted volume update.
  • the upd_marker field means that the volume is damaged because of an interrupted update operation.

i.e., the corrupted flag is never set if the upd_marker flag is set. the way that's a whole distinction πŸ‘‘

the used_bytes and used_ebs fields are only really needed for static volumes and contain the number of bytes stored in this static volume and how many eraseblocks this data occupies. in case of dynamic volumes, the used_bytes field is equivalent to size*usable_leb_size, and the used_ebs field is equivalent to size.

in general, logical eraseblock size is a property of the UBI device, not of the UBI volume. indeed, the logical eraseblock size depends on the physical eraseblock size and on how much bytes UBI headers consume. but because of the volume alignment (alignment), the usable size of logical eraseblocks of a volume may be less. the following equation is true:

usable_leb_size = LEB size - (LEB size mod alignment)

where LEB size is the logical eraseblock size defined by the UBI device.

the alignment is a multiple of the minimal flash input/output unit size, or 1 if all the available space is used.

to put this differently, alignment may be considered a way to change volume logical eraseblock sizes. slay πŸ’…

πŸ¦‹ SEE ALSO πŸ¦‹

  • Kernel file ./include/linux/mtd/ubi.h
  • struct ubi_sgl(9)
  • ubi_sgl_init(9)
  • struct ubi_device_info(9)

xoxo, bestie πŸ’– this one comes from ./include/linux/mtd and is dated October 2026 β€” mwah!

πŸ“¦ where this page comes from