Tue Sep 26 12:31:24 2017 UTC

Construction of the NuTyX (pass 2)

It's time to build your NuTyX. On one single condition: Have you been able to finish successfully the construction of the CHROOT (pass 1).

[Important] The author is not responsible for the loss of your data or other damage which could occur during a wrong manipulation. This article is targeted for people aware of Linux.

All operations will be done in the root account. It's then ABSOLUTELY necessary to be very careful otherwise you could break your actual distribution.

The LFS variable in our example is pointing to /mnt/lfs. It is up to you to adjust for your needs if necessary.

[Important] Please note that the pass2 can be much more an "adventure" as it can have problems when compiling a package the first time. It is up to you to give us a feedback with all the details of the error. You can use the forums or the irc channel for that.

To avoid any confusion and avoid dispersion in the actions taken, the article is split into two parts. The first shows every step to take and the second gives an explanation of each step.

They are 22 actions. SO again:

[Important] All the actions should be done in the root account.

The actions

  1. We go out of the 'lfs' account
    exit
  2. We check the LFS variable
    echo $LFS
    MUST return
    /mnt/lfs
    or the value defined in the beginning of pass 1
    [Important][Important][Important]BEFORE YOU GO FURTHER MAKE SURE THE LFS VARIABLE IS PROPERLY SET OTHERWISE YOU WILL BREAK YOUR DISTRIBUTION
    If the result is correct:
    chown -R root:root $LFS
  3. We have created folders and links to put the receipts in place.
    install -dv -m0750  $LFS/root
    ln -sv development/scripts $LFS/root/bin
  4. We move the receipts to the right folder and enter this folder.
    mv /home/lfs/development $LFS/root/
    cd $LFS/root/development/base/nutyx
  5. We compile the first package of NuTyX.
    /tools/bin/pkgmk -cf ../../../bin/pkgmk.conf.passes
  6. We install the nutyx package in the NuTyX.
    /tools/bin/pkgadd -r $LFS nutyx1*
    /tools/bin/pkgadd -r $LFS nutyx.man1*
  7. We check if it's present.
    /tools/bin/pkginfo -r $LFS -i
    should return
    (base) nutyx 8.2...
    (base) nutyx.man 8.2...
  8. We install all the configuration files in our new NuTyX.
    VERSION="development" install-nutyx -ic
  9. We mount all different folders.
    mount -v -B /dev $LFS/dev
    mount -vt devpts devpts $LFS/dev/pts
    mount -vt proc proc $LFS/proc
    mount -vt sysfs sysfs $LFS/sys
    if [ -h /dev/shm ]; then rm -f $LFS/dev/shm;mkdir $LFS/dev/shm;fi
    mount -vt tmpfs shm $LFS/dev/shm
    chmod 1777 /dev/shm
  10. We copy resolv.conf from the host distribution.
    cp -v /etc/resolv.conf $LFS/etc
  11. We check that all the folders are correctly mounted via the command:
    mount|grep $LFS
    it should return something like:
    /dev/sda2 on /mnt/lfs type ext4 (rw)
    /devtmpfs on /mnt/lfs/dev type devtmpfs (rw,nosuid,relatime,size=16300988k,nr_inodes=4075247,mode=755)
    devpts on /mnt/lfs/dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)
    proc on /mnt/lfs/proc type proc (rw,relatime)
    sysfs on /mnt/lfs/sys type sysfs (rw,relatime)
    tmpfs on /mnt/lfs/run type tmpfs (rw,relatime)
  12. We enter now in the NuTyX.
    chroot "$LFS" /usr/bin/env -i HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
    /bin/bash --login +h
    The result will be a bit ugly but we can ignore it:
    bash: id: command not found
    bash: id: command not found
    bash: date: command not found
    bash: uname: command not found
    bash: uname: command not found
    bash: whoami: command not found
    bash: uname: command not found
    bash: tput: command not found
    ...
  13. We redefine the PATH variable.
    export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin:/root/bin
  14. We launch the compilation of the packages.
    cd /root/development/base
    pass
    return
    tar -p -o -C /tmp/work/src -xf /sources/linux-3.19.3.tar.xz
    ...
  15. Wait for the following message to appear.
    need to install bash manually
  16. As it says, the bash packages need to be installed manually. So let's do it from outside the NuTyX. We exit first:
    exit
  17. Now we go to the right place and install the bash packages:
    cd $LFS/root/development/base/bash
    for PACK in *.xz; do /tools/bin/pkgadd -r $LFS $PACK;done
  18. We check if it has been added:
    /tools/bin/pkginfo -r $LFS -i|grep bash
    return
    (base) bash 4.4-1
    (base) bash.da 4.4-1
    (base) bash.de 4.4-1
    (base) bash.devel 4.4-1
    (base) bash.doc 4.4-1
    ...
  19. We go back into NuTyX and we finish the job:
    chroot "$LFS" /usr/bin/env -i HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
    /bin/bash --login +h
    Few errors still show up:
    bash: id: command not found
    bash: id: command not found
    bash: date: command not found
    bash: uname: command not found
    bash: uname: command not found
    bash: whoami: command not found
    bash: uname: command not found
    bash: wc: command not found
    /
  20. We redefine AGAIN the PATH variable:
    export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin:/root/bin
  21. We launch AGAIN the compilation of the packages:
    cd /root/development/base
    pass
    tar -p -o -C /tmp/work/src -xf /sources/bc-1.06.95.tar.bz2
    ....
  22. The compilation ends with ca-certificates package:
    ADD: ca-certificates-20150725, 1282 files: 100%
    =======> Installing 'ca-certificates1418739487x86_64.cards.tar' succeeded.
    =======> compress ca-certificates1418739487x86_64.cards.tar

