Documentation ¶
Index ¶
- func AddCmdToGRUB(grubPath, cmd string) error
- func ConvertSizeToBytes(size string) (uint64, error)
- func ConvertSizeToGBRoundUp(size string) (uint64, error)
- func ExtendPartition(disk string, partNumInt int, end uint64) error
- func FindLast4KSector(start uint64) uint64
- 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 PartNumIntToString(disk string, partNumInt int) (string, error)
- func ReadPartitionSize(disk string, partNumInt int) (uint64, error)
- func ReadPartitionStart(disk string, partNumInt int) (uint64, error)
- func ReadPartitionTable(disk string) (string, error)
- func UnmountEFIPartition() error
- type PartContent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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 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 grub.cfg is at.
func MovePartition ¶
MovePartition moves a partition to a start sector. It takes destination input like 2048 (absolute sector number), +5G or -200M.
func PartNumIntToString ¶
PartNumIntToString converts input int partNumInt into string, if disk ends with number, add 'p' to the front. Example: /dev/loop5p1
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 UnmountEFIPartition ¶
func UnmountEFIPartition() error
UnmountEFIPartition unmounts the EFI partition (/dev/sda12)
Types ¶
type PartContent ¶
PartContent contains the info of a partition