Documentation
¶
Overview ¶
Package hostswap reports a host's RAM and swap and plans an opt-in swapfile. Nothing here changes the host unless Apply is called with an explicit request.
Index ¶
Constants ¶
const ( // DefaultPath is where the helper creates its swapfile. DefaultPath = "/swapfile-levelrail" // FstabPath is the file the persistent entry is appended to. FstabPath = "/etc/fstab" // MaxSizeMB bounds a swapfile so a typo cannot fill the disk. MaxSizeMB = 262144 )
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply runs the plan. It needs root on Linux and removes the file again if a later step fails, so a failed run leaves the host as it was.
func SizeMB ¶
SizeMB resolves the swapfile size: a positive setting wins, otherwise the size matches RAM (the usual guidance for small hosts).
func ValidatePath ¶
ValidatePath accepts only a clean absolute path under an allowed prefix with no character that could break an fstab line or an argv value.
Types ¶
type Plan ¶
type Plan struct {
Path string `json:"path"`
SizeMB int `json:"size_mb"`
Commands []string `json:"commands"`
Notes []string `json:"notes,omitempty"`
}
Plan is the exact set of steps to add a swapfile.