Documentation
¶
Overview ¶
Package disklayout describes the gokrazy on-disk partition layout and provides helpers for writing it. It is intended for use by tools that install a gokrazy image onto a fresh disk (e.g. SD card flashing tools), so they can lay out the partition table the same way monogok does when it produces a full disk image.
Index ¶
- Constants
- func BootStartLBA(firstLBA int64) uint32
- func BuildMBR(bootCode []byte, firstLBA int64, devsize uint64) ([512]byte, error)
- func PermSize(firstLBA int64, devsize uint64) uint32
- func PermStartLBA(firstLBA int64) uint32
- func RootAStartLBA(firstLBA int64) uint32
- func RootBStartLBA(firstLBA int64) uint32
- func WritePartitionTable(w io.Writer, firstLBA int64, devsize uint64) error
Constants ¶
const ( // BootPartitionSizeMB is the gokrazy boot (FAT) partition size. BootPartitionSizeMB = 100 // RootPartitionSizeMB is the size of each of the two gokrazy root // (squashfs) partitions; the two are sized identically so OTA // updates can swap between them. RootPartitionSizeMB = 500 // MinDiskMB is the smallest device size in megabytes that can hold // a gokrazy install with one byte of perm space, given // DefaultBootPartitionStartLBA. MinDiskMB = (DefaultBootPartitionStartLBA*sectorSize)/mb + BootPartitionSizeMB + 2*RootPartitionSizeMB + 1 )
const DefaultBootPartitionStartLBA int64 = 8192
DefaultBootPartitionStartLBA is the standard LBA at which gokrazy places the first (boot) partition. 8192 sectors of 512 bytes = 4 MiB, the recommended alignment for SD cards.
Variables ¶
This section is empty.
Functions ¶
func BootStartLBA ¶
BootStartLBA returns the LBA where the boot partition starts.
func BuildMBR ¶
BuildMBR returns a complete 512-byte MBR boot sector for a fresh gokrazy disk install: 446 bytes of bootCode (zero-padded if shorter; rejected if longer), followed by the 64-byte gokrazy partition table, followed by the 0xAA55 boot signature.
func PermSize ¶
PermSize returns the perm partition size in sectors on a disk of devsize bytes whose first partition starts at firstLBA. It is the unclamped "fill the rest of the disk" size, matching what monogok writes when building a full MBR image. Callers that need to reserve trailing space (e.g. for a secondary GPT) must subtract it themselves.
func PermStartLBA ¶
PermStartLBA returns the LBA where the perm (writable, ext4) partition starts.
func RootAStartLBA ¶
RootAStartLBA returns the LBA where the root A partition starts.
func RootBStartLBA ¶
RootBStartLBA returns the LBA where the root B partition starts.
func WritePartitionTable ¶
WritePartitionTable writes the 64-byte gokrazy MBR primary partition table to w (not including the 446-byte boot code prefix or the 2-byte 0xAA55 signature). devsize is the total disk size in bytes.
firstLBA is typically DefaultBootPartitionStartLBA. devsize must be large enough to hold the boot + both root partitions + at least one perm sector, or an error is returned.
Types ¶
This section is empty.