Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions Sources/Containerization/ContainerManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public struct ContainerManager: Sendable {
format: "ext4",
source: destination.absolutePath(),
destination: "/",
options: []
options: ["discard"]
)
}
throw err
Expand All @@ -364,11 +364,14 @@ public struct ContainerManager: Sendable {
}
let filesystem = try EXT4.Formatter(FilePath(path), minDiskSize: size)
try filesystem.close()
// The filesystem lives in a sparse file that only gives freed blocks
// back to the host when the guest discards them, so the mount asks
// for continuous discard from birth.
return .block(
format: "ext4",
source: path,
destination: "/",
options: []
options: ["discard"]
)
}
}
Expand Down
6 changes: 5 additions & 1 deletion Sources/Containerization/Image/Unpacker/EXT4Unpacker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,15 @@ public struct EXT4Unpacker: Unpacker {
try await filesystem.unpack(reader: reader, progress: progress)
}

// The filesystem lives in a sparse file that only gives freed blocks
// back to the host when the guest discards them, so the mount asks for
// continuous discard from birth. A read-only mount of it parses the
// option and leaves it idle.
return .block(
format: "ext4",
source: cleanedPath,
destination: "/",
options: []
options: ["discard"]
)
}

Expand Down