Alexander Larsson, the creator of Flatpak working at Red Hat, introduced a preliminary version of patches implementing the Composefs file system for the Linux kernel. The proposed file system is similar to Squashfs and is also suitable for mounting images in read-only mode. The differences lie in Composefs providing efficient shared storage for the contents of several mounted disk images and supporting verification of the authenticity of the read data. Potential use cases for Composefs include mounting container images and using it for Git-like repositories such as OSTree.
Composefs employs a content-addressable storage model, meaning the primary identifier is not the file name, but rather a hash of the file's content. This model allows for deduplication and effectively enables the storage of only one copy of identical files found in different mounted partitions. For instance, container images contain many typical system files, and when using Composefs, each of these files will be shared among all mounted images without employing tricks like hard links. Additionally, shared files not only occupy a single copy on disk but also count as one entry in the page cache, thereby conserving both disk and RAM resources.
To save disk space, data and metadata in the mounted images are separated. When mounting, the following are specified:
- A binary index containing all metadata of the file system, file names, access rights, and other information, excluding the actual file contents.
- A base directory where the contents of all mounted images are stored. The files are linked to the hash of their content.
Binarni indeks se stvara za svaku sliku datotečnog sustava, dok je osnovni katalog zajednički za sve slike. Za provjeru sadržaja pojedinih datoteka i cjelokupne slike u uvjetima zajedničkog pohranjivanja može se koristiti mehanizam fs-verity, koji prilikom pristupa datotekama provjerava usklađenost hash-eva navedenih u binarnom indeksu s aktualnim sadržajem (tj. ako zlonamjernik izmijeni datoteku u osnovnom katalogu ili se podaci oštete uslijed kvara, ova provjera će otkriti neslaganje).
Izvor: opennet.ru
