Monday, December 28, 2020

Maximizing Ubuntu Virtual Host Screen in Virtual Box

Hi,

In this post we are going to see how to maximize the virtual host screen in virtual box.

After we install the virtual host, the host screen would appear something like the one given in the picture below..


In order to maximize the host screen perform the following...

Installing Virtual Box Guest Additons

Open up a terminal and execute the following command...
$ sudo apt install build-essential dkms linux-headers-$(uname -r)

This command would prompt you to provide the password, provide the one associated with the user account.

The below pictures would give you the snapshots of the execution.





Close / Exit the terminal.

Executing Insert Guest Additions CD Image

From the menu bar, select the Device Menu Option and click on "Insert Guest Additions CD Image" menu item...

For your convenience, I have given the image below.


A dialog would appear on the screen and click the "Run" button.


Key in the password associated with the account.


The execution is now successfully completed and evidenced below... 


Quit the terminal by pressing the enter key.

Turning Off the Operating System

You should now turn off the virtual host...



Setting Shared Clipboard and Drag'n'Drop

Select the setting tab for the option General -> Advanced and set the value of Shared Clipboard and Drag'n'Drop to "Bidirectional"

You can refer the image given below...



Well that is it, if you start the virtual host now and see, you should have fully maximized window of the host as depicted in the picture.


Hope you had great time reading.... thanks.

Sunday, December 27, 2020

Chapter 33 : Compile and Install GCC Pass-2 - Cross Compiling Temporary Tools

Hi,

In this chapter we are going to compile and install GCC package again, this is the second pass of the package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 10.2.0
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Remove the directory gcc-10.2.0 if it's still exist in sources directory.
$ rm -rf gcc-10.2.0

Unpack the package tarball and change directory.
$ tar -xvf gcc-10.2.0.tar.xz
$ cd gcc-10.2.0

Unpack the packages and move it to the gcc-10.2.0 directory.
$ tar -xf ../mpfr-4.1.0.tar.xz
$ mv -v mpfr-4.1.0 mpfr
$ tar -xf ../gmp-6.2.0.tar.xz
$ mv -v gmp-6.2.0 gmp
$ tar -xf ../mpc-1.1.0.tar.gz
$ mv -v mpc-1.1.0 mpc

If building on x86_64, change the default directory name for 64-bit libraries to “lib”
$ case $(uname -m) in
  x86_64)
    sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64
  ;;
esac

Create the build directory and move into it.
$ mkdir -v build
$ cd build

Create a symlink that allows libgcc to be built with posix threads support
$ mkdir -pv $LFS_TGT/libgcc
$ ln -s ../../../libgcc/gthr-posix.h $LFS_TGT/libgcc/gthr-default.h

Preparing Gcc package for compilation.
../configure                                       \
    --build=$(../config.guess)                     \
    --host=$LFS_TGT                                \
    --prefix=/usr                                  \
    CC_FOR_TARGET=$LFS_TGT-gcc                     \
    --with-build-sysroot=$LFS                      \
    --enable-initfini-array                        \
    --disable-nls                                  \
    --disable-multilib                             \
    --disable-decimal-float                        \
    --disable-libatomic                            \
    --disable-libgomp                              \
    --disable-libquadmath                          \
    --disable-libssp                               \
    --disable-libvtv                               \
    --disable-libstdcxx                            \
    --enable-languages=c,c++

Compiling the package
$ make -j4

Installing the package
$ make DESTDIR=$LFS install

Creating a utility symlink.
$ ln -sv gcc $LFS/usr/bin/cc





Chapter 32 : Compile and Install Binutils Pass-2 : Cross Compiling Temporary Tools

 Hi,

In this chapter we are going to compile and install Binutils again, this is the second pass of the package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 2.35
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Remove the directory binutils-2.35 in case if it's still exist in sources directory.
$ rm -rf binutils-2.35

Unpack the package tarball and change directory.
$ tar -xvf binutils-2.35.tar.xz
$ cd binutils-2.35

Creating the build directory and move into it.
$ mkdir build
$ cd build

Preparing the package for compilation.
$ ../configure                   \
    --prefix=/usr              \
    --build=$(../config.guess) \
    --host=$LFS_TGT            \
    --disable-nls              \
    --enable-shared            \
    --disable-werror           \
    --enable-64-bit-bfd

Compiling the package.
$ make -j4

Installing the package.
$ make DESTDIR=$LFS install





