disk

package
v0.0.0-...-b79a0d8 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package disk handles logical disks, filesystems, and boot entries for the purposes of factory restore.

Index

Constants

View Source
const K_OVERRIDE = "KERNEL_OVERRIDE"

Variables

View Source
var CantHandleThisFS = errors.New("Can't handle unknown format of recovery fs")
View Source
var NotRecoveryFS = errors.New("not a recovery fs")

Functions

func IOCopy

func IOCopy(dst io.Writer, src io.Reader, progressFunc func(int64)) (written int64, err error)

modified version of io.Copy(). slower, but allows progress reporting

func PartitionRecovery

func PartitionRecovery(d *Disk) error

partition recovery device

func PlatIdentFromRecovery

func PlatIdentFromRecovery() (string, error)

Assume recovery volume will have label imaging.RecVolName(), and read a file 'platform' from the root dir. Return its contents, which will be the platform code name. Use when normal platform ident fails. Volume is not left mounted.

func UnmountAll

func UnmountAll(_ bool)

Types

type Disk

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

func DiskFromDev

func DiskFromDev(dev block.BlockDev) *Disk

func FindTargets

func FindTargets(platform *appliance.Variant) (disks []*Disk)

find the raw disk(s) we'll partition and install to

func (*Disk) CreateNonArray

func (d *Disk) CreateNonArray(platform *appliance.Variant) (fs *Filesystem)

only for non-raid platforms

func (Disk) Device

func (d Disk) Device() string

func (*Disk) Partition

func (d *Disk) Partition(platform *appliance.Variant) error

partition a disk. small boot partition, remainder for raid also zero beginning and end of disk so raid controller will ignore it if the controller somehow gets re-enabled

func (Disk) SizeBytes

func (d Disk) SizeBytes() int64

func (Disk) TargetDev

func (d Disk) TargetDev() string

func (Disk) Valid

func (d Disk) Valid() bool

func (*Disk) Zero

func (d *Disk) Zero(megs uint, whence int)

clears bytes at beginning or end of drive. Whence should be 'disk.SeekStart' or 'disk.SeekEnd'. NOT a substitute for secure erase.

type Filesystem

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

func ConfigUEFIBoot

func ConfigUEFIBoot(recov, ESP *Filesystem, overwriteBootEnts bool, extraOpts string) (bootParts []*Filesystem)

add missing boot entries or overwrite all return the ESP partition as a Filesystem (for adding to fstab) in recovery, boot entries should be correct

func CreateArray

func CreateArray(disks []*Disk, host string, platform *appliance.Variant) (md *Filesystem)

run mdadm to create and start array

func CreateRecovery

func CreateRecovery(platform *appliance.Variant, recoverySize uint64, extraOpts string) (recov *Filesystem)

func ExistingExt4Fs

func ExistingExt4Fs(device string, mounted bool) (fs *Filesystem)

func ExistingFs

func ExistingFs(device, mntType, mntOpts string, mounted bool) (fs *Filesystem)

ExistingFs creates a Filesystem struct corresponding to a fs that already exists. See also: Filesystem.AutoUnmount()

func FindRecovery

func FindRecovery(platform *appliance.Variant) (recovery *Filesystem)

find recovery volume by looking for the fs label

func MakeBootable

func MakeBootable(disks []*Disk, mainFS, recov *Filesystem, platform *appliance.Variant, extraOpts string) []*Filesystem

determine whether system is uefi or legacy and make it bootable. returns list of additional partitions for fstab

func TestFilesystem

func TestFilesystem(dir string) (fs Filesystem)

func WriteLegacyBootParts

func WriteLegacyBootParts(disks []*Disk, target, recov *Filesystem, platform *appliance.Variant, extraOpts string) (bootParts []*Filesystem)

Format boot partitions, write files to them. Ensures that kernel used is most recent of those available.

func (*Filesystem) AutoUnmount

func (fs *Filesystem) AutoUnmount()

Add fs to list for auto-unmount, if it isn't already. For use with ExistingFs().

func (Filesystem) Device

func (fs Filesystem) Device() string

func (*Filesystem) FixupRecoveryFS

func (fs *Filesystem) FixupRecoveryFS() (err error)

recovery can have conflicting options for multiple filesystems. Remove any that don't make sense for this fs type.

func (*Filesystem) Format

func (fs *Filesystem) Format(label string) (err error)

func (Filesystem) Fsid

func (fs Filesystem) Fsid() string

func (Filesystem) FstabEntry

func (fs Filesystem) FstabEntry(uid, gid string) (entry string)

func (Filesystem) FstabMountpoint

func (fs Filesystem) FstabMountpoint() string

func (*Filesystem) InstallGrub4Dos

func (fs *Filesystem) InstallGrub4Dos()

install grub4dos to MBR

func (Filesystem) IsMounted

func (fs Filesystem) IsMounted() bool

func (Filesystem) Label

func (fs Filesystem) Label() string

func (*Filesystem) Mount

func (fs *Filesystem) Mount()

func (*Filesystem) MountErr

func (fs *Filesystem) MountErr() (path string, err error)

func (Filesystem) Path

func (fs Filesystem) Path() string

returns current mount point, or "/dev/null"

func (*Filesystem) SetMountpoint

func (fs *Filesystem) SetMountpoint(pt string)

sets the mount point of a fs, before writing fstab. if mounted, mount location is still retrievable via Path()

func (Filesystem) SetOwnerAndPerms

func (fs Filesystem) SetOwnerAndPerms(uid, gid string)

func (*Filesystem) Umount

func (fs *Filesystem) Umount()

func (*Filesystem) UnderlyingDevice

func (fs *Filesystem) UnderlyingDevice() (dev string)

Find the identifier (e.g. sdb) of the physical device this filesystem is on.

blkdev is probably a partition (subdevice). Try to find base device by
removing chars one at a time and checking if a file with that name exists
in /sys/block.

func (Filesystem) Valid

func (fs Filesystem) Valid() bool

true if it appears that it would be possible to mount the fs - regardless of whether it is mounted at this time

func (*Filesystem) WriteFallbackBootMenu

func (fs *Filesystem) WriteFallbackBootMenu()

func (Filesystem) WriteFstab

func (fs Filesystem) WriteFstab(uid, gid string, mounts ...common.FS)

Jump to

Keyboard shortcuts

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