I am pleased to announce GPTar 1.0.0!
GPTar is a small library to create a tartition table, that is, a tar archive that also contains a valid GUID partition table (GPT).
It exploits the fact that the important areas of a protective MBR in GPT and a tar header are mostly disjoint. The tar header fits almost exactly in the boot strap code of a master boot record (MBR) with the last 54 bytes of the tar header overlapping with the partition table of the (protective) MBR. Thakfully, those are the 54 last bytes of the 155 byte long NUL terminated “filename prefix” of the tar header. So as long as we put a NUL byte before the partition table tar will happily ignore the partition table data.
To further hide the actual GPT header & partition table from tar utilities the first tar header uses the GNU volume header extension with the GPT header & partition table as the “file contents”. This makes GNU tar list the volume header but when extracting files the volume header is skipped. For released versions of bsdtar this unfortunately results in a “bad archive” error - however, the as-yet unreleased libarchive/bsdtar fixes this “bug” and allows for this abuse of volume headers (see the “update” blog post).
For more in depth details you may be interested in reading the following two blog articles:
Why!?
Great question. At Robur we developed an opam-mirror unikernel that acts as an opam repository and package source archive cache similar to https://opam.ocaml.org/. There we use tar as a filesystem for the package source archive cache. Later, we started using the end of the block device to cache data such as git state and computed package source archive checksums.
The neat feature is we could use regular old bsdtar or GNU tar in the host system to inspect the tar filesystem data. The downside was the lack of a partition table using offsets provided by boot arguments for where to find the cached data. With GPTar we can have both! Inspect the tar filesystem data while being more robust with a partition table.
Also, it was very fun to develop.