hcloud-upload-image/hcloudimages
Julian Tölle fdfb284533
feat: smaller snapshots by zeroing disk first (#101)
The base image used requires ~0.42Gi. Even if the uploaded image is
smaller, those bytes are currently not overwritten and still part of the
stored snapshot.

By zeroing the root disk first, those unwanted bytes are removed and not
stored with the snapshot.

This has two benefits:

1. Snapshots are billed by their compressed (shown) size, so small
images are now a bit cheaper.
2. The time it takes to create a server from the snapshot scales with
the snapshot size, so smaller snapshots means the server can start more
quickly.

This reduces the size of an example Talos x86 image from 0.42Gi before,
to 0.2Gi afterwards. An example Flatcar image was 0.47Gi before, and
still has that size with this patch.

There are two ways to zero out the disk:

- `dd if=/dev/zero of=/dev/sda` actually writes zeroes to every block on
the device. This takes around a minute to do.
- `blkdiscard /dev/sda` talks to the disk direclty and instructs it to
discard all blocks. This only takes around 5 seconds.

As both have the same effect on image size, but `blkdiscard` is SO MUCH
faster, I have decided to use it.

Even though only small images benefit from this, this is now enabled by
default as the downside (5 second slower upload) does not justify
additional flags or options to enable/disable this.

Closes #96
2025-05-10 14:21:31 +02:00
..
backoff fix: timeout while waiting for SSH to become available (#92) 2025-05-09 16:15:07 +02:00
contextlogger feat: documentation and cleanup command 2024-05-04 22:13:33 +02:00
internal fix: timeout while waiting for SSH to become available (#92) 2025-05-09 16:15:07 +02:00
CHANGELOG.md chore(main): release hcloudimages 1.0.1 (#94) 2025-05-09 16:17:27 +02:00
client.go feat: smaller snapshots by zeroing disk first (#101) 2025-05-10 14:21:31 +02:00
client_test.go fix: upload from local image generates broken command (#98) 2025-05-09 21:22:24 +00:00
doc.go feat: documentation and cleanup command 2024-05-04 22:13:33 +02:00
doc_test.go fix: upload from local image generates broken command (#98) 2025-05-09 21:22:24 +00:00
go.mod chore(deps): update dependency go to v1.24.3 (#91) 2025-05-09 16:03:07 +02:00
go.sum chore(deps): update module golang.org/x/crypto to v0.37.0 (#72) 2025-05-04 00:49:36 +02:00