gokrazy / tools

this repository contains the gok CLI tool of gokrazy
https://gokrazy.org
BSD 3-Clause "New" or "Revised" License
50 stars 26 forks source link

Pass fs-size to mkfs.ext4 so it doesn't scribble over secondary GPT #42

Closed khirbat closed 1 year ago

khirbat commented 1 year ago

When creating a disk image, gokr-packer shows an mkfs.ext4 command to create the filesystem for /perm

$ gokr-packer -overwrite gokrazy.img -target_storage_bytes 1258299392 github.com/gokrazy/hello
...
If your applications need to store persistent data, create a file system using e.g.:
    /sbin/mkfs.ext4 gokrazy.img -F -E offset=1157627904

This will overwrite the secondary GPT at the end of the disk image.

$ /opt/homebrew/opt/e2fsprogs/sbin/mkfs.ext4 -F -E offset=1157627904 gokrazy.img
...
Writing superblocks and filesystem accounting information: done
$ /opt/homebrew/opt/util-linux/sbin/fdisk -l gokrazy.img 
The backup GPT table is corrupt, but the primary appears OK, so that will be used.
...
khirbat commented 1 year ago

Thanks for your PR! By the way, there is also https://github.com/gokrazy/mkfs, which may or may not be more convenient depending on the use-case.

Thanks for Gokrazy! It is pretty cool! I don't have a use case currently, I am just exploring. I stumbled upon the GPT thing purely by accident :)

stapelberg commented 1 year ago

Thanks!