Linux From ScratchThis Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
This is a pre-noob question. With LFS, you have to start by already having installed a Linux distro (such as Debian, OpenMandriva, Fedora, or openSUSE). So it's kind of like de-hydrated water. You add water, and you get water! You start with Linux, go through Linux From Scratch, and you end up with Linux!
I figure there's a reason for it, probably that actually starting from scratch (just BIOS pre-installed, or whatever) would be too difficult. I also figure that I'm not the first to ask this question. Is there anywhere this question is already addressed?
A few LFS users on here can probably better answer your question but I always thought LFS was for learning how Linux is put together. I do think it can actually be used for daily work, but no clue how - the closest I ever got was Gentoo (stage 1) which (was) far more complex to install than all other distros, LFS aside.
The literal answer is "because you have to start from somewhere". A modern PC has enough built-in to check a few storage devices for something to boot from and display an error if it doesn't find one, but the "something" has to be ready-compiled. I understand some early computers would let you enter a program via toggle switches on the front panel, but if you tried to do that with a modern Linux kernel you'd still be there next Christmas.
In practise I suspect any operating system that can run a suitable compiler could be used to build LFS, but most LFS users will already have used Linux and probably have a distro (or another LFS) already installed. Plus, starting from Linux means you'll have good support for whatever filesystem you want to use, and the option to chroot into the part-built system if needed.
As sevendogsbsd has indicated, the point of LFS is to end up with a Linux system you've built yourself, learning as you go, plus having it exactly as you like it rather than a distro that would be based on somebody else's preferences. And like sevendogsbsd, the closest I've ever got was part way through a Gentoo install. (I was impressed with how smoothly it worked, but not dedicated enough to spend the time on it.)
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,153
Rep:
The main idea in LFS aside from the learning process, is to create an OS that it completly tailored to your own needs, you decise what you want to install, and what you don't need to install, you choose your desktop ( if any ), init system etc etc, also of course the latest LFS book uses pretty much the most recent software.
As for using it for every day use, of course you can, it's just like any other distro, once you have the basic system you just build from there, I ( and many others on this sub forum ) use LFS as their main/only day to day distro, I for instance run a full custom desktop ( https://github.com/KeithDHedger/LFSDesktopProject ), LFS is also ideally suited to products like the Pi, I have one myself running my website, kodi media centre, retroarch for occasional gaming, etc all built on LFS.
The only limitations on LFS is what you decide you want and how much effort you want to put into it.
linux was originally developed using minix which is another Unix like operating system. So these days it takes an existing operating system to build another one. Learning about the history of computers and how programs were originally developed might help you answer your question.
Some of the responses so far have slightly touched on my question, and one of them was so far off that I wasn't even sure it wasn't meant to be a reply to another question. (My question had nothing to with daily use, one way or the other.)
Clearly, if the instructions specify that you must have Linux already installed before beginning, it's not just a matter of "you have to start somewhere". To give a concrete example, a store like Goodwill might sell a used computer, but they remove the hard-drive before selling it.
Thanks for the mention of Gentoo, sevendogs. That might be a good preparatory place for me to start before trying LFS.
Last edited by tharpa; 01-24-2019 at 11:02 AM.
Reason: Corrected - I see now that Goodwill removes the hard drives, not just the OS. This partially invalidates my point.
Gentoo now only has stage 3 installs but not sure what was gained by 1 and 2. With stage 3, you still build the entire system with the compiler you compiled and optimizations so it's fairly custom. I always installed Gentoo using the "systemrescuecd" which is theirs and allows you to boot to a graphical environment with a browser up and several terminals so you can read through the docs and type at the same time. Or you can do it the masochistic way and boot to Gentoo's live cd at the cli use a tty and links (browser) with the docs up and switch between ttys...I did this before the existence of systemrescuecd. Not really any fun.
To build and OS you need a toolchain, source code, compiler, etc and for that you need an OS. The short answer is that you need an OS to build an OS...
The first Linux kernel was cross compiled on MINIX.
The basic function of the BIOS is to initialize the PC and provide a basic boot loader so that an operating system can load and run from a drive or optical disc. It is stored in EEPROM and not easily erased and if it was the computer would be nothing more then a door stop.
The kernel is a essentially a program that is written in c and needs a compiler to convert it into machine language so that it can actually run. And since the kernel is very complex and large it takes an existing operating system to compile it.
In the early days of computing a program was entered into the computer using toggle switches. From there punch cards and tape drives were used to store and load programs. Then came assembly and eventually high level languages were developed but the compilers were originally in machine code or assembly. I left out a few details...
Your question is more of how a PC/operating system works then how to build a LFS system.
LFS used to provide a CD that allowed you to build an LFS system on a machine that didn't have Linux on it. This was still a Linux system of course, just a semi-detached one. I think there is still an LFS CD but you can't build from it any more.
The problem as The Book itself points out is that "to build a compiler, you need a compiler". In fact, to build the gcc compiler, you need gcc. There are parts of gcc that no other compiler will build correctly.
One way you can build an LFS system for a new computer is to use CLFS (Cross-LFS) and build the Chapter 5 toolkit on another machine, perhaps with a different architecture. CLFS guides you in adding a kernel and bootloader and then you can put the whole thing on a memory stick and boot the new machine from that.
Hi tharpa. Apparently you like metaphors.
I want to build a car from scratch but the only way to get the parts to me is with motor vehicles. That doesn't make any sense that I need motor vehicles to build a motor vehicle.
Put another way why, "...You start with Linux, go through Linux From Scratch, and you end up with Linux..." is because LFS is instructions to compile and build a Linux system-not invent Linux. The "start from" and "end up with" statements are worth a laugh and one is free to miss or pretend to miss what is actually being done.
Apparently someone is trying to do LFS from Windows if you're interested.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.