Re: TarFS

From: Dag-Erling_Smørgrav <des_at_FreeBSD.org>
Date: Mon, 25 Mar 2024 13:59:46 UTC
Mark Saad <nonesuch@longcount.org> writes:
> I was wondering if anyone has started to play with tarfs in FreeBSD 14?

I wrote it, does that count?

> It appears to puke with larger tarballs.

On the contrary, one of the use cases I tested was buildworld from a
tarball of the source tree, which it handled just fine.

> For example, if I fetch a copy of ports or pkgsrc and decompress it to
> just a posix tar archive I can't get it to mount.
>
> root@mono:/home/nonesuch # file ports.tar
> ports.tar: POSIX tar archive
> root@mono:/home/nonesuch # mount -t tarfs ./ports.tar /tarfs/ports
> mount: ./ports.tar: Inappropriate file type or format

% fetch ftp://ftp.freebsd.org/pub/FreeBSD/ports/ports/ports.tar.zst
ports.tar.zst                                           47 MB 5431 kBps    09s
% sudo mount -rt tarfs $PWD/ports.tar.zst /mnt
mount: /home/des/ports.tar.zst: Inappropriate file type or format
% dmesg | grep tarfs                  
tarfs_alloc_one: unsupported global extended header at 0
% zcat ports.tar.zst | hexdump -C | head -3
00000000  70 61 78 5f 67 6c 6f 62  61 6c 5f 68 65 61 64 65  |pax_global_heade|
00000010  72 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |r...............|
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

This is a non-standard extension header emitted by `git archive` which
contains metadata about the git tree from which the archive was created.
I believe you can safely strip it off (zcat ports.tar.zst | dd bs=1k
skip=1 >ports.tar), but you'll run into issues with very long paths in
devel/electron*.  I will take a closer look when I find the time.

Note that tarfs can mount tarballs compressed with zstd, but performance
will be poor unless you create a multi-frame archive (try using --zstd
--options=zstd:frame-per-file,zstd:min-frame-size=65536).

DES
-- 
Dag-Erling Smørgrav - des@FreeBSD.org