This approximate instruction for make final release image for simplest install.
- dd from installed device to raw image file:
- Generate loop devices for image:
- Mount first "boot" partition of image:
- Fill unused space to zeros:
- Check second partition (root) for errors before shrink filesystem:
- Resize root filesystem to minimal size (shrink): resize2fs 1.46.5 (30-Dec-2021) Resizing the filesystem on /dev/loop0p2 to 706286 (4k) blocks. The filesystem on /dev/loop0p2 is now 706286 (4k) blocks long.
- Resize root partition to filesystem size: d 2 n p 2 (default first sector) +(count of filesystem blocks from resize2fs out)*8
- Truncate image file: truncate -s ((end of 2 partition sector (from fdisk))/2+1)k
- Image compression #xz -9