Chapter 31 : Compile and Install Xz - Cross Compiling Temporary Tools

Hi,

In this chapter we are going to compile and install Xz package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 2.35
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Unpack the package tarball and change directory.
$ tar -xvf xz-5.2.5.tar.xz
$ cd xz-5.2.5

Preparing the package for compilation.
$ ./configure --prefix=/usr                     \
            --host=$LFS_TGT                   \
            --build=$(build-aux/config.guess) \
            --disable-static                  \
            --docdir=/usr/share/doc/xz-5.2.5

Compiling the package.
$ make -j4

Installing the package.
$ make DESTDIR=$LFS install

Make sure that all essential files are in the correct directory
mv -v $LFS/usr/bin/{lzma,unlzma,lzcat,xz,unxz,xzcat}  $LFS/bin
mv -v $LFS/usr/lib/liblzma.so.*                       $LFS/lib
ln -svf ../../lib/$(readlink $LFS/usr/lib/liblzma.so) $LFS/usr/lib/liblzma.so




Chapter 30 : Compile and Install Tar - Cross Compiling Temporary Tools

Hi,

In this chapter we are going to compile and install Tar Package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 1.32
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Unpack the package tarball and change directory.
$ tar -xvf tar-1.32.tar.xz
$ cd tar-1.32

Prepare the package for compilation.
$ ./configure --prefix=/usr                     \
            --host=$LFS_TGT                   \
            --build=$(build-aux/config.guess) \
            --bindir=/bin

Compiling the package.
$ make -j4

Installing the package.
$ make DESTDIR=$LFS install




Chapter 29 : Compile and Install Sed - Cross Compiling Temporary Tools

Hi,

In this chapter we are going to compile and install Sed Package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 4.8
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Unpack the Sed Package and change directory.
$ tar -xvf sed-4.8.tar.xz
$ cd sec-4.8

Prepare the package for compilation.
$ ./configure --prefix=/usr   \
            --host=$LFS_TGT \
            --bindir=/bin

Compiling the package.
$ make -j4

Installing the package.
$ make DESTDIR=$LFS install




Chapter 28 : Compile and Install Patch - Cross Compiling Temporary Tools

Hi,

In this chapter we are going to compile and install Patch Package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 2.7.6
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Unpack the package tarball and change directory
$ tar -xvf patch-2.7.6.tar.xz
$ cd patch-2.7.6

Prepare the package for compilation
$ ./configure --prefix=/usr   \
            --host=$LFS_TGT \
            --build=$(build-aux/config.guess)

Compiling the package.
$ make -j4

Installing the package.
$ make DESTDIR=$LFS install



Chapter 27 : Compile and Install Make - Cross Compiling Temporary Tools

Hi,

In this chapter we are going to compile and install make package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 4.3
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Unpack the package tarball and change directory.
$ tar -xvf make-4.3.tar.gz
$ cd make-4.3

Prepare the package for the compilation.
$ ./configure --prefix=/usr   \
            --without-guile \
            --host=$LFS_TGT \
            --build=$(build-aux/config.guess)

Compiling the package.
$ make -j4

Installing the package.
$ make DESTDIR=$LFS install




Chapter 26 : Compile and Install Gzip - Cross Compiling Temporary Tools

Hi,

In this post we are going to see how to compile and install Gzip Package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 1.10
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Unpack the package tarball and change directory.
$ tar -xvf gzip-1.10.tar.xz
$ cd gzip-1.10

Preparing the package for compilation.
$ ./configure --prefix=/usr --host=$LFS_TGT

Compiling the package.
$ make -j4

Installing the package.
$ make DESTDIR=$LFS install

Move the executable to its final expected location.
$ mv -v $LFS/usr/bin/gzip $LFS/bin




Chapter 25 : Compile and Install Grep - Cross Compiling Temporary Tools

Hi,

In this chapter we are going to discuss on Compiling and Installing Grep Package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 3.4
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Unpack the package tarball and change directory.
$ tar -xvf grep-3.4.tar.xz
$ cd grep-3.4

Preparing the package for compilation.
./configure --prefix=/usr   \
            --host=$LFS_TGT \
            --bindir=/bin

Compiling the package
$ make -j4

Installing the package
$ make DESTDIR=$LFS install




Chapter 24 : Compile and Install Gawk - Cross Compiling Temporary Tools

Hi,

In this chapter we are going to compile and install Gawk package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 5.1.0
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Unpack the package tarball and change directory.
$ tar -xvf gawk-5.1.0.tar.xz
$ cd gawk-5.1.0

