Documentation
¶
Overview ¶
Package makefs provides function to format and grow filesystems.
Index ¶
- Constants
- func BTRFS(ctx context.Context, partname string, setters ...Option) error
- func BTRFSGrow(ctx context.Context, partname string) error
- func BTRFSRepair(ctx context.Context, partname string) error
- func Ext4(ctx context.Context, partname string, setters ...Option) error
- func Ext4Repair(ctx context.Context, partname string) error
- func Ext4Resize(ctx context.Context, partname string) error
- func GUIDFromLabel(label string) uuid.UUID
- func GenerateProtofile(sourcePath string) (io.Reader, error)
- func VFAT(ctx context.Context, partname string, setters ...Option) error
- func XFS(ctx context.Context, partname string, setters ...Option) error
- func XFSGrow(ctx context.Context, partname string) error
- func XFSRepair(ctx context.Context, partname string) error
- type Option
- func WithConfigFile(configFile string) Option
- func WithForce(force bool) Option
- func WithLabel(label string) Option
- func WithPrintf(printf func(string, ...any)) Option
- func WithReproducible(reproducible bool) Option
- func WithSectorSize(sectorSize uint) Option
- func WithSourceDirectory(sourceDir string) Option
- func WithUnsupportedFSOption(unsupported bool) Option
- type Options
Constants ¶
const (
// FilesystemTypeBTRFS is the filesystem type for BTRFS.
FilesystemTypeBTRFS = "btrfs"
)
const (
// FilesystemTypeEXT4 is the filesystem type for EXT4.
FilesystemTypeEXT4 = "ext4"
)
const (
// FilesystemTypeVFAT is the filesystem type for VFAT.
FilesystemTypeVFAT = "vfat"
)
const (
// FilesystemTypeXFS is the filesystem type for XFS.
FilesystemTypeXFS = "xfs"
)
Variables ¶
This section is empty.
Functions ¶
func BTRFSGrow ¶
BTRFSGrow expands a BTRFS filesystem to the maximum possible.
The partition MUST be mounted, and partname must be a path within the mount (typically the mount point), since btrfs filesystem resize operates on a mounted filesystem.
func BTRFSRepair ¶
BTRFSRepair repairs a BTRFS filesystem on the specified partition.
As this operation is potentially dangerous, we are going to wire into the volume mount flow, but we will keep it here for completeness.
The filesystem must NOT be mounted. --force is passed to skip the interactive 10-second warning delay; --repair on a damaged filesystem is dangerous and can make things worse — callers should ensure a check is warranted.
func Ext4Repair ¶ added in v1.9.2
Ext4Repair repairs a ext4 filesystem.
func Ext4Resize ¶ added in v1.9.0
Ext4Resize expands a ext4 filesystem to the maximum possible.
func GUIDFromLabel ¶ added in v1.13.0
GUIDFromLabel generates a deterministic partition GUID from a label by creating a version 8 UUID derived from a SHA-256 hash of the label bytes.
func GenerateProtofile ¶ added in v1.13.0
GenerateProtofile walks a filesystem tree and generates an XFS protofile. All files and directories will have uid/gid mapped to 0:0.
Types ¶
type Option ¶
type Option func(*Options)
Option to control makefs settings.
func WithConfigFile ¶ added in v1.10.0
WithConfigFile sets the config file for the filesystem to be created.
func WithPrintf ¶ added in v1.13.0
WithPrintf sets the printf function for logging.
func WithReproducible ¶ added in v1.5.0
WithReproducible sets the reproducible flag for the filesystem to be created. This should only be used when creating filesystems on raw disk images.
func WithSectorSize ¶
WithSectorSize overrides the sector size used by mkfs. This should only be used with disk images where the underlying sector size cannot be detected automatically; on real block devices mkfs auto-detection is preferred.
For ext4, this sets the filesystem block size (-b) since ext4 has no separate sector size concept.
func WithSourceDirectory ¶ added in v1.13.0
WithSourceDirectory sets the source directory for populating the filesystem.
func WithUnsupportedFSOption ¶ added in v1.8.0
WithUnsupportedFSOption sets the unsupported filesystem option.
type Options ¶
type Options struct {
Label string
ConfigFile string
SourceDirectory string
SectorSize uint
Force bool
Reproducible bool
UnsupportedFSOption bool
Printf func(string, ...any)
}
Options for makefs.
func NewDefaultOptions ¶
NewDefaultOptions builds options with specified setters applied.