partition

package
v0.1.28 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2026 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package partition provides common utils for system partition format.

Package partition provides common utils for system partition format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(ctx context.Context, devname string, t *FormatOptions, talosVersion string, printf func(string, ...any)) error

Format zeroes the device and formats it using filesystem type provided.

func WipeWithSignatures

func WipeWithSignatures(bd *block.Device, deviceName string, log func(string, ...any)) error

WipeWithSignatures wipes the given block device by its signatures (if available) and falls back to fast wipe otherwise.

The function assumes that the caller locked properly the block device (or the parent device in case of partitions) before calling it.

If non-nil log function is passed, it will be used to log the wipe process.

Types

type FileSystemType

type FileSystemType = string

FileSystemType is used to format partitions.

const (
	FilesystemTypeNone   FileSystemType = "none"
	FilesystemTypeZeroes FileSystemType = "zeroes"
	FilesystemTypeXFS    FileSystemType = "xfs"
	FilesystemTypeVFAT   FileSystemType = "vfat"
	FileSystemTypeExt4   FileSystemType = "ext4"
)

Filesystem types.

type FormatOption

type FormatOption func(*FormatOptions)

FormatOption to control options.

func WithFileSystemType

func WithFileSystemType(fsType FileSystemType) FormatOption

WithFileSystemType sets the filesystem type.

func WithForce

func WithForce() FormatOption

WithForce sets the force option.

func WithLabel

func WithLabel(label string) FormatOption

WithLabel sets the label for the filesystem.

func WithReproducible

func WithReproducible() FormatOption

WithReproducible sets the reproducible option.

func WithSourceDirectory

func WithSourceDirectory(dir string) FormatOption

WithSourceDirectory sets the source directory for populating the filesystem.

func WithUnsupportedFSOption

func WithUnsupportedFSOption() FormatOption

WithUnsupportedFSOption sets the unsupported filesystem option.

type FormatOptions

type FormatOptions struct {
	Label               string
	SourceDirectory     string
	FileSystemType      FileSystemType
	Force               bool
	UnsupportedFSOption bool
	Reproducible        bool
}

FormatOptions contains format parameters.

func NewFormatOptions

func NewFormatOptions(opts ...FormatOption) *FormatOptions

NewFormatOptions creates a new format options.

type Options

type Options struct {
	FormatOptions

	PartitionLabel string
	PartitionType  Type
	Size           uint64
	PartitionOpts  []gpt.PartitionOption
}

Options contains the options for creating a partition.

func NewPartitionOptions

func NewPartitionOptions(uki bool, quirk quirks.Quirks, formatOpts ...FormatOption) Options

NewPartitionOptions returns a new PartitionOptions.

type Type

type Type = string

Type in partition table.

const (
	EFISystemPartition  Type = "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
	BIOSBootPartition   Type = "21686148-6449-6E6F-744E-656564454649"
	LinuxFilesystemData Type = "0FC63DAF-8483-4772-8E79-3D69D8477DE4"
	LinkSwap            Type = "0657FD6D-A4AB-43C4-84E5-0933C84B4F4F"
)

GPT partition types.

TODO: should be moved into the blockdevice library.

type VolumeWipeTarget

type VolumeWipeTarget struct {
	// contains filtered or unexported fields
}

VolumeWipeTarget is a target for wiping a volume.

func VolumeWipeTargetFromDiscoveredVolume

func VolumeWipeTargetFromDiscoveredVolume(dv *blockres.DiscoveredVolume) *VolumeWipeTarget

VolumeWipeTargetFromDiscoveredVolume creates a new VolumeWipeTarget from a DiscoveredVolume.

func VolumeWipeTargetFromVolumeStatus

func VolumeWipeTargetFromVolumeStatus(vs *blockres.VolumeStatus) *VolumeWipeTarget

VolumeWipeTargetFromVolumeStatus creates a new VolumeWipeTarget from a VolumeStatus.

func (*VolumeWipeTarget) GetLabel

func (v *VolumeWipeTarget) GetLabel() string

GetLabel implements runtime.PartitionTarget.

func (*VolumeWipeTarget) String

func (v *VolumeWipeTarget) String() string

String implements runtime.PartitionTarget.

func (*VolumeWipeTarget) Wipe

func (v *VolumeWipeTarget) Wipe(ctx context.Context, log func(string, ...any)) error

Wipe implements runtime.PartitionTarget. Asides from wiping the device, Wipe() also drops the partition.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL