Linux From Scratch


Why I started to compile LFS

In the beginning of 2014 I tried my best to start learning Linux for real. But after finding Linux from scratch ive learned 1 thing, copying just text wasnt enough. I needed more Linux skills to be able to understand and diagnose the problems i faced.

Eventually I did sort of get the kernel compiled and working. I even registered myself in the lfscounter. got ID 24773. and version 20140527, svn. Guess I should have went for the stable version to begin with. Today tho, after learning to install Arch Linux, configure networks and do some basic compilation using GCC and C++ programming. Im able to succesfull compile, run, diagnose most faults and think im getting the hang of it.

For those that know enough about Linux from scratch, know making backups is also a smart thing. For those, who want to skip or compare their results, I share here some files that might help you. This page is suspect to change according to my ideas where I want to go with this.

Im proficient enough I think to say that you can use the rest of this page as a suggestion or guide to help build your own version of Linux from scratch. Yet, I wish to remind any reader to remember that with any new release of a piece of software or growing knowledge about the ecosystem like Linux it is best used as a guide but tested against ones own knowledge, skill and information more up to date.

According to the LFS book, its a good idea to make a backup of your temporarely tools:7.14. Cleaning up and Saving the Temporary System

If you wish to continue forward using my backup (ive not tested this yet), paragraph "7.14.3. Restore" is what you need to read (first, then type, after entering the chroot. chapters 7.3 and 7.4 has to be followed aswell).

Files

Temp tools

lfs-temp-tools-10.0-systemd-unstripped.tar.xz on Googledrive

md5: f0ce1f1d67c8f73f10f95c923ed8c8ce  
sha512: d9f583d86b27c1ca460ed749b877213df51455f8875f9d2ce2eb24331008168131512e890a51b807dbe96c626b6c7fc965220529fc5f2a26db6162175e82d752 

Full prebuild system

Default root password: LinuxR00t
lfs-10-systemd-withsymbols.tgz on Googledrive

md5: 1369866a82b9b3b8be99209f1ef98414
sha512:  02894b065a334db6e9b0fa7b3f7a5f871a17d1d5909e0d9c37ebb234465915da1254dec05002619c8c3ebb820efafc630fc0f1b0898335e6662e83c4d3c510b3

No symbols included

This version has been symbol stripped, smaller in size. difficult to debug but just as usefull.Default root password: LinuxR00t
lfs-10-systemd.tgz on Googledrive

md5: cb5b07bf8a3740b4f9d2d9488407cfcd  
sha512:  919b1ea37b9a6f9995683f6b52647851c1a7396fdeea805d89607c60614bc6f67f297a2790ee81d2d104e5814528daa4c93185a558c5bedce13b0738c503b790

Backup and restore

The above files are created with the following methods and are able to be restored by also the following instructions.Do note, ive not yet tested restoring.

Full sys backup (excluding virtual stuff)
somewhere (I asume inside chroot or running LFS) do:

tar cvpzf lfs-10-systemd-withsymbols.tgz --exclude=lfs-10-systemd-withsymbols.tgz --exclude=/proc --exclude=/lost+found --exclude=/dev --exclude=/tmp --exclude=/run --exclude=/media --exclude=/mnt --exclude=/sys / 

Alternatively, you can use Bzip2 to compress your backup. This means higher compression but lower speed. If compression is important to you, just substitutethe ‘z’ in the command with ‘j’, and give the backup the right extension.

Full restore
mount the to be LFS under $LFS:

tar xf /path/to/lfs-10-systemd-withsymbols.tgz -C $LFS

Your now in a sort of www.linuxfromscratch.org/lfs/view/stable-systemd/chapter08/revisedchroot.html
you dont have to rm tmp, but do have to do Sections: 7.3.2 and 7.3.3.

(Possibly also have to create some missing directories).maybe, havent checked:

mkdir -pv $LFS/{dev,proc,sys,run}  mknod -m 600 $LFS/dev/console c 5 1  mknod -m 666 $LFS/dev/null c 1 3  mount -v --bind /dev $LFS/dev  

eitherway, if succesfully chrooted, your now ready to enter chapter 9. (ive already cleaned both the Symbol-included and cleaned versions).

What I do to enter after a full build

mount lfs to the right folder (or like me, its in fstab)same for swap, usr, home, and whatever

export LFS=/mnt/lfsmount --bind /boot /mnt/lfs/bootmount -v --bind /dev $LFS/devmount -v --bind /dev/pts $LFS/dev/ptsmount -vt proc proc $LFS/procmount -vt sysfs sysfs $LFS/sysmount -vt tmpfs tmpfs $LFS/runif [ -h $LFS/dev/shm ]; then  mkdir -pv $LFS/$(readlink $LFS/dev/shm)fichroot "$LFS" /usr/bin/env -i          \    HOME=/root TERM="$TERM"            \    PS1='(lfs chroot) \u:\w\$ '        \    PATH=/bin:/usr/bin:/sbin:/usr/sbin \    /bin/bash --login

Package Management

I know, this is one of those things, you gonna probably need to do some selecting and trial and error.first, whats a package manager, what did early package managers do, what do modern ones do. in what languages are they written, is it hard? (im sure the modern ones are). what options do you have to keep it simple?

This page explains some basic management techniques:
http://lfs-matrix.net/lfs/view/stable-systemd/chapter08/pkgmgt.html

According to the following hint, its a good read to begin with:
http://lfs-matrix.net/hints/downloads/files/essential_prereading.txt

and the hints colletcion has some ideas you could use:
http://lfs-matrix.net/hints/downloads/files/package_management_using_trip.txt
http://lfs-matrix.net/hints/downloads/files/pkg_unionfs.txt
debian package management, probably good enough
http://lfs-matrix.net/hints/downloads/files/dpkg.txt

Im not sure if these are any good, but fakeroot is another technique:
http://lfs-matrix.net/hints/downloads/files/fakeroot.txt
http://lfs-matrix.net/hints/downloads/files/more_control_and_pkg_man.txt

This one promisses a GTK+ GUI aswell:
http://lfs-matrix.net/hints/downloads/files/paco.txt

This might be helpfull finding wich package is needed for said package:
http://lfs-matrix.net/hints/downloads/files/blfs-deps.txt
and probably a mandatory earlier read:
http://lfs-matrix.net/hints/downloads/files/dependency.txt

some extra automation hints I see, that I might take a look at:
http://lfs-matrix.net/hints/downloads/files/copy-paste-blfs-book-commands.txt

Distributed compiling, for if you want to keep builded packages for slower or other systems arround:
http://lfs-matrix.net/hints/downloads/files/distributed_compiling.txt

Xorg or Desktop

1SBU

Wrapping the first package to be build into a time construct results in a rough estimate that can predict how many “SBU” later build packages take to build. My results where pretty accurate:

1SBU--------------------real  1m11.760suser  4m5.314ssys   0m38.545s

Do note however, I used a -j8 flag while doing normal make commands, significantly making the compilation faster.