11 August 2003 14:32
Today I am having fun building a Linux boot image. The overall goal I'm trying to accomplish is to create a 'mini-distribution' that I can send to any given host via PXE. The images would be booted providing serial console and ssh access, so we could use it to diagnose hardware issues. Kind of like a rescue image on steriods. So Friday I spent some time reading through the Linux Bootdisk HOWTO getting accquainted with what I would need in a basic image. Leaving work Friday, I figured the best plan of action was to put everything I wanted in the initrd that I could easily specify as a kernel param via PXE.
So I put together a simple filesystem with dd if=/dev/zero of=my_fs bs=1k count=20000, and then mke2fs myfs. I copied over the /dev files, a few /etc files, etc. and got things ready to send to the test machine via PXE. The first problem I ran into was the kernel bailing, saying "attempt to read beyond end of device". This was puzzling. A little googling for that error message indicated that I needed to use the kernel boot paramater ramdisk_size=20000. I added that and got a little farther, but now the kernel was complaining that it couldn't mount the root filesystem as it was "unable to read superblock". Hrm. I ran e2fsck on the fielsystem, and cleaned up any issues there, but still ran into the problem. More googling brought me to the Linux for PowerPC Embedded Systems HOWTO, which tells me that I need to be also specifying the kernel parameter root=/dev/ram to tell the kernel, yes, I want to use the initial ram disk as my root filesystem.
That brings me to where I am now. The kernel is complaining that it can't find init. That should be easy to fix...
I made sure /sbin/init was available in my image, and also checked which libraries it needed with ldd. I copied over libc.so.6, /bin/bash to interpret /etc/rc.d/rc.sysinit, and some more required libs for bash, libtermcap.so.2 and ld-linux.so.2. Since I'm not dealing with the constraints of putting all of this on a floppy, I'm not worrying about stripping binaries or other fun stuff to reduce space usage. I also changed the root= boot param to root=/dev/ramdisk, which is a symlink to /dev/ram0, which should be the right spot. I booted up with that in place, and voila, I get init complaining about syntax errors in /etc/rc.d/rc.sysinit. Now things are really getting easy. Looks like I left a quoted string un-terminated.
Wohoo! Success! My little creation booted up, has the ramdisk mounted, and greeted me with an echo line from /etc/rc.d/rc.sysinit. The rest is easy now. Just add all the binaries I need to do what we want. My co-worker says we should make the boot process run from Perl ;-). Piece of cake.
On 29 June 2007 10:23 qweqwe