Explanation to each step

  1. [Important] It’s very important that everything is done via the root account.
  2. The LFS variable is used all along the article, it’s important that it's correctly set and that it points always to the same folder. One way to solve this problem is to define one for all in the .bash_profile file and to source it:
    echo "export LFS=/mnt/lfs" >> /root/.bash_profile
    source  ~/.bash_profile
  3. Checking the LFS variable. If OK we change the owner and group of the contents of $LFS.
  4. We create the folder to put the receipts in place and the log folder as well. We also create a link so that the script pass is found.
  5. We will now compile the first package which is nutyx. For this we go to the folder of the receipt.
  6. This package doesn’t contain any code as it just created all the folders for the NuTyX.
  7. We install the first package nutyx into the NuTyX and...
  8. We check if it's correctly installed.
  9. We add all the default configuration files, those are included in the instal-nutyx script.
  10. It's time to mount all the necessary folders to be able to enter and compile the rest of the NuTyX without problems.
  11. In case a package needs to download something (for example the kernel) we copy the resolv.conf file from the host to be able to resolve the address.
  12. One last check before we enter the CHROOT.
  13. We can now enter the CHROOT means the future NuTyX. As it still has no programs in the right places, we get all kinds of ugly messages. The PATH must be defined again so that all the binaries are found in the right order.
  14. The PATH variable is not set properly, so we need to redefine it.
  15. We go to the right folder. We launch the compilation of the packages in the right order.
  16. The bash interpreter must be installed outside the chroot, so we wait until the message comes.
  17. We exit the chroot.
  18. We go to the right folder and start a loop to install all the bash packages.
  19. Again we check if it's correctly installed.
  20. We can now return to the CHROOT means the future NuTyX. This time, there should be NO weird message printouts.
  21. The PATH variable is redefined
  22. We go to the right folder and relaunch the compilation of the remains packages in the right order.
  23. Once the ca-certificates package is compiled and installed, the construction of your base NuTyX is done.

You need to know:

  1. [Note] If you have an error when compiling a package, it's not a big deal, when you restart the command pass the script will restart where it stopped. It is up to you to inform us what kind of error it is. You can use the irc channel or the forum.
  2. [Note] You can build the pass 2 in several ways. If you went out of the chroot, you MUST make sure to type the 12 and 13 commands again. If you stopped the PC, make sure to type the command 9 plus commands 12 and 13.