Documentation
¶
Index ¶
Constants ¶
const ( KairosDefaultArtifactName = "kairos" IsoEFIPath = "/boot/uefi.img" EfiBootPath = "/EFI/BOOT" EfiLabel = "COS_GRUB" EfiFs = "vfat" IsoRootFile = "rootfs.squashfs" ISOLabel = "COS_LIVE" ShimEfiDest = EfiBootPath + "/bootx64.efi" ShimEfiArmDest = EfiBootPath + "/bootaa64.efi" BuildImgName = "elemental" GrubCfg = "grub.cfg" GrubPrefixDir = "/boot/grub2" GrubEfiCfg = "search --no-floppy --file --set=root " + IsoKernelPath + "\nset prefix=($root)" + GrubPrefixDir + "\nconfigfile $prefix/" + GrubCfg // GrubEfiRecovery Used for RAW images as we chainload the grub config in the recovery partition GrubEfiRecovery = "search --no-floppy --label --set=root COS_RECOVERY" + "\nset root=($root)" + "\nset prefix=($root)/grub2\n" + "configfile ($root)/etc/cos/grub.cfg" IsoBootCatalog = "/boot/boot.catalog" IsoHybridMBR = "/boot/boot_hybrid.img" IsoBootFile = "/boot/eltorito.img" // These paths are arbitrary but coupled to grub.cfg IsoKernelPath = "/boot/kernel" IsoInitrdPath = "/boot/initrd" // Default directory and file fileModes DirPerm = os.ModeDir | os.ModePerm FilePerm = 0666 NoWriteDirPerm = 0555 | os.ModeDir TempDirPerm = os.ModePerm | os.ModeSticky | os.ModeDir ArchArm64 = "arm64" Archx86 = "x86_64" ArchAmd64 = "amd64" Archaarch64 = "aarch64" UkiCmdline = "" /* 164-byte string literal not displayed */ UkiCmdlineInstall = "install-mode" UkiSystemdBootx86 = "/amd/systemd-boot/systemd-bootx64.efi" UkiSystemdBootStubx86 = "/amd/systemd-boot/linuxx64.efi.stub" UkiSystemdBootArm = "/arm/systemd-boot/systemd-bootaa64.efi" UkiSystemdBootStubArm = "/arm/systemd-boot/linuxaa64.efi.stub" EfiFallbackNamex86 = "BOOTX64.EFI" EfiFallbackNameArm = "BOOTAA64.EFI" ArtifactBaseName = "norole" DefaultCloudConfig = `` /* 166-byte string literal not displayed */ )
const ( OpPrepareDirs = "prepare-dirs" OpDownloadISO = "download-iso" OpCopyCloudConfig = "copy-cloud-config" OpInjectCC = "inject-cloud-config" OpStartHTTPServer = "start-httpserver" OpStartNetboot = "start-netboot" OpDumpSource = "dump-source" OpGenISO = "gen-iso" OpExtractNetboot = "extract-netboot" OpGenEFIRawDisk = "gen-raw-efi-disk" OpGenBIOSRawDisk = "gen-raw-bios-disk" OpConvertGCE = "convert-gce" OpConvertVHD = "convert-vhd" )
Ops constants
const GB = 1024 * MB
const MB = int64(1024 * 1024)
Variables ¶
var BootHybrid []byte
BootHybrid is boot_hybrid.img which comes bundled with grub Its ASM to boot from the grub image embedded You can check its source here: https://github.com/rhboot/grub2/blob/fedora-39/grub-core/boot/i386/pc/cdboot.S
var Eltorito []byte
Eltorito image is basically a grub cdboot.img + grub core image So basically you build a grub image with modules embedded and prepend it with the cdboot, which allows it to boot from CDRom and run the grub embedded in the image directly from BIOS This can be generated from any distro by runing something like:
grub2-mkimage -O i386-pc -o core.img -p /boot/grub2 -d PATH_TO_i386_MODULES ext2 iso9660 linux echo configfile search_label search_fs_file search search_fs_uuid ls normal gzio gettext font gfxterm gfxmenu all_video test true loadenv part_gpt part_msdos biosdisk vga vbe chain boot cat $(find / -name cdboot.img -print) core.img > eltorito.img
Important things in the grub image creation:
- -O i386-pc is the architecture we want to build the image for. Bios is i386
- -p is the prefix dir, this is where grub will start searching for things, including the grub.cfg config, when it boots
- -d is the current dir where modules and images are. Usually this is automatically set so it can be dropped
- the list at the end are the modules to bundle for grub. Honestly the list is not too big and it can probably be dropped to like half for the livecd as it only uses linux, echo, font, video ones and boot. But it doesnt hurt to have extra modules.
var GrubLiveBiosCfg []byte
GrubLiveBiosCfg is the livecd config for BIOS boot
Functions ¶
func GetDefaultSquashfsOptions ¶
func GetDefaultSquashfsOptions() []string
GetDefaultSquashfsOptions returns the default options to use when creating a squashfs
func GetXorrisoBooloaderArgs ¶
func OutPutTypes ¶
func OutPutTypes() []string