Does anyone know if there exists a tool that can convert tarballs to filesystems and back. I know you can make a loopback device, but it can be pretty hard/impossible to do inside a container, and often requires special flags and privileges.
You can extract the tarball to a directory, then run mkfs.ext4 -d DIRECTORY FILENAME BLOCKS to create a filesystem[0]. You'll need to know how many blocks your filesystem needs to be in advance.
Unfortunately, mkfs.ext4 only works on Linux. There is no port for other operating systems.
I've been doing something similar recently, though it doesn't directly convert a tar to an ext4 FS. But maybe this can help you get to where you want to be.
On Alpine Linux:
```
apk add --no-cache coreutils e2fsprogs
```
```
#!/bin/sh
# Untar the tar file
mkdir -p /tmp/my_untarred_files_dir
tar -xvf my_tar_file.tar -C /tmp/my_untarred_files_dir
# Make an empty image file.
dd if=/dev/zero of="fs.raw" bs=1M count=1024
# Format the file as ext4 (with journaling) and copy untarred files into it