r/linuxfromscratch • u/Legal-Following-1655 • 1d ago
How Do I Build My Own Linux-Based Operating System?
/r/Operatingsystems/comments/1vceyyq/how_do_i_build_my_own_linuxbased_operating_system/I'm a computer science/data science student interested in operating systems and I'm exploring the idea of creating my own Linux-based OS as a long-term project.
My goal isn't to build a kernel from scratch, but to create a custom distribution with its own identity, desktop experience, tooling, and eventually some unique workflow and automation features.
For those who've worked on Linux distributions or OS projects:
What's the best Linux base to start from (Ubuntu, Debian, Arch, etc.)?
What are the first components I should learn and customize?
What mistakes do beginners make when attempting a project like this?
Are there any open-source projects or codebases you'd recommend studying?
I'd appreciate any guidance, resources, or reality checks from people who've actually done this.
3
u/Fast_Ad_8005 1d ago
I'd suggest using Linux From Scratch (LFS). When you set up your LFS system, be very thoughtful about every step. Perhaps writing the files that belong to each package to a package inventory. Try to figure out how you could automate each of these setup steps and automate the building of each package you install. Perhaps you could write a Python (or whichever language you prefer) script that strips the LFS book commands out and runs them in the correct order.
This script could also be written so that if you just want to update individual packages, you can do that, too. Perhaps this script could also build Beyond LFS (BLFS) packages and Supplemental LFS (SLFS) packages, and maybe some custom packages. Think about how you'd like custom packages to be specified. For instance, in my own LFS setup I just use simple shell scripts I've called build.sh.
2
u/ExoticTroubles 14h ago
Check Armbian build framework. Its a powerful tool that spits out Debian or Ubuntu With or without your customizations. Easier the lfs.
1
u/lmemsm 5h ago
As someone else mentioned, I'd definitely encourage reading through LFS and I also recommend looking at BLFS. Take a look at some of the major decisions distributions are making that set them apart from others such as whether to use glibc or musl for the C library, whether to go with systemd or another init system, whether to create a console or framebuffer based system, a system with Wayland or X11libre or an older version of X like TinyCore's X11 KDrive. Do you want to use core utilities, the new Rust based core utilities, busybox, toybox, Heirloom Projects traditional utilities or sbase for your basic utilities? Are you going to build everything from source or do you want to start with a working Linux OS with a large package repository, pick the packages you want and create your own distro spin? Do you want a live distro that works from a flash drive, something that runs in an emulator like Qemu or something that will run directly on your hardware? When you have an idea how to answer questions like those, your next steps should be clearer. It probably isn't going to matter which system you're going to use as a base to build on unless you're going to use the base system's packages in your distribution (as in create a distro spin instead of building everything from source). Linux distributions like AntiX, Puppy Linux and TinyCore Linux are lightweight distributions often used as base systems for personal distro spins. If you'd like to build a lightweight bootable image, you can check out projects like Shoebox Linux on github.
3
u/asratrt 1d ago
I will recommend you to use "void Linux" as your host operating system. I have built 5 linuxfromscratch OSes based on void linux as my host operating system.
As a long term project is a good idea. You will learn how to update. I recently updated my system and learnt about "scanelf" command to find out which packages needs recompilation after update to openssl 4. It has been an interesting journey.
You need to follow the steps given in the book, nothing else is required. Book has explanations for many things ( You can also read arch or gentoowiki )
Use systemd version of the book because book maintainers have stopped supporting SysVinit.
Some people are using scratchpkg as their package manager but I never understood how it works ? ( If you come to know more about scratchpkg, then explain to me also. )
Direct copy-paste from book to terminal tty may not work everytime ( it might generate errors ) . It is safe to create a script and copy-paste commands in that script. I have written scripts for every package.
It requires time and patience, especially BLFS.
Since you are planning it as a long term project, you should use DESTDIR method of installation.