1080*80 ad

The Linux /usr Merge Explained

Understanding the structure of the Linux filesystem can sometimes be a bit confusing, especially when encountering concepts like the split between the root filesystem and the /usr directory. Historically, this division served a practical purpose but evolved into a source of complexity.

In the early days of Unix and later Linux, disk space was extremely limited. It was common practice to use multiple physical disks or partitions. The root filesystem (/) contained only the most essential files needed to boot the system and reach a minimal operational state, often referred to as single-user mode. This included critical binaries in /bin (like a basic shell, ls, mv), essential system administration tools in /sbin, and necessary libraries in /lib.

Other, less critical programs, libraries, and user data were placed in the /usr directory, which could reside on a separate partition or even a different physical disk. /usr traditionally held things like most user applications in /usr/bin, more system administration tools in /usr/sbin, shared libraries in /usr/lib and /usr/lib64, documentation in /usr/share, and header files for software development in /usr/include.

Over time, the lines blurred. Many essential tools needed during boot or in minimal mode started depending on libraries and resources primarily located in /usr. This led to duplication; for instance, ls might exist in both /bin and /usr/bin, or critical libraries needed early in boot might be duplicated or symlinked from /lib to /usr/lib. This duplication and split structure made things complicated. It made it harder to create consistent system snapshots, implement read-only root filesystems, and manage software packages efficiently.

The /usr merge is a modern initiative to simplify this structure. The goal is to consolidate the contents of /bin, /sbin, /lib, and /lib64 directly into their corresponding locations within /usr: /usr/bin, /usr/sbin, /usr/lib, and /usr/lib64.

How is this done? The directories /bin, /sbin, /lib, and /lib64 in the root filesystem are removed and replaced with symbolic links (symlinks) that point to their new locations within /usr. For example, /bin becomes a symbolic link pointing to /usr/bin, /sbin points to /usr/sbin, and so on.

This change means that after the system has booted and the /usr filesystem is mounted, all commands and libraries are accessed through /usr. The root filesystem (/) is then left with only the truly essential files needed before /usr is available, such as the initial ramdisk, the kernel, bootloader files, and potentially minimal configuration needed for early boot.

The benefits of this merge are significant:

  • Simplification: The filesystem structure becomes more unified and easier to understand.
  • Consistency: It resolves the duplication issue and ensures a single location for programs and libraries.
  • Easier Snapshots: Taking snapshots of the entire system state becomes simpler as most user-space programs and libraries reside under one hierarchy (/usr).
  • Improved Read-Only Root: It facilitates running the root filesystem as read-only, enhancing system security and stability, as most writable data is outside the root hierarchy.
  • Better Package Management: Package managers can operate more cleanly without worrying about files being split across two distinct, potentially confusing locations.

While transitioning to the merged structure requires careful handling to maintain compatibility, especially for older systems or scripts, the long-term advantages in terms of system management, simplicity, and robustness are clear. The /usr merge represents a logical evolution of the Linux filesystem layout, adapting it to modern needs and storage capabilities.

Source: https://ostechnix.com/understanding-linux-usr-merge/

900*80 ad

      1080*80 ad