2017 December 11 linux
How to build minimum Linux distribution ?
Not verified yet
- download Linux kernel and busybox source code.
- extract source code at linux and busybox
- install ncurses and bc
- cd to linux folder and
make menuconfig to have a gui to customize kernel configuration; then make tar-pkg to build kernel and package in a tarball. - cd to busybox folder and
make menuconfig; check build busybox as a static binary; then make; copy out the executable binary file of busybox. dd if=/dev/zero of=disk.img count=1 bs=512M to create 512MB disk; format the disk with mkfs.ext4; use losetup to bind the disk.img to a loop device such as /dev/loop0 mkdir a new folder and mount as /dev/loop0; extract built linux kernal to the folder; in the folder also do mkdir dev proc sys bin sbin sys var etc dev - copy busybox binary to bin folder; in sbin folder, do
ln to create a soft link of init (→ busybox); in bin folder, create soft link of sh, bash (→ busybox) - run
grub2-install --root-directory=<mount_folder> --no-floppy --force /dev/loop0 to set up bootable section - convert disk.img to disk.vmdk (for example with
qemu-img) - creaet a virtual machine to run the min linux
- in grub boot screen: input
linux /boot/vmlinuz-<kernel_version> root=/dev/sda rw; then type boot to get min linux run - use
busybox ifconfig to config network
-->