disk

package
v0.0.0-...-9fb81a0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MSDOS = "msdos"
	GPT   = "gpt"
)
View Source
const (
	BTRFS      = "btrfs"
	EXT2       = "ext2"
	EXT3       = "ext3"
	EXT4       = "ext4"
	FAT16      = "fat16"
	FAT32      = "fat32"
	HFS        = "hfs"
	HFS_PLUS   = "hfs+"
	LINUX_SWAP = "linux-swap"
	NTFS       = "ntfs"
	REISERFS   = "reiserfs"
	UDF        = "udf"
	XFS        = "xfs"
)

Variables

This section is empty.

Functions

func GenFstab

func GenFstab(targetRoot string, entries [][]string) error

func GetFilesystemByPath

func GetFilesystemByPath(path string) (string, error)

func GetUUIDByPath

func GetUUIDByPath(path string) (string, error)

func LUKSMakeFs

func LUKSMakeFs(part Partition) error

LUKSMakeFs creates a filesystem inside of a LUKS-formatted partition. Use this instead of MakeFs when setting up encrypted filesystems.

func LUKSSetLabel

func LUKSSetLabel(part *Partition, name string) error

LUKSSetLabel labels a LUKS-formatted partition. Use this instead of SetLabel when setting up encrypted filesystems.

func MakeFs

func MakeFs(part *Partition) error

func OCISetup

func OCISetup(imageSource, storagePath, destination string, verbose bool) error

func UnmountDirectory

func UnmountDirectory(dir string) error

func Unsquashfs

func Unsquashfs(filesystem, destination string, force bool) error

func UpdateInitramfs

func UpdateInitramfs(root string) error

Types

type Disk

type Disk struct {
	Path, Size, Model, Transport string
	Label                        DiskLabel
	LogicalSectorSize            int `json:"logical-sector-size"`
	PhysicalSectorSize           int `json:"physical-sector-size"`
	MaxPartitions                int `json:"max-partitions"`
	Partitions                   []Partition
}

func LocateDisk

func LocateDisk(diskname string) (*Disk, error)

func (*Disk) AvailableSectors

func (disk *Disk) AvailableSectors() ([]Sector, error)

func (*Disk) GetPartition

func (target *Disk) GetPartition(partNum int) *Partition

GetPartition attempts to locate a partition by its number. For instance, partition 3 will normally point to `/dev/sda3`, but this might not be the case if partitions have been deleted (see Issue #44). This function searches all partitions in target for the correct one.

func (*Disk) LabelDisk

func (disk *Disk) LabelDisk(label DiskLabel) error

func (*Disk) NewPartition

func (target *Disk) NewPartition(name string, fsType PartitionFs, start, end int) (*Partition, error)

NewPartition creates a new partition on Disk with the provided name, filesystem type, and start and end locations.

If fsType is an empty string, the function will skip creating the filesystem. This can be useful when creating LUKS-encrypted partitions, where the format operation needs to be executed first.

func (*Disk) Update

func (disk *Disk) Update() error

type DiskLabel

type DiskLabel string

type Partition

type Partition struct {
	Number                       int
	Start, End, Size, Type, Path string
	Filesystem                   PartitionFs
}

func (*Partition) FillPath

func (target *Partition) FillPath(basePath string)

func (*Partition) GetLUKSMapperPath

func (part *Partition) GetLUKSMapperPath() (string, error)

func (*Partition) GetPath

func (part *Partition) GetPath() string

func (*Partition) GetUUID

func (target *Partition) GetUUID() (string, error)

func (*Partition) IsMounted

func (part *Partition) IsMounted() (bool, error)

func (*Partition) Mount

func (part *Partition) Mount(location string) error

func (*Partition) Mountpoints

func (part *Partition) Mountpoints() ([]string, error)

func (*Partition) NamePartition

func (target *Partition) NamePartition(name string) error

func (*Partition) RemovePartition

func (target *Partition) RemovePartition() error

func (*Partition) ResizePartition

func (target *Partition) ResizePartition(newEnd int) error

func (*Partition) SetLabel

func (part *Partition) SetLabel(label string) error

func (*Partition) SetPartitionFlag

func (target *Partition) SetPartitionFlag(flag string, state bool) error

func (*Partition) UnmountPartition

func (part *Partition) UnmountPartition() error

func (*Partition) WaitUntilAvailable

func (part *Partition) WaitUntilAvailable()

WaitUntilAvailable polls the specified partition until it is available. This is particularly useful to make sure a recently created or modified partition is recognized by the system.

type PartitionFs

type PartitionFs string

type Sector

type Sector struct {
	Start, End int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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