Ensure some unneeded files are not installed.
sed -i 's/extras//' Makefile.in

Preparing the package for compilation.
$ ./configure --prefix=/usr   \
            --host=$LFS_TGT \
            --build=$(./config.guess)

Compiling the package.
$ make -j4

Installing the package.
$ make DESTDIR=$LFS install




Chapter 23 : Compile and Install Findutils - Cross Compiling Temporary Tools

Hi,

In this chapter we are going to compile and install Findutils package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 4.7.0
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Unpack the package and change directory.
$ tar -xvf findutils-4.7.0.tar.xz
$ cd findutils-4.7.0

Preparing the package for compilation.
$ ./configure --prefix=/usr   \
            --host=$LFS_TGT \
            --build=$(build-aux/config.guess)

Compiling the package.
$ make -j4

Installing the package.
$ make DESTDIR=$LFS install

Move the executable to its final expected location
$ mv -v $LFS/usr/bin/find $LFS/bin
$ sed -i 's|find:=${BINDIR}|find:=/bin|' $LFS/usr/bin/updatedb




Chapter 22 : Compile and Install File - Cross Compiling Temporary Tools

Hi,

In this chapter we are going to compile and install file package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 5.39
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Unpack the package and change directory.
$ tar -xvf file-5.39.tar.gz
$ cd file-5.39

Preparing the package for compilation
$ ./configure --prefix=/usr --host=$LFS_TGT

Compiling the package
$ make -j4

Installing the package
$ make DESTDIR=$LFS install

You can have a detailed explanation about this package compiling and installation at the below mentioned location.




Chapter 21 : Compile and Install Diffutils - Cross Compiling Temporary Tools

Hi,

In this post we are going to see compiling and installing diffutils package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 3.7
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Unpacking the tarball and change directory
$ tar -xvf diffutils-3.7.tar.xz
$ cd diffutils-3.7

Preparing the package for compiling
$ ./configure --prefix=/usr --host=$LFS_TGT

Compiling the package
$ make -j4

Installing the package
$ make DESTDIR=$LFS install




Chapter 20 : Compile and Install CoreUtils - Cross Compiling Temporary Tools

Hi,
In this chapter we are going to compile and install coreutils package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 8.32
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Unpacking the coreutils package
$ tar -xvf coreutils-8.32.tar.xz

Change directory
$ cd coreutils-8.32

Preparing for compilation.
$ ./configure --prefix=/usr                     \
            --host=$LFS_TGT                   \
            --build=$(build-aux/config.guess) \
            --enable-install-program=hostname \
            --enable-no-install-program=kill,uptime

Compiling Coreutils.
$ make -j4

Installing Coreutils.
$ make DESTDIR=$LFS install

Move programs to their final expected locations
$ mv -v $LFS/usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} $LFS/bin
$ mv -v $LFS/usr/bin/{false,ln,ls,mkdir,mknod,mv,pwd,rm}        $LFS/bin
$ mv -v $LFS/usr/bin/{rmdir,stty,sync,true,uname}               $LFS/bin
$ mv -v $LFS/usr/bin/{head,nice,sleep,touch}                    $LFS/bin
$ mv -v $LFS/usr/bin/chroot                                     $LFS/usr/sbin
$ mkdir -pv $LFS/usr/share/man/man8
$ mv -v $LFS/usr/share/man/man1/chroot.1                        $LFS/usr/share/man/man8/chroot.8
$ sed -i 's/"1"/"8"/'                                           $LFS/usr/share/man/man8/chroot.8


You can refer the following link for detailed explanation.



Chapter 19 : Compile and Install Bash - Cross Compiling Temporary Tools

Hi,

In this chapter we are going to discuss on compiling and installing BASH package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 5.0
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Before we unpack the package to compile and install, let us create a directory called bin and let the lfs user owns it.

$ cd /mnt/lfs
$ sudo mkdir bin
$ sudo chown lfs bin

Now change directory to sources and unpack the bash package.
$ tar -xvf bash-5.0-tar.gz

Changing directory to bin-5.0
$ cd bin-5.0

Prepare the bash for compilation.
$ ./configure --prefix=/usr                   \
            --build=$(support/config.guess) \
            --host=$LFS_TGT                 \
            --without-bash-malloc

Compile the package.
$ make -j4

Install the package.
$ make DESTDIR=$LFS install

