After building BusyBox you should end up with a directory named _install. Let’s move the directory and rename it to something more usefull:
mv _install ../rootfs
In rootfs we create dev, proc, sys and tmp directories. We need at least one device, which is the console and we need an init script as well. I also remove linuxrc.
cd ../rootfs
mkdir dev proc sys tmp
rm linuxrc
sudo mknod dev/console c 5 1
The last file we need to create is init. Before giving a shell to the user lets mount proc and sys:
cat >> init << EOF
#!/bin/ash
mount -t proc none /proc
mount -t sysfs none /sys
/bin/ash
EOF
chmod +x init
That is it. Archive the initramfs with cpio and compress it with gzip:
find . | cpio -H newc -o | gzip > ../rootfs.cpio.gz
cd ..
That is all you need. Next I will show you how to use this minimal linux in qemu.
Nasir's Notes
Just sharing my notes with you.
Tuesday, January 3, 2012
Minimal Linux: Filesystem
Monday, January 2, 2012
Minimal Linux: BusyBox
If you did read my previous post by now you know that the way I like to do things is to start with minimalistic configuration and enable just what I need. So this is how I download, extract and run make with allnoconfig option:
wget http://busybox.net/downloads/busybox-1.19.3.tar.bz2
tar xjvf busybox-1.19.3.tar.bz2
cd busybox-1.19.3/
make allnoconfig
We need to enable one option:
Busybox Settings ---> Build Options ---> Build BusyBox as a static binary (no shared libs)
However this will not give us a very useful build. You also want to have some applications. For example I want a shell (ash), some tools (cat, cp, df, ls, mkdir, mknod, mv, rm, sleep, tail, uname, vi, grep, init, mount, ps). Of course you are free to choose whatever you want, just keep in mind that it is wise to have some core tools, like a shell and being able to start the system with init and maybe mount a filesystem with mount.
When you are done exit and make sure to save the configuration. You are ready to build:
make
make install
BusyBox is now ready to be used. In the same directory we have _install which will be used for our next step which is building a filesystem.
BusyBox 1.19.3 was used while taking notes.
wget http://busybox.net/downloads/busybox-1.19.3.tar.bz2
tar xjvf busybox-1.19.3.tar.bz2
cd busybox-1.19.3/
make allnoconfig
We need to enable one option:
Busybox Settings ---> Build Options ---> Build BusyBox as a static binary (no shared libs)
However this will not give us a very useful build. You also want to have some applications. For example I want a shell (ash), some tools (cat, cp, df, ls, mkdir, mknod, mv, rm, sleep, tail, uname, vi, grep, init, mount, ps). Of course you are free to choose whatever you want, just keep in mind that it is wise to have some core tools, like a shell and being able to start the system with init and maybe mount a filesystem with mount.
When you are done exit and make sure to save the configuration. You are ready to build:
make
make install
BusyBox is now ready to be used. In the same directory we have _install which will be used for our next step which is building a filesystem.
BusyBox 1.19.3 was used while taking notes.
Minimal Linux: Kernel
The way I like to do things is to start with minimalistic configuration and enable just what I need. So this is how I download, extract and run make with allnoconfig option:
wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.1.6.tar.bz2
tar xjvf linux-3.1.6.tar.bz2
cd linux-3.1.6/
make allnoconfig
As far as I know I only need to enable ELF and initial ram file system support. Because I do not have a gui, but just a console I use:
make menuconfig
And enable:
General setup ---> Initial RAM filesystem and RAM disk (initramfs/initrd) support
Executable file formats / Emulations ---> Kernel support for ELF binaries
That is all I need for now. Exit and make sure to save the configuration. We are ready now to build our minimal linux kernel:
make
If everything went well we get a freshly compiled kernel in arch/x86/boot/bzImage ready for use. Lets continue with the minimal linux and build BusyBox.
Linux Kernel 3.1.6 was used while taking notes.
wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.1.6.tar.bz2
tar xjvf linux-3.1.6.tar.bz2
cd linux-3.1.6/
make allnoconfig
As far as I know I only need to enable ELF and initial ram file system support. Because I do not have a gui, but just a console I use:
make menuconfig
And enable:
General setup ---> Initial RAM filesystem and RAM disk (initramfs/initrd) support
Executable file formats / Emulations ---> Kernel support for ELF binaries
That is all I need for now. Exit and make sure to save the configuration. We are ready now to build our minimal linux kernel:
make
If everything went well we get a freshly compiled kernel in arch/x86/boot/bzImage ready for use. Lets continue with the minimal linux and build BusyBox.
Linux Kernel 3.1.6 was used while taking notes.
Minimal Linux
Today I wanted to build a minimal linux distribution from scratch for some embedded project I am working on in my spare time.
This post will be part of a series of posts about building minimal linux from scratch. I will show you how to do this with using a the latest kernel avalible and busybox. If you want me to cover something let me and I will post it.
First we will build a kernel and busybox with a minimal configuration. Then we will build a filesystem and use it with Qemu, because that is very easy.
I am still busy with this, there is a chance that I have not posted whatever you need, so please check back later (and spam me about it).
This post will be part of a series of posts about building minimal linux from scratch. I will show you how to do this with using a the latest kernel avalible and busybox. If you want me to cover something let me and I will post it.
First we will build a kernel and busybox with a minimal configuration. Then we will build a filesystem and use it with Qemu, because that is very easy.
I am still busy with this, there is a chance that I have not posted whatever you need, so please check back later (and spam me about it).
Subscribe to:
Posts (Atom)