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 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.

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

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

Download a Gentoo Stage 3, unpack it to, and chroot into it and build the system following the Gentoo Handbook and other guides as necessary.

Install necessary tools to the system:

Build kernel
Use to make a kernel and initramfs, add extra parameters as necessary (see Genkernel for details):

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

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

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] in the directory customrescuecd64/boot/grub/

Create the file adjusting kernel and initramfs versions as necessary:

cd into customrescuecd64/EFI/customiso/

create a empty file named grub.img to create the boot efi partition

format it with FAT12 filesystem

mount grub.img into /boot/efi of your stage4

from your stage4 chroot

create the grub image efi boot executable