|8.1.2010||The year I started blogging (blogware)|
|9.1.2010||Linux initramfs with iSCSI and bonding support for PXE booting|
|9.1.2010||Using manually tweaked PTX assembly in your CUDA 2 program|
|9.1.2010||OpenCL autoconf m4 macro|
|9.1.2010||Mandelbrot with MPI|
|10.1.2010||Using dynamic libraries for modular client threads|
|11.1.2010||Creating an OpenGL 3 context with GLX|
|11.1.2010||Creating a double buffered X window with the DBE X extension|
|12.1.2010||A simple random file read benchmark|
|14.12.2011||Change local passwords via RoundCube safer|
|5.1.2012||Multi-GPU CUDA stress test|
|6.1.2012||CUDA (Driver API) + nvcc autoconf macro|
|29.5.2012||CUDA (or OpenGL) video capture in Linux|
|31.7.2012||GPGPU abstraction framework (CUDA/OpenCL + OpenGL)|
|7.8.2012||OpenGL (4.3) compute shader example|
|10.12.2012||GPGPU face-off: K20 vs 7970 vs GTX680 vs M2050 vs GTX580|
|4.8.2013||DAViCal with Windows Phone 8 GDR2|
|5.5.2015||Sample pattern generator|
Initrd (or nowadays initramfs) is a simple thing, and I often find it easier to create one myself rather than to figure out how to operate distribution specific tools to get all the required features in.
Since I have a proper file server, I prefer my desktops diskless. NFS roots are otherwise OK, but efficient caching is a bit problematic since the standard Linux disk cache acts on the block device layer. I have found it easiest to just use iSCSI (which is a real block device) for the remote root filesystem. Unfortunately the Linux kernel can't be told to use its iSCSI initiator automatically during boot-up (as can be done with NFS), so we need to do that ourselves.
I also have 2 gigabit NICs in my desktop which I would like to bond in software. As this is only possible after Linux has already been booted, we need to use a single NIC during PXE booting, and then switch to the bond device before mounting the real root. Hence the right place to intialize the bond interface is the initramfs, which doesn't have any dependencies on network.
In this blog entry, I'll give you an example of how to make a transparent minimalistic initramfs that can be used to boot a Linux from network (PXE) using aggregated NICs and iSCSI.
The initial ram filesystem should have an init script, which sets up the networking and the iSCSI device, mounts root, and then passes control over to the real root's init script as if nothing had happened.
Such a script could look like this (I haven't commented it much but it's rather self-explanatory):
For this to work, you need to include in your image:
My root, for example, looks like this:
You can grab the initramfs I use from here (without /etc/shadow, /lib/modules/188.8.131.52, or /etc/iscsi, which are personal).
When you have a root ready, package it like this:
Now you should be ready to enjoy your 2Gbps remote root with a proper local disk cache. :-)
For instance, I have 8G of RAM in my desktop, of which ~7G is usually free for cache; the performance difference to NFS is huge.
This aritcle helps a lot! But I still confuse that is there anything we have to build in kernel directly to let iscsi work properly? And in my experience, I have to remove the network start script to prevent the iscsi connection from disconneting.- Roy
Thanks! No, I didn't need to compile anything extra in the kernel. All the iSCSI stuff is included in the ramfs as modules. The network start script is a valid concern, however I didn't have to touch it. I guess the interface is down such a short time before brought back up again that it doesn't block on any file system calls. I'm using a static IP for my desktop, so it doesn't have to invoke a dhcp client or anything while bringing up the interface again. (Might have a difference)- wili