Tue Sep 26 12:31:24 2017 UTC

Post-construction and (optional) generation of the iso

Introduction

If you've done pass2 successfully, you then have all the packages needed for a basic system.

We can now finalise our NuTyX and adapt it to our needs. And then, we can produce an installable ISO if we want to.

It's time to decide what you still need, at this point of progress in your NuTyX:

  1. Does not have a kernel.
  2. Does not contain a boot program.
  3. Does not contain any other formatting tools than the one for ext3, ext4.
  4. Does not contain any tool for RAID management.
  5. Cannot connect to a dhcp server and get a dynamic address.
  6. Does not contain a text editor.

On the other hand your NuTyX will contain some services that you most probably will never use.

How to go on

It's now time for you to decide what you need. A boot system, a kernel, your favourite file system, logical volume or RAID and your IP address dynamic or static.

Before that we need to configure a minimum 'cards' package manager and download all the ports containing the building receipts of all the available NuTyX packages.

  1. We exit from the NuTyX.
    exit

    We check if the LFS variable is still set.

    echo $LFS

    It should return something.

    /mnt/lfs
  2. We can now re-enter the new NuTyX to finalise the job.
    chroot $LFS /usr/bin/env -i HOME=/root TERM="$TERM" PS1='\u: \w\$' \
    /bin/bash --login
    No error should be shown:
    root [ / ]# 
  3. We begin by adjusting the cards.conf file. We use from now on, only the receipt coming from the git project. You need to adapt the language if necessary.
    cat > /etc/cards.conf << "EOF"
    dir /usr/ports/gui-extra
    dir /usr/ports/gui
    dir /usr/ports/cli-extra
    dir /usr/ports/cli
    dir /usr/ports/base
    locale de
    base /usr/ports/base
    EOF
  4. We can now download all the available ports and compile the receipts we want (as long the collections are correctly configured in the cards.conf file above)
    ports -u
    ...

    We are now ready to finalise our NuTyX

The kernel compilation and optional port compilations

  1. Kernel compilation

  2. The kernel will be the only mandatory package, without it your NuTyX will never be able to start and run. You can choose different possibilities:

    1. Compilation of one of the available port kernels

      This choice is mandatory if you plan to produce an installable ISO. It's also the simplest choice:

      cd /usr/ports/base/kernel-lts
      pkgmk -d -i
    2. Compile your own kernel

      This choice means that the generation of an installable ISO will be not possible

      You can follow the article explaining how to compile your own kernel or you will find many tutorials about kernel compilation on the net.

  3. Remove unnecessary services (recommended)

  4. During the construction of your NuTyX, services ssh and rsync have been automatically installed. If you do not plan to activate a rsync server or do not plan to remote access your machine, it's strongly recommended that you deactivate those services. Even if you don't know what they are, do:

    cards remove openssh.service
    cards remove rsync.service

    Add grub, the boot process tool (optional)

    The grub package is only needed if you decide to produce an installable ISO or if you don't have any boot procedure yet on your machine (most probably you already have one):

    cards depcreate grub

    Once grub is installed, you will be able to setup your boot process via the command line or later via the generated ISO.

  5. Adding other file system supports (optional)

    The following file systems are available:

    cards depcreate btrfs-progs
    cards depcreate xfsprogs
    cards depcreate reiserfsprogs
    cards depcreate jfsutils

    Choose your favourite one or leave it as ext3 , ext4.

  6. Adding the logical partition tools and RAID (optional)

  7. If you are using RAID system:

    cards depcreate mdadm
  8. Adding a dhcp client enables you to obtain a dynamic IP address (optional)

  9. If you don't want to use a fixed ip address, you will need a dhcp client tool:

    cards depcreate dhcpcd
  10. Adding a text editor (optional)

  11. The installer in the generated ISO uses the command 'vi' to edit your grub file, you can choose between:

    cards depcreate e3

    and

    cards depcreate vim
  12. Adding the NFS support (optional)

  13. If you don't use or don't know about NFS, you can ignore this option:

    cards depcreate nfs-utils

    Like the sshd and rsync services, if you don't need a NFS server. do:

    cards remove nfs-utils.service

