partitioner

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 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 types.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 types.FS) func(d *Disk) error

func WithGdisk

func WithGdisk() func(d *Disk) error

func WithLogger

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

func WithMounter

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

func WithRunner

func WithRunner(runner types.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 types.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

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

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

Jump to

Keyboard shortcuts

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