Skip to content

Commit 157365b

Browse files
authored
fix: increase ext4 filesystem overhead from 20% to 50% (#55)
The 20% overhead was insufficient for small filesystems with many files (like images with timezone data). ext4 requires significant space for superblock, group descriptors, inode tables, and directory entries. This caused mkfs.ext4 to fail with "Could not allocate block in ext2 filesystem" when converting images to disk format. Tested with Alpine + tzdata image which previously failed.
1 parent d353357 commit 157365b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lib/images/disk.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,10 @@ func convertToExt4(rootfsDir, diskPath string) (int64, error) {
116116
return 0, fmt.Errorf("calculate dir size: %w", err)
117117
}
118118

119-
// Add 20% overhead for filesystem metadata, minimum 10MB
120-
diskSizeBytes := sizeBytes + (sizeBytes / 5)
119+
// Add 50% overhead for filesystem metadata, minimum 10MB
120+
// ext4 needs significant overhead for superblock, group descriptors, inode tables, etc.
121+
// 20% was insufficient for small filesystems with many files (like tzdata)
122+
diskSizeBytes := sizeBytes + (sizeBytes / 2)
121123
const minSize = 10 * 1024 * 1024 // 10MB
122124
if diskSizeBytes < minSize {
123125
diskSizeBytes = minSize

0 commit comments

Comments
 (0)