Option1: Produce an installable ISO

  1. We add all the necessary files for a working ISO.
    cp -av /root/development/iso /ISO
    '/root/development/iso' -> '/ISO'
    '/root/development/iso/isolinux' -> '/ISO/isolinux'
    '/root/development/iso/isolinux/boot.cat' -> '/ISO/isolinux/boot.cat'
    '/root/development/iso/isolinux/boot.msg' -> '/ISO/isolinux/boot.msg'
    '/root/development/iso/isolinux/isolinux.bin' -> '/ISO/isolinux/isolinux.bin'
    '/root/development/iso/isolinux/isolinux.cfg' -> '/ISO/isolinux/isolinux.cfg'
    cp -v /boot/kernel-* /ISO/isolinux/kernel
    '/boot/kernel-3.19.3' -> '/ISO/isolinux/kernel'
    cp -v /boot/initrd-* /ISO/isolinux/initrd
    '/boot/initrd-3.19.3' -> '/ISO/isolinux/initrd'
    [Note] Consult the options at the bottom of the page before going further if you want to customize your ISO by adding some packages or if you want to get rid of the binaries archives and build logs to reduce the size of your ISO.
  2. We produce the squashfs files used by the ISO and erase the existing one if necessary as the mksquashfs command is not able to overwrite the existing file.
    mkdir -p /ISO/isolinux/boot/
    cd /
    for dir in opt bin etc lib root run sbin usr var home
    do
      [ -f ISO/isolinux/boot/$dir.squashfs ] && rm ISO/isolinux/boot/$dir.squashfs
      mksquashfs $dir ISO/isolinux/boot/$dir.squashfs
    done
  3. We can now exit NuTyX and produce the ISO.
    exit
  4. We can finally generate our ISO using the version with today’s date.
    [Important][Important][Important] Before you start the next command, make sure the LFS variable is still set and the commands mkisofs and isohybrid are available on your host linux distribution. They are belonging to cdrkit and syslinux packages.
    sh $LFS/root/development/scripts/mkiso
    Warning: creating file system that does not conform to ISO-9660.
    I: -input-charset not specified, using utf-8 (detected in locale settings)
    Size of boot image is 4 sectors -> No emulation
      3.82% done, estimate finish Fri Jan  9 21:46:48 2015
      7.63% done, estimate finish Fri Jan  9 21:46:48 2015
     11.44% done, estimate finish Fri Jan  9 21:46:48 2015
     15.25% done, estimate finish Fri Jan  9 21:46:48 2015
     19.06% done, estimate finish Fri Jan  9 21:46:48 2015
     22.88% done, estimate finish Fri Jan  9 21:46:48 2015
     26.68% done, estimate finish Fri Jan  9 21:46:48 2015
     30.50% done, estimate finish Fri Jan  9 21:46:48 2015
     34.31% done, estimate finish Fri Jan  9 21:46:48 2015
     38.12% done, estimate finish Fri Jan  9 21:46:48 2015
     41.94% done, estimate finish Fri Jan  9 21:46:48 2015
     45.74% done, estimate finish Fri Jan  9 21:46:48 2015
     49.56% done, estimate finish Fri Jan  9 21:46:48 2015
     53.37% done, estimate finish Fri Jan  9 21:46:48 2015
     57.19% done, estimate finish Fri Jan  9 21:46:48 2015
     60.99% done, estimate finish Fri Jan  9 21:46:48 2015
     64.81% done, estimate finish Fri Jan  9 21:46:48 2015
     68.62% done, estimate finish Fri Jan  9 21:46:48 2015
     72.43% done, estimate finish Fri Jan  9 21:46:48 2015
     76.24% done, estimate finish Fri Jan  9 21:46:48 2015
     80.06% done, estimate finish Fri Jan  9 21:46:48 2015
     83.86% done, estimate finish Fri Jan  9 21:46:48 2015
     87.68% done, estimate finish Fri Jan  9 21:46:48 2015
     91.49% done, estimate finish Fri Jan  9 21:46:48 2015
     95.31% done, estimate finish Fri Jan  9 21:46:48 2015
     99.11% done, estimate finish Fri Jan  9 21:46:48 2015
    Total translation table size: 2048
    Total rockridge attributes bytes: 1751
    Total directory bytes: 4096
    Path table size(bytes): 38
    Max brk space used 28000
    165140 extents written (322 MB)

    You now have an ISO located in the $LFS folder.

    ls $LFS/
    bin   etc   lib    NuTyX_x86_64-20161001.iso     root  sources  base  usr
    boot  home  lib64  NuTyX_x86_64-20161001.md5sum  run   srv      tmp     var
    dev   ISO   mnt    proc sbin  sys      tools
  5. You just need to transfer it to your USB key and test it.
    dd if=$LFS/NuTyX_x86_64-20161001.iso of=/dev/sdb
    526336+0 records in
    526336+0 records out
    269484032 bytes (269 MB) copied, 66.4757 s, 4.1 MB/s

Congratulations, you now have a new base system NuTyX in your hands ready to be installed on all your machines.

Options2: Reduce the size of your final ISO.

  1. If you want to reduce the size of the final ISO, you can remove the binaries archives and the logs, they won't be needed. If you want to keep the archives, give the following command:
    rsync -a /root/development/base/ /base/

    no error should be printout.

    We can now delete the binaries from the git.

    find /root/ -name "*.cards.*" -exec rm -v {} \;

    no error should be printout.

    We erase the logs.

    mv /root/logs /logs

    If needed, binaries and logs are stored at the root directory of the new produced NuTyX.

  2. The compiled kernel uses a lot of space. If you want to reduce the size of your ISO, you can delete the documentation and the sources of the kernel:
    pkgrm kernel.doc
    pkgrm kernel.devel