partitioner

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const Gdisk = "gdisk"
View Source
const Parted = "parted"

Variables

This section is empty.

Functions

func FormatDevice

func FormatDevice(runner v1.Runner, device string, fileSystem string, label string, opts ...string) error

FormatDevice formats a block device with the given parameters

func MiBToSectors

func MiBToSectors(size uint, sectorSize uint) uint

func WithFS

func WithFS(fs v1.FS) func(d *Disk) error

func WithGdisk added in v1.1.0

func WithGdisk() func(d *Disk) error

func WithLogger

func WithLogger(logger v1.Logger) func(d *Disk) error

func WithMounter added in v1.2.0

func WithMounter(mounter v1.Mounter) func(d *Disk) error

func WithRunner

func WithRunner(runner v1.Runner) func(d *Disk) error

Types

type Disk

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

func NewDisk

func NewDisk(device string, opts ...DiskOptions) *Disk

func (*Disk) AddPartition

func (dev *Disk) AddPartition(size uint, fileSystem string, pLabel string, flags ...string) (int, error)

AddPartition adds a partition. Size is expressed in MiB here Size is expressed in MiB here

func (*Disk) CheckDiskFreeSpaceMiB

func (dev *Disk) CheckDiskFreeSpaceMiB(minSpace uint) bool

Size is expressed in MiB here

func (*Disk) Exists

func (dev *Disk) Exists() bool

func (*Disk) ExpandLastPartition

func (dev *Disk) ExpandLastPartition(size uint) (string, error)

ExpandLastPartition expands the latest partition in the disk. Size is expressed in MiB here Size is expressed in MiB here

func (Disk) FindPartitionDevice

func (dev Disk) FindPartitionDevice(partNum int) (string, error)

func (Disk) FormatPartition

func (dev Disk) FormatPartition(partNum int, fileSystem string, label string) (string, error)

func (*Disk) GetFreeSpace

func (dev *Disk) GetFreeSpace() (uint, error)

func (Disk) GetLabel

func (dev Disk) GetLabel() string

func (Disk) GetLastSector

func (dev Disk) GetLastSector() uint

func (Disk) GetSectorSize

func (dev Disk) GetSectorSize() uint

func (*Disk) NewPartitionTable

func (dev *Disk) NewPartitionTable(label string) (string, error)

func (*Disk) Reload

func (dev *Disk) Reload() error

func (Disk) String

func (dev Disk) String() string

func (Disk) WipeFsOnPartition

func (dev Disk) WipeFsOnPartition(device string) error

type DiskOptions

type DiskOptions func(d *Disk) error

type MkfsCall

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

func NewMkfsCall

func NewMkfsCall(dev string, fileSystem string, label string, runner v1.Runner, customOpts ...string) *MkfsCall

func (MkfsCall) Apply

func (mkfs MkfsCall) Apply() (string, error)

type Partition

type Partition struct {
	Number     int
	StartS     uint
	SizeS      uint
	PLabel     string
	FileSystem string
}

We only manage sizes in sectors unit for the Partition structre in parted wrapper FileSystem here is only used by parted to determine the partition ID or type

type Partitioner added in v1.1.0

type Partitioner interface {
	WriteChanges() (string, error)
	SetPartitionTableLabel(label string) error
	CreatePartition(p *Partition)
	DeletePartition(num int)
	SetPartitionFlag(num int, flag string, active bool)
	WipeTable(wipe bool)
	GetLastSector(printOut string) (uint, error)
	Print() (string, error)
	GetSectorSize(printOut string) (uint, error)
	GetPartitionTableLabel(printOut string) (string, error)
	GetPartitions(printOut string) []Partition
}

func NewPartitioner added in v1.1.0

func NewPartitioner(dev string, runner v1.Runner, backend string) Partitioner

Jump to

Keyboard shortcuts

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