liva / minimal-linux

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

minimal linux

What's this?

This is the stripped version of linux kernel for learning.

Features are

  • fast compilation (only takes 20 seconds on Xeon E3-1275 v5 @ 3.60GHz)
  • less source files (almost 900 .c files)

Limitations are

  • only works on x86_64 QEMU
  • only supports 8250 serial driver

compilation

Use 'minimalconfig' for configuration. DO NOT GENERATE '.config' FROM 'make' COMMANDS!

$ cp minimalconfig .config
$ make -j8 bzImage

make rootfs

$ cd (project_root)
$ wget http://busybox.net/downloads/busybox-1.27.2.tar.bz2
$ tar xf busybox-1.27.2.tar.bz2
$ cd busybox
$ make menuconfig
Busybox Settings ---> Build Options --->Build BusyBox as a static binary (no shared libs)
$ make -j8
$ make install
$ mv _install ../rootfs
$ cd ../rootfs
$ find . | cpio -o --format=newc > ../rootfs.img
$ cd ..

run

qemu-system-x86_64 -kernel arch/x86/boot/bzImage -initrd (project_root)/rootfs.img -append "console=tty0 console=ttyS0,115200 root=/dev/ram rdinit=/bin/sh" -curses

You must switch to the serial console monitor with Ctrl+Alt+3.

to use procfs and sysfs

Run these commands in the busybox shell.

# mkdir /proc /sys
# mount -t proc none /proc
# mount -t sysfs none /sys
# mdev -s

About

License:Other


Languages

Language:C 93.5%Language:C++ 2.9%Language:Perl 1.2%Language:Assembly 0.6%Language:Objective-C 0.6%Language:Makefile 0.4%Language:Shell 0.3%Language:Python 0.1%Language:Yacc 0.1%Language:Lex 0.0%Language:Awk 0.0%Language:Prolog 0.0%