partutil

package
v0.0.0-...-02cb986 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCmdToGRUB

func AddCmdToGRUB(grubPath, cmd string) error

AddCmdToGRUB adds a command string to after every `cros_efi` command

func BootDev

func BootDev(rootdevCmd string) (string, error)

func ConvertSizeToBytes

func ConvertSizeToBytes(size string) (uint64, error)

ConvertSizeToBytes converts a size string to int unit: bytes. It takes a string of number with no unit (sectors), unit B, unit K, unit M, or unit G.

func ConvertSizeToGBRoundUp

func ConvertSizeToGBRoundUp(size string) (uint64, error)

ConvertSizeToGBRoundUp converts input size to GB unit. Rounded up, since extend disk can only take GB unit. Used by Daisy workflow to resize the disk.

func ExtendPartition

func ExtendPartition(disk string, partNumInt int, end uint64) error

ExtendPartition extends a partition to a specific end sector.

func FindLast4KSector

func FindLast4KSector(start uint64) uint64

FindLast4KSector returns the last 4K bytes aligned sector from start. If input is a 4K aligned sector, return itself.

func GRUBContains

func GRUBContains(grubPath, cmd string) (bool, error)

GRUBContains seaches for the command string inside of the GRUB file

func GetPartUUID

func GetPartUUID(partName string) (string, error)

GetPartUUID finds the PartUUID of a partition using blkid

func HandlePartitionTable

func HandlePartitionTable(table, partName string, change bool, f func(p *PartContent)) (string, error)

HandlePartitionTable takes a partition table and get the start and size of the target partition. If change==true, it will rebuild the partition table with data passed in by p *PartContent and return the new table

func IsPartitionMinimal

func IsPartitionMinimal(disk string, partNumInt int) (bool, error)

IsPartitionMinimal determines if a partition is the smallest size it can be. If this function returns true, MinimizePartition can make the given partition smaller.

func MinimizePartition

func MinimizePartition(disk string, partNumInt int) (uint64, error)

MinimizePartition minimizes the input partition and returns the next sector of the end sector. The smallest partition from fdisk is 1 sector partition.

func MountEFIPartition

func MountEFIPartition() (string, error)

MountEFIPartition mounts the EFI partition (/dev/sda12) and returns the path where grub.cfg is at.

func MovePartition

func MovePartition(disk string, partNumInt int, dest string) error

MovePartition moves a partition to a start sector. It takes destination input like 2048 (absolute sector number), +5G or -200M.

func PartNumIntToString

func PartNumIntToString(disk string, partNumInt int) (string, error)

PartNumIntToString converts input int partNumInt into string, if disk ends with number, add 'p' to the front. Example: /dev/loop5p1

func ReadPartitionSize

func ReadPartitionSize(disk string, partNumInt int) (uint64, error)

ReadPartitionSize reads the size of a partition (unit:sectors of 512 Bytes).

func ReadPartitionStart

func ReadPartitionStart(disk string, partNumInt int) (uint64, error)

ReadPartitionStart reads the start sector of a partition.

func ReadPartitionTable

func ReadPartitionTable(disk string) (string, error)

ReadPartitionTable reads the partition table of a disk.

func UnmountEFIPartition

func UnmountEFIPartition() error

UnmountEFIPartition unmounts the EFI partition (/dev/sda12)

Types

type PartContent

type PartContent struct {
	Start uint64
	Size  uint64
}

PartContent contains the info of a partition

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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