Move the executable to bin directory created
$ mv $LFS/usr/bin/bash $LFS/bin/bash

Make a soft link to the executable for those programs which uses "sh"
$ ln -sv bash $LFS/bin/sh

You can also refer the explanation on compiling and installing bash at the below mentioned location.




Chapter 18 : Compile and Install Ncurses - Cross Compiling Temporary Tools

Hi,
In this chapter we are going to discuss about install Ncurses package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 6.2
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Unpack the package tar ball and change directory to ncurses-6.2
$ tar -xvf ncurses-6.2.tar.gz
$ cd ncurses-6.2

Ensure that gawk is found first during configuration.
$ sed -i s/mawk// configure

Run the following commands to build the “tic” program on the build host
$ mkdir build
$ pushd build
  ./configure
  make -C include
  make -C progs tic
  popd
$ cd build

Prepare Ncurses for Compilation.
../configure --prefix=/usr                \
            --host=$LFS_TGT              \
            --build=$(./config.guess)    \
            --mandir=/usr/share/man      \
            --with-manpage-format=normal \
            --with-shared                \
            --without-debug              \
            --without-ada                \
            --without-normal             \
            --enable-widec

Compiling the Ncurses.
$ make -j4

Installing the Ncursed.
make DESTDIR=$LFS TIC_PATH=$(pwd)/build/progs/tic install

The libncurses.so library is needed by a few packages we will build soon hence we create this small linker script
$ echo "INPUT(-lncursesw)" > $LFS/usr/lib/libncurses.so

Move the shared libraries to the /lib directory
$ mv -v $LFS/usr/lib/libncursesw.so.6* $LFS/lib

Change directory to the Ncurses home
$ cd ..

Because the libraries have been moved, one symlink points to a non-existent file. Recreate it
$ ln -sfv ../../lib/$(readlink $LFS/usr/lib/libncursesw.so) $LFS/usr/lib/libncursesw.so

If you would like to have a detailed explanation on what we discussed so far, you can refer the link below




Chapter 17 : Compiling and Installing M4 - Cross Compiling Temporary Tools

Hi,

In this chapter we are going to compile and install M4-1.4.18 package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 1.4.18
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Unpack the M4 tar ball package and change directory to it.
$ tar -xvf m4-1.4.18.tar.xz
$ cd m4-1.4.18

Make some fixes required by glibc-2.28 and later.
$ sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c
$ echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h

Preparing M4 for compilation
$ ./configure --prefix=/usr   \
            --host=$LFS_TGT \
            --build=$(build-aux/config.guess)

Compiling M4
make -j4

Installing M4
make DESTDIR=$LFS install




Chapter 16 : Compile and Install Libstdc++ - Compiling a Cross-Toolchain

Hi,
In this chapter we are going to discuss on compiling and installing Libstdc++, this is part of the gcc-10.2.0 package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 10.2.0
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)
Remove the folder gcc-10.2.0 in case if you still have in the sources directory and extract it again.
$ tar -xvf gcc-10.2.0.tar.xz

Change directory to gcc-10.2.0
$ cd gcc-10.2.0

As per practice, create and change to build directory.
$ mkdir -v build
$ cd build

Preparing Libstdc++ for compiling
$ ../libstdc++-v3/configure           \
    --host=$LFS_TGT                 \
    --build=$(../config.guess)      \
    --prefix=/usr                   \
    --disable-multilib              \
    --disable-nls                   \
    --disable-libstdcxx-pch         \
    --with-gxx-include-dir=/tools/$LFS_TGT/include/c++/10.2.0

Compiling Libstdc++
$ make -j4

Installing Libstdc++
$ make DESTDIR=$LFS install




Chapter 15 : Compile and Install Glibc - Compiling a Cross-Toolchain

Hi,

In this chapter, we are going to compile Glibc package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 2.32
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Before we compile the package, there are certain directories to be created at the location /mnt/lfs.

Use the following command to create the required directories, along with creating the directories we have change the ownership of the directories created.

$ sudo mkdir lib
$ sudo chown lfs lib

$ sudo mkdir etc
$ sudo chown lfs etc

$ sudo mkdir var
$ sudo chown lfs var

$ sudo mkdir lib64
$ sudo chown lfs lib64

Now extract the glibc package using the following command.

$ sudo cd $LFS/sources
$ tar -xvf glibc-2.32.tar.xz

After successful extraction, change directory to glibc-2.32
$ cd glibc-2.32

