@@ -15,9 +15,9 @@ func convertToExt4(rootfsDir, diskPath string) (int64, error) {
1515 return 0 , fmt .Errorf ("calculate dir size: %w" , err )
1616 }
1717
18- // Add 20% overhead for filesystem metadata, minimum 1GB
18+ // Add 20% overhead for filesystem metadata, minimum 10MB
1919 diskSizeBytes := sizeBytes + (sizeBytes / 5 )
20- const minSize = 1024 * 1024 * 1024 // 1GB
20+ const minSize = 10 * 1024 * 1024 // 10MB
2121 if diskSizeBytes < minSize {
2222 diskSizeBytes = minSize
2323 }
@@ -39,8 +39,11 @@ func convertToExt4(rootfsDir, diskPath string) (int64, error) {
3939 f .Close ()
4040
4141 // Format as ext4 with rootfs contents using mkfs.ext4
42- // This works without root when creating filesystem in a regular file
43- cmd := exec .Command ("mkfs.ext4" , "-d" , rootfsDir , "-F" , diskPath )
42+ // -b 4096: 4KB blocks (standard, matches VM page size)
43+ // -O ^has_journal: Disable journal (not needed for read-only VM mounts)
44+ // -d: Copy directory contents into filesystem
45+ // -F: Force creation (file not block device)
46+ cmd := exec .Command ("mkfs.ext4" , "-b" , "4096" , "-O" , "^has_journal" , "-d" , rootfsDir , "-F" , diskPath )
4447 output , err := cmd .CombinedOutput ()
4548 if err != nil {
4649 return 0 , fmt .Errorf ("mkfs.ext4 failed: %w, output: %s" , err , output )
0 commit comments