Documentation ¶
Overview ¶
Package disk handles logical disks, filesystems, and boot entries for the purposes of factory restore.
Index ¶
- Constants
- Variables
- func IOCopy(dst io.Writer, src io.Reader, progressFunc func(int64)) (written int64, err error)
- func PartitionRecovery(d *Disk) error
- func PlatIdentFromRecovery() (string, error)
- func UnmountAll(_ bool)
- type Disk
- func (d *Disk) CreateNonArray(platform *appliance.Variant) (fs *Filesystem)
- func (d Disk) Device() string
- func (d *Disk) Partition(platform *appliance.Variant) error
- func (d Disk) SizeBytes() int64
- func (d Disk) TargetDev() string
- func (d Disk) Valid() bool
- func (d *Disk) Zero(megs uint, whence int)
- type Filesystem
- func ConfigUEFIBoot(recov, ESP *Filesystem, overwriteBootEnts bool, extraOpts string) (bootParts []*Filesystem)
- func CreateArray(disks []*Disk, host string, platform *appliance.Variant) (md *Filesystem)
- func CreateRecovery(platform *appliance.Variant, recoverySize uint64, extraOpts string) (recov *Filesystem)
- func ExistingExt4Fs(device string, mounted bool) (fs *Filesystem)
- func ExistingFs(device, mntType, mntOpts string, mounted bool) (fs *Filesystem)
- func FindRecovery(platform *appliance.Variant) (recovery *Filesystem)
- func MakeBootable(disks []*Disk, mainFS, recov *Filesystem, platform *appliance.Variant, ...) []*Filesystem
- func TestFilesystem(dir string) (fs Filesystem)
- func WriteLegacyBootParts(disks []*Disk, target, recov *Filesystem, platform *appliance.Variant, ...) (bootParts []*Filesystem)
- func (fs *Filesystem) AutoUnmount()
- func (fs Filesystem) Device() string
- func (fs *Filesystem) FixupRecoveryFS() (err error)
- func (fs *Filesystem) Format(label string) (err error)
- func (fs Filesystem) Fsid() string
- func (fs Filesystem) FstabEntry(uid, gid string) (entry string)
- func (fs Filesystem) FstabMountpoint() string
- func (fs *Filesystem) InstallGrub4Dos()
- func (fs Filesystem) IsMounted() bool
- func (fs Filesystem) Label() string
- func (fs *Filesystem) Mount()
- func (fs *Filesystem) MountErr() (path string, err error)
- func (fs Filesystem) Path() string
- func (fs *Filesystem) SetMountpoint(pt string)
- func (fs Filesystem) SetOwnerAndPerms(uid, gid string)
- func (fs *Filesystem) Umount()
- func (fs *Filesystem) UnderlyingDevice() (dev string)
- func (fs Filesystem) Valid() bool
- func (fs *Filesystem) WriteFallbackBootMenu()
- func (fs Filesystem) WriteFstab(uid, gid string, mounts ...common.FS)
Constants ¶
const K_OVERRIDE = "KERNEL_OVERRIDE"
Variables ¶
var CantHandleThisFS = errors.New("Can't handle unknown format of recovery fs")
var NotRecoveryFS = errors.New("not a recovery fs")
Functions ¶
func PlatIdentFromRecovery ¶
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 FindTargets ¶
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
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)