Create a symbolic link for LSB compliance. Additionally, for x86_64, create a compatibility symbolic link required for proper operation of the dynamic library loader

 $ case $(uname -m) in
    i?86)   ln -sfv ld-linux.so.2 $LFS/lib/ld-lsb.so.3
    ;;
    x86_64) ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64
            ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3
    ;;
esac

Command to apply the patch to make some of the glibc programs use the non-FHS compliant /var/db directory to store their runtime data

$ patch -Np1 -i ../glibc-2.32-fhs-1.patch

Creating the build directory.

$ mkdir -v build
$ cd build

Preparing glibc for compilation...

$ ../configure                             \
      --prefix=/usr                      \
      --host=$LFS_TGT                    \
      --build=$(../scripts/config.guess) \
      --enable-kernel=3.2                \
      --with-headers=$LFS/usr/include    \
      libc_cv_slibdir=/lib

Compiling the package...

$ make -j4

Installing the package...

$ make DESTDIR=$LFS install

If you would like to have a sanity check on the glibc package, you can make use of the following instructions...

echo 'int main(){}' > dummy.c
$LFS_TGT-gcc dummy.c
readelf -l a.out | grep '/ld-linux'

The execution of the above commands should result like the one given below...

[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]

Now that our cross-toolchain is complete, finalize the installation of the limits.h header. For doing so, run a utility provided by the GCC developers

$ $LFS/tools/libexec/gcc/$LFS_TGT/10.2.0/install-tools/mkheaders




Saturday, December 26, 2020

Chapter 14 : Installation of Linux API Headers

Hi,

In this chapter we are going to compile linux API headers.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 5.8.3
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Before we proceed further, let us make "lfs" user a sudo user.

Please check out one of my posts to make a user a sudo user using the following link given below..

Creating a directory "/usr" in /mnt/lfs

$ cd $LFS
$ sudo mkdir usr

The above command would prompt to key in the password, provide the one associated with the user account.

Let the user "lfs" own the directory /mtn/lfs/usr

$sudo chown lfs /mnt/lfs/usr

Now login back as "lfs" user and perform the following actions...

$ cd $LFS/sources

Unpack the package tar ball linux-5.8.3.tar.xz

At the time of writing, this package was at version 5.8.3, please check the version when you perform the following command.

$ tar -xvf linux-5.8.3.tar.xz

Change directory to linux-5.8.3

$ cd linux-5.8.3

The extracted package may or may not contain some stale files, we got be sure that there are no such files while compiling this package... to make sure the extracted folder do not contain any stale files, use the following command.

$ make mrproper

Should not be having any problem in executing above command.

Now execute the following set of commands to complete the linux API installation.

$ make headers
$ find usr/include -name '.*' -delete
$ rm usr/include/Makefile
$ cp -rv usr/include $LFS/usr

if you like a detailed explanation on how to install linux API headers, you can refer the following link...




Chapter 13 : Compile and Install GCC - Compiling a Cross-Toolchain

 Hi,

In this chapter, we are going to discuss on how to compile the GCC which GNU Compiler Collection and cross tool chain.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 10.2.0
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)
Package NameVersion
gcc10.2.0
mpfr4.1.0
gmp6.2.0
mpc1.1.0

Change Directory to sources folder

$ cd $LFS/sources

Extract the gcc-10.2.0.tar.xz file in source folder

$ tar -xvf gcc-10.2.0.tar.xz

The above command would result in the creation of a new directory in /mnt/lfs/sources/ folder called gcc-10.2.0

Change directory to gcc-10.2.0

$ cd gcc-10.2.0

As you can see from the list of packages given above, the other packages has to be extracted inside gcc-10.2.0 folder, to extract those packages use the commands given below...

$ tar -xf ../mpfr-4.1.0.tar.xz
$ mv -v mpfr-4.1.0 mpfr

$ tar -xf ../gmp-6.2.0.tar.xz
$ mv -v gmp-6.2.0 gmp

$ tar -xf ../mpc-1.1.0.tar.gz
$ mv -v mpc-1.1.0 mpc

On x86_64 hosts, set the default directory name for 64-bit libraries to “lib”

case $(uname -m) in
  x86_64)
    sed -e '/m64=/s/lib64/lib/' \
        -i.orig gcc/config/i386/t-linux64
 ;;
esac

As suggested, the build process has to happen in a dedicated directory, hence creating a directory called build in gcc-10.2.0 folder.

