michielderhaeg / build-linux Goto Github PK
View Code? Open in Web Editor NEWA short tutorial about building Linux based operating systems.
License: Other
A short tutorial about building Linux based operating systems.
License: Other
What do i need?
I read the readme and it has stuff like bin/sh and sbin/init, i could not find anything on sbin/init so i just made my own and that didn't work, messing with the grub.cfg init parameter didn't help either
Requested init /sbin/init failed (error -13)
The error is this:
/usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x8): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x38): first defined here
collect2: error: ld returned 1 exit status
make[3]: *** [scripts/Makefile.host:100: scripts/dtc/dtc] Error 1
make[2]: *** [scripts/Makefile.build:403: scripts/dtc] Error 2
make[2]: *** Waiting for unfinished jobs....
HOSTLD scripts/mod/modpost
make[1]: *** [Makefile:556: scripts] Error 2
make[1]: Leaving directory '/home/debian/belgrade/build-linux/linux-4.4.52'
make: *** [Makefile:16: bzImage] Error 2
gen-image.sh refers to fs.tar, am assuming its the filesystem folder?
Hello, I am very new to building Linux. Firstly thank you for this nice article.
So I tried to follow your explanation but I was suck here:
We'll copy our binaries over.
$ cp /path/to/busybox usr/bin/busybox
$ cp /path/to/bzImage boot/bzImage
bzImage
appeared all of the sudden, without being mentioned until now. Newcomers to Linux like me may have no idea what does bzImage
means and where to find the bzImage
(although when I figured it out by looking through your Makefile).
Mounting /dev
when Linux has already mounted it causes mount
to fail (at least in my case) with resource busy
.
$ sudo qemu-system-x86_64 -enable-kvm image
WARNING: Image format was not specified for 'image' and probing guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
Specify the 'raw' format explicitly to remove the restrictions.
Could not initialize SDL(No available video device) - exiting
The busybox
binary can be configured to accept a --install
option to create links to itself for all the various commands in /bin/
, /sbin
, /usr/bin
, and /usr/sbin
. To have busybox
install itself to these directories, using symlinks (assuming BusyBox is configued with --install
), chroot into the installation image, then:
/path/to/busybox --install -s
Will create symlinks (without -s
it will create hardlinks) for all configured applets.
In my opinion, this is better then iterating over --list
output with a script.
5tgr
Here are my thoughts and experiments about the subject:
Initramfs hides a lot and brings unnecesary complexity eventhough
it is unneeded in 99% of the cases. So starting with an extracted
initramfs I've ended up with the attached init on /boot.
Machine boots from /boot straight and pivots to /. No initramfs
employed. Contents of /boot is always accessible and editable.
I can provide more details if there is further interest.
/boot only has the following (About 6MB in total):
Suggested common disk layout:
/dev/sda1 -> /boot - 128M btrfs created with -M mixed mode
/dev/sda2 -> / compressed btrfs on luks. (or f2fs for flash/SSD)
#!/bin/ash
setfont /boot/lat5-16.psfu.gz -C /dev/console &
loadkmap < /boot/trq.bmap &
# backgrounding with '&' is for utilizing parallel execution and
# cutting some boot seconds. You can also use it elsewhere.
# But NOT below! These lines should execute sequentially.
# Use '&' wisely.
mount -t proc proc /proc -o nosuid,noatime,nodev,noexec
# add crypt_setup lines here.
mount /dev/sda2 /mnt
cd /mnt
mount --move /dev ./dev
mount --move /proc ./proc
pivot_root . boot
exec chroot . /bin/init
I keep getting the same error as with the other issue, but the only difference is that I'm trying it on real hardware.
To be specific a PC with windows installed on it. However, I'm having trouble getting it to even boot as I'm getting a kernel panic. Also, I'm using the Makefile provided.
To be honest, I have no clue what to do.
Thanks, Sam.
Hello,
So I have followed all of the steps on the README file, and I successfully compiled the kernel. But, when I tried to boot the kernel on QEMU, it will just show:
Decompressing Linux, Parsing ELF
Or something similar to that.
I also tried using the command that is provided in the README, and it just say
Booting from ROM
and froze.
I am using Debian 10, the latest one.
Is there anyway to fix this? Thank you!
Hi Michiel,
I use Ubuntu 16.04 and when doing grub-install --boot-directory="$PWD/boot" /dev/loop0
I got error grub-install: cannot find EFI directory
.
How should I fix it?
Thanks.
The title says it all. How would I rebuild?
I tried doing make
again but I get an error saying:
make -C filesystem . make[1]: Entering directory '/home/samhep0803/build-linux/filesystem' . Makefile:1: *** missing separator. Stop. . make[1]: Leaving directory '/home/samhep0803/build-linux/filesystem' . Makefile:32: recipe for target 'fs.tar' failed . make: *** [fs.tar] Error 2
I figured it was because I already built but surely I don't have to delete my whole folder and clone this repo again.
Hopefully, you could help.
Thanks, Sam.
The tutorial is really nice and kept quite simple (I don't know if it is too simple for beginners starting from Ubuntu). It definitely is a good guide for people who already know a thing or two about Linux (I might be able to use it, however I run Gentoo on my Desktop ;P), so thank you a lot for putting your time into writing it.
There is, however, one thing which I am missing: How do I boot my system and then install new software? You are missing that part completely. You should add a little guide detailing how to add gcc or Clang and git to the system, so that source code can be fetched and compiled.
Also a little guide on how to prepare that system for installation on hardware would be nice ;)
I received the following:
console-tools/kbd_mode.c:33:22: error: linux/kd.h: No such file or directory
console-tools/kbd_mode.c: In function ‘kbd_mode_main’:
console-tools/kbd_mode.c:56: error: ‘KDGKBMODE’ undeclared (first use in this function)
console-tools/kbd_mode.c:56: error: (Each undeclared identifier is reported only once
console-tools/kbd_mode.c:56: error: for each function it appears in.)
console-tools/kbd_mode.c:57: error: ‘K_RAW’ undeclared (first use in this function)
console-tools/kbd_mode.c:59: error: ‘K_XLATE’ undeclared (first use in this function)
console-tools/kbd_mode.c:61: error: ‘K_MEDIUMRAW’ undeclared (first use in this function)
console-tools/kbd_mode.c:63: error: ‘K_UNICODE’ undeclared (first use in this function)
console-tools/kbd_mode.c:70: error: ‘KDSKBMODE’ undeclared (first use in this function)
make[2]: *** [console-tools/kbd_mode.o] Error 1
make[1]: *** [console-tools] Error 2
Per this github thread, you need to init the submodule.
cd build-linux
git submodule update --init
make
Posting here in the event this helps anyone else. This appears to happen on non-arch versions of Linux (at least, centos and ubuntu).
I had issues running busybox
as the first process. Due to a cryptic (to me) kernel error, it took me a while to realize that busybox
was compiled dynamically.
Adding CONFIG_EXTRA_CFLAGS="-static"
to the busybox .config
builds a static binary and allows the kernel to run it.
Hi
Congratulations for the tuto.
I get the message druring the boot.
kernel panic - not syncing vfs unable to mount root fs on unknown-block (0 0)
I tried change grub.cfg to root=/dev/sda{1,2,3,4} and did not work.
My disk identifier is 0x1593f630
$ cat image-root/boot/grub/grub.cfg
linux /boot/bzImage quiet init=/bin/sh root=PARTUUID=1593f630-01
boot
I use Debian 8.
tks
Hi,
The README file mentions a startup
script, but it seems to be actually called rcS
in the repository.
i want to make my own linux distro but want to make it into a live cd with an installer
Hello! May I ask which directory is "../filesystem"? Thanks
While running make all
(specifically, make busybox
) I ran into this issue:
console-tools/kbd_mode.c:33:22: fatal error: linux/kd.h: No such file or directory
#include <linux/kd.h>
^
compilation terminated.
scripts/Makefile.build:197: recipe for target 'console-tools/kbd_mode.o' failed
make[2]: *** [console-tools/kbd_mode.o] Error 1
Makefile:742: recipe for target 'console-tools' failed
make[1]: *** [console-tools] Error 2
make[1]: Leaving directory '/home/vnz/work/build-linux/busybox-1.26.2'
Makefile:26: recipe for target 'busybox' failed
make: *** [busybox] Error 2
[1] 27046 exit 2 make busybox
Any idea on how should this be resolved?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.