Hardened_Linux_From_Scratch

Linux From Scratch

Linux From Scratch

Type of Linux installation


Linux From Scratch (LFS) is a type of a Linux installation and the name of a book written by Gerard Beekmans, and as of May 2021, mainly maintained by Bruce Dubbs. The book gives readers instructions on how to build a Linux system from source. The book is available freely from the Linux From Scratch site.[1]

Quick Facts Developer, OS family ...

Projects under LFS

Linux From Scratch is a way to install a working Linux system by building all components of it manually. This is, naturally, a longer process than installing a pre-compiled Linux distribution. According to the Linux From Scratch site, the advantages to this method are a compact, flexible and secure system and a greater understanding of the internal workings of the Linux-based operating systems.[5]

To keep LFS small and focused, the book Beyond Linux From Scratch (BLFS) was created, which presents instructions on how to further develop the basic Linux system that was created in LFS. It introduces and guides the reader through additions to the system including the X Window System, desktop environments (KDE, GNOME, Xfce, LXDE), productivity software, web browsers, programming languages and tools, multimedia software, and network management and system administration tools. Since Release 5.0, the BLFS book version matches the LFS book version.[6]

The book Cross Linux From Scratch (CLFS) focuses on cross compiling, including compiling for headless or embedded systems that can run Linux, but lack the resources needed to compile Linux. CLFS supports a broad range of processors and addresses advanced techniques not included in the LFS book such as cross-build toolchains, multilibrary support (32 & 64-bit libraries side-by-side), and alternative instruction set architectures such as Itanium, SPARC, MIPS, and Alpha.

The Linux from Scratch project, like BitBake, also supports cross-compiling Linux for ARM embedded systems such as the Raspberry Pi and BeagleBone.[7][8]

The book Hardened Linux From Scratch (HLFS) focuses on security enhancements such as hardened kernel patches, mandatory access control policies, stack-smashing protection, and address space layout randomization. Besides its main purpose of creating a security-focused operating system, HLFS had the secondary goal of being a security teaching tool. It has not been updated since 2011.

Automated Linux From Scratch (ALFS) is a project designed to automate the process of creating an LFS system. It is aimed at users who have gone through the LFS and BLFS books several times and wish to reduce the amount of work involved. A secondary goal is to act as a test of the LFS and BLFS books by directly extracting and running instructions from the XML sources of the LFS and BLFS books.

Requirements and procedure

A clean partition and a working Linux system with a compiler and some essential software libraries are required to build LFS. Instead of installing from an existing Linux system, one can also use a Live CD to build an LFS system.

The project formerly maintained the Linux From Scratch Live CD.[9] LFS Live CD contains all the source packages (in the full version of the Live CD only), the LFS book, automated building tools and (except for the minimal Live CD version) an Xfce GUI environment to work in. The official LFS Live CD is no longer maintained, and cannot be used to build the LFS version7 or later.[9] There are, however, two unofficial builds that can be used to build a 32-bit or 64-bit kernel and userspace respectively for LFS 7.x.[10]

First, a toolchain must be compiled consisting of the tools used to compile LFS, like GCC, glibc, binutils, and other necessary utilities. Then, the root directory must be changed, (using chroot), to the toolchain's partition to start building the final system. One of the first packages to compile is glibc; after that, the toolchain's linker must be adjusted to link against the newly built glibc, so that all other packages that will make up the finished system can be linked against it as well. During the chroot phase, bash's hashing feature is turned off and the temporary toolchain's bin directory moved to the end of PATH. This way the newly compiled programs come first in PATH and the new system builds on its own new components.

List of packages in LFS

More information Component, Description ...

[18] This is a list of the packages included in CLFS version 1.1.0. Unless otherwise noted, this list is applicable to all supported architectures.

Standard build unit

A "standard build unit" ("SBU") is a term used during initial bootstrapping of the system, and represents the amount of time required to build the first package in LFS on a given computer. Its creation was prompted by the long time required to build an LFS system, and the desire of many users to know how long a source tarball will take to build ahead of time.

As of Linux From Scratch version 10.1, the first package built by the user is GNU binutils. When building it, users are encouraged to measure the build process using shell constructs and dub that time the system's "standard build unit". Once this number is known, an estimate of the time required to build later packages is expressed relative to the known SBU.

Several packages built during compilation take much longer to build than binutils, including the GNU C Library (rated at 4.2 SBUs) and the GNU Compiler Collection (rated at 11 SBUs). The unit must be interpreted as an approximation; various factors influence the actual time required to build a package.

Reception

LWN.net reviewed LFS in 2004:[19]

Linux From Scratch is a wonderful project. It should become a compulsory reading material for all Linux training courses, and something that every Linux enthusiast should complete at least once. This would also create another interesting side effect: people who tend to be quick in expressing dissatisfaction on the distributions' mailing lists and forums would probably show a lot more respect for the developers. Installing a ready-made distribution is a trivial task. Building up a set of 4 CDs containing a stable, secure and reliable operating system, plus thousands of applications, is most definitely not.

Tux Machines wrote a review about Linux From Scratch 6.1 in 2005:[20]

Now on to BLFS. Unfortunately Beyond Linux From Scratch is always a book behind it seems. To me it's not a real install until one can log into a window manager.

Tux Machines also has a second[21] and a third part[22] of the review.

See also

Other source-based Linux distributions:


References

  1. "LFS News". www.linuxfromscratch.org. Retrieved 2 September 2023.
  2. Beekmans, Gerard (2023). Linux From Scratch, Version 12.0 (PDF).
  3. "Appendix D. LFS Licenses". Retrieved 9 August 2023.
  4. What is Linux From Scratch?, LFS Project Homepage
  5. Gerard Beekmans: Beyond Linux From Scratch, Version 6.3 (August 2008)
  6. Brendan Horan. "Practical Raspberry Pi". 2013. p. 105.
  7. "LFS LiveCD Project Homepage". www.linuxfromscratch.org. Retrieved 25 May 2018.
  8. "Index of /~kb0iic/livecdupd". clfs.org. Retrieved 25 May 2018.
  9. "Licenses for manual pages". www.kernel.org. Retrieved 25 May 2018.
  10. "NCURSES – Licensing". Retrieved 9 July 2013.
  11. "The "Artistic License" - dev.perl.org". dev.perl.org. Retrieved 25 May 2018.
  12. Artistic - file on the Perl 5 git repository
  13. "Perl Licensing". dev.perl.org. Retrieved 8 January 2011.
  14. "Tcl/Tk Licensing Terms". Retrieved 8 January 2011.
  15. "New license", GitHub "facebook/zstd"
  16. "Learning with Linux From Scratch [LWN.net]". lwn.net. Retrieved 28 March 2020.
  17. "Linux From Scratch 6.1 (part 1?) | Tux Machines". www.tuxmachines.org. Retrieved 28 March 2020.
  18. "Linux From Scratch 6.1 - Part 2 - BLFS | Tux Machines". www.tuxmachines.org. Retrieved 28 March 2020.
  19. "Beyond Beyond Linux from Scratch (lfs - part3) | Tux Machines". www.tuxmachines.org. Retrieved 28 March 2020.

Share this article:

This article uses material from the Wikipedia article Hardened_Linux_From_Scratch, and is written by contributors. Text is available under a CC BY-SA 4.0 International License; additional terms may apply. Images, videos and audio are available under their respective licenses.