<> = Live-Build Steps for building a custom ISO, IMG or Netboot Tar Ball with a custom kernel = Live-Build is a Debian based infrastructure -> [[https://debian-live.alioth.debian.org/live-manual/unstable/manual/html/live-manual.en.html|Debian Live-Build Manual]] == Build Host Requirements == '''ppc64el''' images are built on a '''ppc64el''' host == Setting up Live-Build with Patches == There are two patches needed to build and install '''ppc64el''' '''ISO's''', '''IMG's''' and '''Netboot Tar Ball's'''. As of '''March 23, 2017''', you will need to clone and build '''grub2''' on the build machine to include a patch for the ieee1275 chrp grub install [[https://wiki.ubuntu.com/ppc64el/grub2|How To Build and Install Grub2]] === Install pre-req's === {{{ myuser@ppc64el:~ $ sudo apt-get install debootstrap debhelper kpartx gdisk devscripts dh-systemd live-build isolinux po4a }}} === Clone the live-build tree === {{{ myuser@ppc64el:~ $ git clone git://anonscm.debian.org/git/debian-live/live-build.git myuser@ppc64el:~ $ cd live-build }}} === Apply the Patches === {{{ myuser@ppc64el:~/live-build $ git am 0001-live-build-binary_hdd-enablement-for-ppc64el.patch myuser@ppc64el:~/live-build $ git am 0002-live-build-installer-enablement-for-ppc64el.patch }}} [[attachment:0001-live-build-binary_hdd-enablement-for-ppc64el.patch]] [[attachment:0002-live-build-installer-enablement-for-ppc64el.patch]] === Build Live-Build === {{{ myuser@ppc64el:~/live-build $ sudo dpkg-buildpackage -b -uc -us myuser@ppc64el:~/live-build $ sudo make install myuser@ppc64el:~/live-build $ lb -v 1:20170920 <- This should reflect the current level of the git tree }}} == Sample Live-Build Configuration == This tutorial is based on a pre-configured setup for '''ppc64el'''. Be mindful that the sample config builds for the case of '''IMG''' an '''auto''' sized hard disk drive (which is a minimal size). If you are adding packages and need extra hard disk space, tweak the '''LB_HDD_SIZE''' in the '''config/binary'''. The patch file has a prologue which explains a little more detail on more advanced customizations and tweaks, '''0001-live-build-binary_hdd-enablement-for-ppc64el.patch'''. === Download the tar file === [[attachment:latest-fwts-live-v5-ppc64el.tar.gz]] === Setup and Build === {{{ myuser@ppc64el:~ $ sudo mkdir lb-setup <- lb-setup directory can be named anything you want }}} {{{ myuser@ppc64el:~ $ sudo cp latest-fwts-live-v5-ppc64el.tar.gz ~/lb-setup myuser@ppc64el:~ $ cd lb-setup myuser@ppc64el:~/lb-setup $ sudo tar -xvf latest-fwts-live-v5-ppc64el.tar.gz }}} The sample configuration builds an '''ISO''', if you want to build an '''IMG''' or '''Netboot Tar Ball''' {{{ myuser@ppc64el:~/lb-setup $ sudo vi config/build <=== Change "Type: iso-hybrid" or "Type: hdd" or "Type: netboot" myuser@ppc64el:~/lb-setup $ sudo lb clean --all myuser@ppc64el:~/lb-setup $ sudo lb build 2>&1 | tee /home/myuser/build.log myuser@ppc64el:~/lb-setup $ ls -al live-image-ppc64el.iso <- This is the output file based on the Type you chose to build. }}} If you built an '''IMG''' or '''Netboot Tar Ball''' look for '''live-image-ppc64el.img''' or '''live-image-ppc64el.netboot.tar''' == Running the ISO == === Install pre-req's === {{{ myuser@ppc64el:~/lb-setup $ sudo apt-get install qemu-kvm qemu-utils }}} === Run the Live Image and Optional Install === {{{ myuser@ppc64el:~/lb-setup $ sudo kvm -cdrom live-image-ppc64el.iso -m 2G -nographic -nodefaults -serial stdio }}} == Running the IMG == === Install pre-req's === {{{ myuser@ppc64el:~/lb-setup $ sudo apt-get install qemu-kvm qemu-utils }}} === Run the Live Image and Optional Install === {{{ myuser@ppc64el:~/lb-setup $ sudo kvm -hda live-image-ppc64el.img -m 2G -nographic -nodefaults -serial stdio }}} == Running the Netboot Tar Ball == === Install pre-req's === {{{ myuser@ppc64el:~/lb-setup $ sudo apt-get install qemu-kvm qemu-utils }}} === Run the Live Image and Optional Install === When you expand the '''live-image-ppc64el.netboot.tar''' file it contains various piece parts of the live-build output. Use the '''tftpboot/ubuntu-installer/ppc64el/vmlinux''' and '''tftpboot/ubuntu-installer/ppc64el/initrd.gz''' To try this out on a '''VM''', make a '''.IMG''' file to hold the installed '''OS''' you will create by using the '''kernel''' and '''initrd''' from the netboot tar file: {{{ $ sudo dd if=/dev/zero of=mydrive.img bs=1G count=10 $ sudo kvm -m 2G -serial stdio -nographic -nodefaults -netdev user,id=net0 -device virtio-net-pci,netdev=net0 -device virtio-blk-pci,drive=drive0 -drive id=drive0,if=none,file=mydrive.img -kernel vmlinux -initrd initrd.gz }}} The '''initrd.gz''' embeds a completely automated '''preseed.cfg''' which asks '''NO''' questions and will install to the disk device detected. If you do '''NOT''' wish to have this complete automation, you will need to re-build '''WITHOUT''' the '''preseed.cfg'''. See the '''Advanced Customization''' section for how to remove the '''preseed.cfg'''. == Advanced Customizations == === Add a proxy for APT during the live-build process === '''config/common''' -> LB_APT_HTTP_PROXY="`http://proxy:3128`" <=== Replace with your proxy server and port name === Remove the preseed.cfg === To remove the '''preseed.cfg''' to allow the install to ask all the guided questions, remove the '''preseed.cfg''' and re-build the '''IMG''', '''ISO''' or '''Netboot Tar Ball'''. '''config/includes.installer/preseed.cfg''' <=== Remove this file completely and re-build === Update the Custom Kernel used to build Live Images === You can either remove this custom kernel '''.deb''' file completely or replace with your custom built kernel to modify the kernel used for the Live Images. '''config/packages.chroot/linux-image-4.8.0-41-generic_4.8.0-41.44_ppc64el.deb''' <== If you build your own kernel, be sure to use '''generic''' in the name so the kernel is automatically picked up when the '''grub.cfg''' file is pre-built ('''LB_LINUX_FLAVOURS'''). === Update the Custom Kernel used to install a new OS with the Installer Images === You can either remove this custom kernel '''.deb''' file completely or replace with your custom built kernel to modify the kernel used for the Installer Images. If you remove the file completely, be sure to remove related lines from the '''config/includes.installer/preseed.cfg''' '''config/includes.installer/debs/linux-image-4.8.0-41-generic_4.8.0-41.44_ppc64el.deb''' <== If you build your own kernel, be sure to use '''generic''' in the name so the kernel is automatically picked up when the '''grub.cfg''' file is pre-built ('''LB_LINUX_FLAVOURS'''). '''config/includes.installer/preseed.cfg''' <=== You will need to update the name of the linux custom kernel name in the bottom of the '''preseed.cfg''' file in various places === Update the Root or Default User ID used for Live Images === {{{#!wiki warning '''IMPORTANT NOTE:''' Changing the root or default user ID and password have consequences due to the timing of when the scripts are run and when root privileges are instantiated. Recommendation is to NOT modify unless you test the scenarios well. }}} '''config/binary''' -> LB_BOOTAPPEND_LIVE="username=ubuntu" <=== You can change the default user id that is used during live-boot setup '''config/includes.chroot/lib/live/config/0035-user-setup''' <=== This sets the Live default user password which is defined on the LB_BOOTAPPEND_LIVE parameter (The file '''0035-user-setup''' is NOT included, you will need to copy a template like '''config/hooks/live/0500-root-password.hook.chroot''') '''config/hooks/live/0500-root-password.hook.chroot''' <=== This sets the Live root password === Update the Root or Default User ID used for Installer Images === {{{#!wiki warning '''IMPORTANT NOTE:''' Changing the root or default user ID and password have consequences due to the timing of when the scripts are run and when root privileges are instantiated. Recommendation is to NOT modify unless you test the scenarios well. }}} '''config/includes.installer/preseed.cfg''' <=== Update the passwd/username and passwd/user-password d-i parameters [[https://www.debian.org/releases/stable/amd64/apbs02.html.en|Debian Preseeding]] === Add Packages for the Live Images === Create or edit the file with packages you want installed: {{{ # cat ~/lb-setup/config/package-lists/live-list.chroot openssh-client openssh-server }}} === Add Packages for the Installer Images === Create or edit the file with packages you want installed, sample '''d-i''' below: {{{ # vi ~/lb-setup/config/includes.installer/preseed.cfg }}} '''d-i pkgsel/include string vim openssh-server build-essential''' [[https://www.debian.org/releases/stable/amd64/apbs02.html.en|Debian Preseeding]] === INITRD Customizations === ==== Embed SquashFS in INITRD ==== To alter the content of the initrd produced {{{ # vi config/chroot LB_CHROOT_PAYLOAD_PATH="/live" <--- Add this line, this is exploited in ~/live-build/scripts/build/binary_linux-image and the filesystem.squashfs is copied into the chroot, this works together with live-media-path option on kernel command line # cat config/includes.chroot/initrd.files /live/filesystem.squashfs <=== Customize the list of files to pull into the initrd, you have to make sure the source files get put in the chroot somehow # vi config/includes.chroot/usr/share/initramfs-tools/hooks/lb_initrd_hook <=== This is the hook that gets called during the update-initramfs, customize this hook if desired Be sure to use kernel command line parameter "live-media=initrd" to have live-boot pick up the embedded squashfs as the rootfs from the initrd produced above # vi config/includes.chroot/lib/live/boot/9990-misc-helpers.sh }}} ==== Trim contents of CHROOT or INITRD ==== To perform custom edits on what gets built in the CHROOT or what is ultimately output for the INITRD live-build produces an INITRD based on a custom CHROOT, this INITRD which is built from the CHROOT can also be customized post-CHROOT ===== CHROOT Alterations ===== These steps are exploiting the live-build post-chroot stage hook. {{{ # vi config/hooks/live/list.hook.chroot <=== Customize the logic if desired Two input files: # vi config/includes.chroot/keep.list <=== Customize as desired, these files/directories are really saved off and then pulled back in # vi config/includes.chroot/remove.list <=== Customize as desired, these files/directories will be removed after the keep list is processed }}} The "list" files can have conditional logic. {{{ # cat config/includes.chroot/keep.list <=== The "list" files are pre-processed, so the example below will only output a keep list if LIVE_IMAGE_TYPE=netboot #if ${LIVE_IMAGE_TYPE} netboot overlay.ko ipmi_powernv.ko opal-prd.ko ipmi_devintf.ko ipmi_msghandler.ko mtd.ko powernv_flash.ko ofpart.ko cmdlinepart.ko ibmpowernv.ko powernv-rng.ko #endif # cat config/includes.chroot/remove.list <=== The "list" files are pre-processed, so the example below will only output a remove list if LIVE_IMAGE_TYPE=netboot #if ${LIVE_IMAGE_TYPE} netboot /lib/modules/*/kernel /lib/firmware #endif }}} ===== INITRD Alterations Post-CHROOT Phase ===== These steps are exploiting the live-build post-binary stage hook. {{{#!wiki warning '''IMPORTANT NOTE:''' If you make changes in the CHROOT stage (described above), then the binary stage INITRD uses what you had built in the CHROOT stage. }}} {{{ # vi config/hooks/live/list.hook.binary <=== Customize the logic if desired Two input files: # vi config/includes.binary/keep.list <=== Customize as desired, these files/directories are really saved off and then pulled back in # vi config/includes.binary/remove.list <=== Customize as desired, these files/directories will be removed after the keep list is processed }}} === Custom Grub Menu for Kernels === Define which kernel flavours you want automatically created in the grub menu during the build. The first one in the list will be used as the default kernel in building the grub menu items. {{{ # vi config/chroot LB_MENU_FLAVOURS="mydebug mycustom" <=== Add the trailing tag, like from vmlinux-4.12.0-1-mydebug }}} If you want the normal linux kernel included while using the LB_MENU_FLAVOURS you must include that tag in the LB_MENU_FLAVOURS {{{ LB_MENU_FLAVOURS="mydebug mycustom generic" <=== Add the "generic" or whatever kernel tag you want automatically configured during the build }}} {{{#!wiki warning '''IMPORTANT NOTE:''' If the LB_MENU_FLAVOURS is used, then the normal LB_LINUX_FLAVOURS value is NOT used for the grub menu building. }}}