Documentation
¶
Index ¶
- Variables
- func AddCmdToGRUB(grubPath, cmd string) error
- func BootDev(rootdevCmd string) (string, error)
- func ConvertSizeToBytes(size string) (uint64, error)
- func ConvertSizeToGBRoundUp(size string) (uint64, error)
- func ExtendPartition(disk string, partNumInt int, end uint64, extendFS bool) error
- func FindLast4KSector(start uint64) uint64
- func GPTPriority(attrs string) (uint64, error)
- func GRUBContains(grubPath, cmd string) (bool, error)
- func GetPartUUID(partName string) (string, error)
- func HandlePartitionTable(table, partName string, change bool, f func(p *PartContent)) (string, error)
- func IsPartitionMinimal(disk string, partNumInt int) (bool, error)
- func MinimizePartition(disk string, partNumInt int) (uint64, error)
- func MountEFIPartition() (string, error)
- func MovePartition(disk string, partNumInt int, dest string) error
- func ParseGPTAttrs(attrs string) (uint64, error)
- func PartNumIntToString(disk string, partNumInt int) (string, error)
- func ReadPartitionData(disk string, partNum int) ([]byte, error)
- func ReadPartitionSize(disk string, partNumInt int) (uint64, error)
- func ReadPartitionStart(disk string, partNumInt int) (uint64, error)
- func ReadPartitionTable(disk string) (string, error)
- func ReadPartitionUUID(disk string, partNumInt int) (string, error)
- func UnmountEFIPartition() error
- func WritePartitionData(disk string, partNum int, data []byte) error
- type PartContent
- type Partition
- type PartitionTable
- type SFDiskTable
Constants ¶
This section is empty.
Variables ¶
var GRUBCfgEFIPath = "/efi/boot/grub.cfg"
Functions ¶
func AddCmdToGRUB ¶
AddCmdToGRUB adds a command string to after every `cros_efi` command
func ConvertSizeToBytes ¶
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 ¶
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 ¶
ExtendPartition extends a partition to a specific end sector.
func FindLast4KSector ¶
FindLast4KSector returns the last 4K bytes aligned sector from start. If input is a 4K aligned sector, return itself.
func GPTPriority ¶
GPTPriority extracts the GPT priority value from the given sfdisk attributes.
func GRUBContains ¶
GRUBContains seaches for the command string inside of the GRUB file
func GetPartUUID ¶
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 ¶
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 ¶
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 ¶
MountEFIPartition mounts the EFI partition (/dev/sda12) and returns the path where it is mounted.
func MovePartition ¶
MovePartition moves a partition to a start sector. It takes destination input like 2048 (absolute sector number), +5G or -200M.
func ParseGPTAttrs ¶
ParseGPTAttrs reads a GPT attributes string output by sfdisk and converts it into a uint64 with the appropriate bits set.
func PartNumIntToString ¶
PartNumIntToString converts input int partNumInt into string, if disk ends with number, add 'p' to the front. Example: /dev/loop5p1
func ReadPartitionData ¶
ReadPartitionData reads the content of the given partition on the given disk.
func ReadPartitionSize ¶
ReadPartitionSize reads the size of a partition (unit:sectors of 512 Bytes).
func ReadPartitionStart ¶
ReadPartitionStart reads the start sector of a partition.
func ReadPartitionTable ¶
ReadPartitionTable reads the partition table of a disk.
func ReadPartitionUUID ¶
ReadPartitionUUID reads PARTUUID of a partition.
func UnmountEFIPartition ¶
func UnmountEFIPartition() error
UnmountEFIPartition unmounts the EFI partition (/dev/sda12)
Types ¶
type PartContent ¶
PartContent contains the info of a partition
type PartitionTable ¶
type SFDiskTable ¶
type SFDiskTable struct {
PartitionTable PartitionTable `json:"partitiontable"`
}
func ReadPartitionTableJSON ¶
func ReadPartitionTableJSON(disk string) (SFDiskTable, error)
ReadPartitionTableJSON reads a partition table into a SFDiskTable type.