Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/images/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ func convertToExt4(rootfsDir, diskPath string) (int64, error) {
return 0, fmt.Errorf("calculate dir size: %w", err)
}

// Add 20% overhead for filesystem metadata, minimum 10MB
diskSizeBytes := sizeBytes + (sizeBytes / 5)
// Add 50% overhead for filesystem metadata, minimum 10MB
// ext4 needs significant overhead for superblock, group descriptors, inode tables, etc.
// 20% was insufficient for small filesystems with many files (like tzdata)
diskSizeBytes := sizeBytes + (sizeBytes / 2)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: to keep the comment and math from drifting, consider pulling the ratio into a named constant.

Suggested change
diskSizeBytes := sizeBytes + (sizeBytes / 2)
const ext4MetadataOverheadPercent int64 = 50
diskSizeBytes := sizeBytes + (sizeBytes*ext4MetadataOverheadPercent)/100

const minSize = 10 * 1024 * 1024 // 10MB
if diskSizeBytes < minSize {
diskSizeBytes = minSize
Expand Down