Running Debian from RAM
Since about a year I'm investigating more appliance/embedded-like systems. Through all this research I stumbled upon debirf. This simple tool let's you create a full debian os in an initial ramdisk. This is especially handy for fully customised systems aimed at performance and not using harddrives or flash disks.
Firs install the tool and create a directory where you can place your images.
sudo apt-get install debirf
mkdir debirf
cd debirf/
To start simply we need to extract a profile. This profile is a set of scripts to setup a system. We'll try the 'minimal' profile first which is a simple minimal os.
tar xzf /usr/share/doc/debirf/example-profiles/minimal.tgz
Debirf by default refers to some old distros so we'll first need to edit the debirf.conf in the profile dir.
nano minimal/debirf.conf
Have a look around in the config to see what you can set. Change the following two vars to the distro/suite you are running:
DEBIRF_SUITE=lucid
DEBIRF_DISTRO=ubuntu
Next we can just create an image by issuing:
debirf make minimal
This will take a while! The output is quite verbose so if anything fails look at the exact failure message.
I've tried this on Ubuntu Lucid X86_64 which worked for me. However Oneiric failed which might be caused by some outstanding bugs.
Don't try working around this by using sudo. I don't know how but it completely ruined my system :(
After the build
You're left with two files: * debirf-minimal_lucid_2.6.32-21-generic.cgz : The ramdisk image * vmlinuz-2.6.32-21-generic : The linux kernel
Just run qemu to test the kernel, ie.:
qemu -m 256 -serial stdio -net nic -net user -kernel vmlinuz-2.6.32-21-generic -initrd debirf-minimal_lucid_2.6.32-21-generic.cgz
Thoughts
- I've found for the lucid minimal image that not everything works like it should. For example the serial console is started through inittab but inittab is obsolete in Lucid so it's never started.
- Debootstrap is being replaced by multistrap in Debian which makes it possible to build for different architectures.... It should be very easy to implement multistrap to replace debootstrap
- lots of fakeroot bugs I bumped into...
- It should be very interesting to build an image using emdebian... Hopefully I'll find time to test this
- The image can be optimised a lot. Documentation (/usr/share/doc/) is really not needed and just eats up 9MB of RAM. For example an Emdebian Grip root filesystem only uses 41MB!!!
- While investigating this tool I also discovered rootstock. This is essentiale the same tool but with a little different approach. I think it uses qemu a lot. It also seems to be supported by Canonical.
- I think you'll have more personal control if you just a build a system using multistrap and some manual tweaking.
- The initrd of debirf builds a new ramdisk containing the root filesystem. I think it would be easier to just use the primary initrd as a root filesystem directly.