$ mkdir build
$ cd build

Preparing GCC for compilation...

../configure                            \
    --target=$LFS_TGT          \
    --prefix=$LFS/tools           \
    --with-glibc-version=2.11  \
    --with-sysroot=$LFS          \
    --with-newlib                      \
    --without-headers                \
    --enable-initfini-array          \
    --disable-nls                         \
    --disable-shared                   \
    --disable-multilib                 \
    --disable-decimal-float        \
    --disable-threads                  \
    --disable-libatomic              \
    --disable-libgomp                \
    --disable-libquadmath         \
    --disable-libssp                    \
    --disable-libvtv                    \
    --disable-libstdcxx               \
    --enable-languages=c,c++

Compiling GCC
$ make -j4

Installing GCC
$ make install

Create a full version of the internal header using a command that is identical to what the GCC build system does in normal circumstances
$ cd ..
$ mkdir -p ./install-tools/include
$ touch ./install-tools/include/limits.h
$ cat gcc/limitx.h gcc/glimits.h gcc/limity.h > `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h




Chapter 12 : Compile and Install BinUtils - Compiling a Cross-Toolchain

 Hi,

In this chapter, I would be discussing on how to compile the bin utils package

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 2.35
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Use the following command to unpack the package...

$ tar -xvf binutils-2.35.tar.xz

The above command would unpack the package in a folder called binutils-2.35.

Once the command execution is completed, we have to change directory to that folder.

$ cd binutils-2.35

The linux from scratch suggest that we should be compiling the packages using a dedicated directory.

To compile binutils, let us create a directory called "build" inside binutils-2.35

$ mkdir build

Change directory to build directory

$ cd build
Paste the following command at the terminal to prepare binutils for compilation.

../configure --prefix=$LFS/tools   \

                 --with-sysroot=$LFS  \

                 --target=$LFS_TGT  \

                 --disable-nls              \

                 --disable-werror

Execute the following command at the prompt to compile the binutils

$ make

If the above command execution is successful then execute the following command to install binutils

$ make install

For detailed explanation on compiling binutils package, you can refer the link given below...





Chapter 4 : Creating FSTAB entries to automate mounting of partitions of the disk during system boot

 Hi,

In this post/chapter I am going to talk about how to automate the process of mounting of partitions of the disk...

We are going to use the partitions created in chapter-02 to mount automatically , to recollect let me summarize the partitions here briefly...

Disk Partition Partition Name Partition Type Size of the Partition
/dev/sde1bootext2100 MB
/dev/sde2rootext430 GB
/dev/sde3swapswap9.9 GB


The purpose of having this post/chapter is when ever the system is shutdown... the mount point we established would vanish and it becomes tedious for the user to mount the partitions again and again after every system boot.

This is where fstab comes handy as a solution to this problem.

the following would describe the edition of  fstab and check whether the mounting has happened without error...

Identifying the UUID of the partitions

To identify the UUID of the partitions we can the use the utility called "blkid" which would list all the UUID of the partitions available in the system.

$ blkid

The output of the above command is sampled below...


from the above command output, we can inference the following details...

Disk Partition Partition UUID Partition Type
/dev/sde186fa30de-9907-4ced-a5ba-c6043ae04aeeext2
/dev/sde2d9bfa86a-9ba8-4681-9bd0-3c3e25ee9ce3ext4
/dev/sde33ce6bf45-e899-4c48-94b4-0c11305c2353swap


Editing the FSTAB file

Before we edit the fstab file, we have to know the structure of the file, the structure of the table is furnished in the table below to have the understand what each parameter is meant for...

File SystemDenotes the partition name or the UUID of the partition
Mount PointThe location at which the partition is mounted
TypeType of the file system on the partition
OptionsDenotes the options available in the manual page of fdisk
DumpDenotes the flag for the back up, 0=no-backup, 1=yes-backup
Pass-

Based on the above understanding, we would arrive the fstab entries as follows...

File System Mount Point Type Options Dump Pass
UUID=d9bfa86a-9ba8-4681-9bd0-3c3e25ee9ce3 /mnt/lfs ext4 defaults 0 1
UUID=86fa30de-9907-4ced-a5ba-c6043ae04aee /mnt/lfs/boot ext2 defaults 0 1
UUID=3ce6bf45-e899-4c48-94b4-0c11305c2353 swap swap defaults 0 0

Use the command below to edit the fstab file...

$ sudo vi /etc/fstab

after we include the above fstab entires in fstab file, the file would like the one shown below...




Testing or Validating the fstab entries

This testing phase is required after including the fstab entries because the system would not boot properly if there is an error in any of the entries included.

For the SWAP partitions to be mounted, we should have switched on SWAP using the following command

$ sudo swapon /dev/sde3

In order to check or test the entires, use the command below...

$ sudo mount -a

This command would try to mount all the entries made available in the fstab file.

$ sudo mount

This command would display the result of each entires as that of the one show below... you have to cross check whether the partition is mounted correctly or not, if there is no error then the partition would show up or else not.



You can also use an other command to check whether the partitions are mounted correctly or not.

Key in the "lsblk" command at the prompt, to have the result



the command "lsblk" is just an other option, the former is the actual way to check the integrity of the entires...



Chapter 11 : Setting up the environment for the "lfs" user

Hi,

In this chapter, we are going to setup the environment for the "lfs" user.

As part of setting up the environment, we are going to create two files namely

1. .bash_profile

2. .bashrc

3. .profile

Open a terminal and execute the following commands, keep that in mind...now you should have logged in as lfs user at the terminal.

Use the content below to create .bash_profile file 

cat > ~/.bash_profile << "EOF"

exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash

EOF


Use the content below to create .bashrc file
cat > ~/.bashrc << "EOF"
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
LFS_TGT=$(uname -m)-lfs-linux-gnu
PATH=/usr/bin
if [ ! -L /bin ]; then PATH=/bin:$PATH; fi
PATH=$LFS/tools/bin:$PATH
export LFS LC_ALL LFS_TGT PATH
EOF

$ source ~/.bash_profile

If you like to have a detailed explanation about these two files, you can checkout the following link below


Use the content below to create .profile file
cat > ~/.profile << "EOF"

export LFS=/mnt/lfs

EOF




Chapter 10 : Switching to lfs User

Hi,

In this post/chapter we are going to switch the user from the one we logged in to "lfs" user and from now on all the operations should be performed as "lfs" user.

To swith user, use the following command...

$ su - lfs

The above command would prompt you to provide the password associated with the user, provide the one associated with user.




Chapter 9 : Creating Symbolic links to tools folder

 Hi,

In this chapter we are going to create a symbolic link to "tools" folder.

To create a link, use the commands below..


$ cd $LFS
$ sudo ln -sv $LFS/tools/



Chapter 8 : Downloading the sources

Hi,

In this post/chapter we are going to discuss about downloading the sources required to compile for the new linux system.

We can get the list of tar balls of sources required to download from the location given below...


The list you would see is pretty long and it would take lot of time if you start download those tar balls in a piece meal manner.. We do have a short cut to download entire set using some set of commands given below...

$ cd $LFS/sources
$ sudo wget http://linuxfromscratch.org/lfs/view/stable/wget-list

the above command would generate a file called "wget-list" at the location /mnt/lfs/sources which is again used as input parameter for the command "wget"

Now downloading the actual tar balls of the sources...

$ sudo wget --input-file=wget-list

Once the command execution is done, you can witness the set of tar balls of sources downloaded at the location /mnt/lfs/sources.




Chapter 7 : Creating "sources" and "tools" Directory

Hi,

In this chapter I would like to disclose the creation of "sources" and "tools" directory at the location /mnt/lfs

Use the following commands to create the above mentioned directories

$ cd /mnt/lfs
$ sudo mkdir sources
$ sudo mkdir tools

Along with the creation of directories, we should also change the file permissions of the directories created...

To do that, use the following commands...

$ sudo chmod -v a+wt /mnt/lfs/sources
$ sudo chmod -v a+wt /mnt/lfs/tools

The purpose of changing the file permissions is to make the folders sticky, which means any user can perform read and write operations but only the owner can delete the file in the specified directory.

At last we have to change the ownership of the directories from "root" to "lfs"...

Use the following command to change the ownership

$ sudo chown -v lfs /mnt/lfs/sources
$ sudo chown -v lfs /mnt/lfs/tools





Chapter 5 : Automating Export of LFS Environment Variable

 Hi,

In this post/chapter I am going to talk about how the export the environment variable required to build a linux system from scratch.

This post/chapter is going to be the shortest of all still it is mandatory for the process.

Start your virtual host from your virtual box, and login as the user.

After you login, Open a terminal and edit the ".profile" of the user using the following command.

$ vi .profile

Append the file with the following...

export LFS=/mnt/lfs

Save the file and exit.

Well that is it, next time you login you do not have to worry about exporting this variable again, this variable is made available when the profile of the user is loaded.




Chapter 6 : Creating lfs User Account

Hi,

In this post let us create a dedicated user for the process of building the linux system from scratch.

Let the name of the user be "lfs"

Well before we add the user, let us create a user group and let the group name be "lfs"

Open a terminal and key in the following command...

$ sudo groupadd lfs

the above command may prompt you to key in the password, provide the one associated with the account.

Now, let us create the user..

The command to create a user is given below with necessary options in it.

$ sudo useradd -s /bin/bash -g lfs -m -k /dev/null lfs

Now let us associate a password to this newly created user, use the "passwd" command to set the password as dictated below..

$ sudo passwd lfs

The above command would ask you to type and comfirm the password.

Well with this we have created the user and move on to the next chapter


Chapter 3 : Mounting the Partitions of the Disk

 Hi,

This posts discusses on exporting the environment variable "LFS" and Mounting the partitions that we created on the chapter-02  for further proceedings...

Let us use the following command to export the variable, open an terminal and key in the following command

$ export LFS=/mnt/lfs

The above location is the mount point where the partitions are be to mounted...

Mounting the lfs partition to the mount point

Use the following command to a directory named "lfs" under the directory "/mnt"

$ sudo mkdir /mnt/lfs

the above command, if prompted for password key in the password associated with the user

Use the following command to mount the lfs partition "/dev/sde2" to the location "/mnt/lfs"

$ sudo mount -v -t ext4 /dev/sde2 $LFS

Conclusion

As a result of this action you can find a directory called "boot" and "lost+found" at the lfs mount point location


If you do not find the boot directory under /mnt/lfs... you can create one using the following command...

$ sudo mkdir $LFS/boot

Mounting the boot partition to the mount point

The location /boot is the mounting point for the boot partition "/dev/sde1".

Now mount the boot partition at the mount point, using the following command

$ sudo mount -v -t ext2 /dev/sde1 $LFS/boot

Conclusion



You can assert your action from the images given above...

Mounting the Swap partition

The last partition to be mounted is the swap partition, which can be done using the command below...

$ sudo swapon -v /dev/sde3

Conclusion





Friday, December 25, 2020

Chapter 2 : Creat, Partitioning and Format a Virtual Hard Disk

Hi, 

In this post/chapter i am going to talk about creating a virtual hard disk and formatting it. 

let us get started...

I have split this blog into four sections namely Creating, Partitioning, Formatting and Mounting, which we can discuss in a detailed manner....

Creating a Virtual Hard Disk

In this section, I would like to display images rather writing down the steps... the following images would detail you on how a virtual hard disk should be created using virtual box. the following images are the activities that you can find under the settings menu of each virtual host.




















Start the virtual host.
 
Conclusion


From the image above, if you look at the "Attached to" property it would tell us that, the created hard disk is now successfully attached to the virtual host.


Form the list of block devices, "sde" is the one that we attached to the virtual host.

Partitioning the Virtual Hard Disk

Open up a terminal and perform the following actions as said in the following images...

Use the following command to partition the disk 

$ sudo cfdisk /dev/sde




Select the option "Guid Partition Table"



As I said, the first partition should be of size 100 MB which is the boot partition.







The second partition is of size 30 GB, the size is not necessarily of this much, it is up to us to decide, the minimum recommended size is 10 GB.





The rest I have decided to have it as the swap partition, the basic idea on the size of the swap partition is that it should have twice as that of the primary memory.





When everything is set, we are good to go writing the partition table on the disk. Use the write option to have it done.


 
Conclusion



the above image would conclude the partitioning of the virtual hard disk "sde"


Formatting the Virtual Hard Disk

This section describes the writing of file system on the partitions created...

Use the following commands to write the file system on the specified partitons... 

On the boot partition i.e /dev/sde1

$ sudo mkfs -v -t ext2 /dev/sde1

ext2 is the file system, which is recommended by the linux itself for the boot partition.




$ sudo mkfs -v -t ext4 /dev/sde2



sudo mkswap /dev/sde3



Here we conclude the formatting the partitions and the same can be concluded as follows...

Conclusion



How to change the root password in linux when it is forgotten/to change

This blog is all about changing the root password of the Linux system when it is forgotten or to reset the password...   Let's get it ...