Fri Mar 10 14:56:34 2017 UTC

Construction of the NuTyX (pass 2)

It's time to build your NuTyX. One single condition: Have been able to finish with success the construction of the CHROOT (pass 1).

[Important] The author is not responsable for the lost of your datas or others dammage which could occur during a wrong manipulation. This article is target for aware Linux peoples.

All the operations will be done in the root account. It's then ABSOLUTLY necessary to be very carefull otherwise you could broker your actual distribution.

The LFS variable in our exemple is pointing to /mnt/lfs. Up to you to adjust to your need if necessary.

[Important] Please note that the pass2 can be much more an "aventure" as it can always have problems when compiling a package the first time. 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 to take, the article is split in two parts. The first shows every step to do and the second gives an explaignation about each step.

They are 22 actions. SO again:

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

The actions

  1. We go out of the 'lfs' account
  2. We check the LFS variable
    echo $LFS
    MUST return
    or the value define in the begining of pass 1
    If the result is correct:
    chown -R root:root $LFS
  3. We create folders and links to put the recepts in place.
    install -dv -m0750  $LFS/root
    ln -sv development/scripts $LFS/root/bin
  4. We move the receipts to the right folder and go in 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) 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 uggly but we can ignored 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
    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's says, the bash packages needs to be installed manually. So let's do it from outside the NuTyX. We got out first:
  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
    (base) bash 4.4-1
    (base) bash.da 4.4-1
    (base) 4.4-1
    (base) bash.devel 4.4-1
    (base) bash.doc 4.4-1
  19. We enter again 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 stills 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
    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 '' succeeded.
    =======> compress

Explanation to each step

  1. [Important] Its very important that everything is done via the root account.
  2. The LFS variable is used all along the article, its important that it's correctly set and that it point always to the same folder. One way to solve this problem is to define ones 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 receiptes in place and the log folder as well. We create also a link so that the script pass is found.
  5. We will now compile the first package which is nutyx. For this we go in the folder of the recept.
  6. This package doent contains any code so it's just create all the folders for the NuTyX.
  7. We install the first package nutyx into the NuTyX and...
  8. We check if it's corretly installed.
  9. We add all the defaults 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 to compile without problems the rest of the NuTyX.
  11. In case of a package need to download something (for exemple the kernel) we copy the resolv.conf file from the host to be able to resolve the adress.
  12. One last check before we enter the CHROOT.
  13. We can now enter the CHROOT means the future NuTyX. As it has still no programms at the right place, we get all kind of uggly messages. The PATH must be define 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 in 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 go out of the chroot.
  18. We go in the right folder and start a loop to install all the bash packages.
  19. Again we check if it's corretly installed by.
  20. We can now return into the CHROOT means the future NuTyX. This time, they should be NO weard messages printout.
  21. The PATH variable is redefine
  22. We go in the right folder and relaunch the compilation of the remains packages in the right order.
  23. One 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's stops. 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 serverall times. If you went out of the chroot, you MUST make shure to type the 12 et 13 commands again. If you did stop the PC, make shure to type the command 9 plus commands 12 and 13.