How To Make CustomRescueCD

Overview
This document will walk readers through the steps to create a Gentoo stage4 inside a squashfs and subsequently use it in a bootable ISO9660 image.

The steps are to make a Gentoo Install to your taste inside a directory. This follows the Handbook. Add or remove packages to your taste. This will become customrescuecd-squash, which will be the root filesystem in the CD.

This will then be packaged with a syslinux /boot to make the bootable ISO9660 image.

Burning the image to a CD or making a bootable USB stick will not be addressed.

Examine the structure of the ISO:

 * ./boot/grub/font.pf2
 * ./boot/grub/grub.cfg <-- Grub Configuration File for EFI BOOT
 * ./boot/grub/x86_64-efi
 * ./boot/grub/x86_64-efi/all_video.mod
 * ./boot/grub/x86_64-efi/efi_gop.mod
 * ./boot/grub/x86_64-efi/efi_uga.mod
 * ./boot/grub/x86_64-efi/gfxterm.mod
 * ./boot/grub/x86_64-efi/video.mod
 * ./boot/grub/x86_64-efi/videoinfo.mod
 * ./boot/grub/x86_64-efi/videotest.mod
 * ./boot/memtest86plus/memtest
 * ./boot/memtest86plus/memtest.bin <-- Memtest kernel for bios boot
 * ./boot/syslinux/chain.c32
 * ./boot/syslinux/syslinux.cfg <--- Main Syslinux Configuration File
 * ./boot/syslinux/customresccd.cfg
 * ./boot/syslinux/customresccd_head.cfg
 * ./boot/syslinux/customresccd_pxe.cfg
 * ./boot/syslinux/customresccd_sys.cfg
 * ./boot/syslinux/customresccd_tail.cfg
 * ./boot/syslinux/isohdpfx.bin <--- Syslinux MBR for Bios Boot
 * ./boot/syslinux/isolinux.bin <--- Syslinux Image
 * ./boot/syslinux/boot.cat <--- Syslinux Boot Catalogue
 * ./boot/syslinux/ldlinux.c32
 * ./boot/syslinux/ldlinux.sys
 * ./boot/syslinux/libcom32.c32
 * ./boot/syslinux/libutil.c32
 * ./boot/syslinux/memdisk
 * ./boot/syslinux/poweroff.c32
 * ./boot/syslinux/pxelinux.0
 * ./boot/syslinux/reboot.c32
 * ./boot/syslinux/vesamenu.c32
 * ./boot/syslinux/whichsys.c32
 * ./boot/x86_64/customrescue64 <-- CustomRescueCd KERNEL
 * ./customresccd/x86_64/customrescuecd.sfs <--- SquashFS
 * ./customresccd/x86_64/customrescuecd.sha512 < Sha512 of Squashfs
 * ./EFI/boot/bootx64.efi < Grub Efi Executable for usb stick boot
 * ./EFI/customiso/grub.img <--- Grub Partition in append to iso for efi boot that contain .efi executable

Create The Work Space
I advise you to keep two terminals open, one for the stage 4 chroot and another you will need to create the squash and the iso ahead.

customrescuecd-squash is for the stage4. This will be turned into a squashfs later.

customrescuecd64 is for the files that will become the ISO9660 filesystem, including the squashfs above.

Download a Gentoo Stage 3, explode into it and build your own system following the Gentoo Handbook and other guides to add a Graphical User Interface.

Remember to emerge syslinux and grub! Insert GRUB_PLATFORMS="efi-64" into make.conf of your stage4

Build kernel
Download the initramfs tarball from [//sourceforge.net/projects/customrescuecd/files/SDK/initramfs64.tar.xz initramfs64.tar.xz] explode it in /usr/src of your stage4


 * 1) Populate the initramfs with the linux firmware in /lib/firmware of initramfs

emerge the last gentoo-sources, at this time is gentoo-sources-5.7.2, the kernel configuration can be found on [//sourceforge.net/projects/customrescuecd/files/SDK/config-5.7.2 config-5.7.2], put in your stage4 under the kernel source directory /usr/src/linux-5.7.2-gentoo and save as .config

build the modules for first time to obtain modules to copy into initramfs /lib/modules

to correct the configuration file if kernel version is different from 5.7.2 and

copy the modules into initramfs lib/modules {{RootCmd| cp -r /lib/modules/5.7.2-gentoo /usr/src/initramfs64/lib/modules/

then clean and rebuild the kernel so that the kernel includes the initramfs with modules and firmware files {{RootCmd| make clean mrproper }} {{RootCmd| make bzImage modules modules_install }} copy the resultant kernel into customrescuecd64/boot/x86_64/customrescue64

The customrescuecd64 directory must contain these subdirectories:

 * boot/syslinux
 * boot/grub/x86_64-efi
 * boot/memtest86plus
 * boot/x86_64
 * EFI/boot
 * EFI/customiso
 * customresccd/x86_64

Creating the squashfs
Make an excludes file with the following content.

Add any other files and directories to be excluded from the squashfs

Save the file as exclude.txt

Build the squashfs using the exclude.txt file created above.

Build the sha512 checksum because the initramfs verify the checksum

Syslinux
Download the syslinux cfg from [//sourceforge.net/projects/customrescuecd/files/SDK/syslinux.cfg.tar.xz syslinux.cfg.tar.xz] and explode into customrescuecd64/boot/syslinux/ the content of this directory must be the one that follow! All *.c32 and memdisk isolinux.bin boot.cat pxelinux.0 isohdpfx.bin file you can copy from your stage4 at folder /usr/share/syslinux/


 * customresccd_tail.cfg
 * poweroff.c32
 * customresccd_head.cfg
 * boot.cat
 * syslinux.cfg
 * pxelinux.0
 * reboot.c32
 * isohdpfx.bin
 * libcom32.c32
 * whichsys.c32
 * chain.c32
 * ldlinux.sys
 * memdisk
 * vesamenu.c32
 * isolinux.bin
 * customresccd_pxe.cfg
 * ldlinux.c32
 * customresccd_sys.cfg
 * customresccd.cfg
 * libutil.c32

Grub
in the directory customrescuecd64/boot/grub/x86_64-efi/ copy the files all_video.mod efi_gop.mod  efi_uga.mod  gfxterm.mod  videoinfo.mod  videotest.mod from /usr/lib/grub/x86_64-efi/ of your stage4

download the [//sourceforge.net/projects/customrescuecd/files/SDK/font.pf2 font.pf2] and [//sourceforge.net/projects/customrescuecd/files/SDK/grub.conf grub.conf] in the directory customrescuecd64/boot/grub/

cd into customrescuecd64/EFI/customiso/ create a empty file named grub.img to create the boot efi partition