On Tue, Oct 09, 2007 at 03:49:41PM +0200, octane indice
wrote:> Hello
>
> Is there a skeleton for an initramfs, like mkinitrd do for an initrd?
There are, mostly very big and complicated. I know one from the debian's
initramfs-tools package.
But right now i happened to do a klibc based initramfs to boot my laptop
from scratch. Started it mainly due to discussion in the LKML about
userspace helpers for kernel messages (coloring, filtering, etc.), but
wanted to make long time ago.
> An archive where all I could need for my initramfs could be present, with a
> shell script ready to fill in with my work to be done.
In the "archive" there are not that much things, actually.
(cpio doesn't handle device nodes, so this must be created)
/dev/null
/dev/kmsg
/dev/console
/bin/{all klibc executables + dash}
/init
/proc + mount -t proc
(optional, if process handling magic is needed early)
== == = basically =
#!/bin/sh
# NOTE: pipefs (in <2.6.2?) isn't up yet
test -e null || mknod null c 1 3
{
mkdir -m 0755 /dev
mkdir -m 1777 /tmp
mkdir -m 0555 /proc
cd /dev
mknod null c 1 3
mknod kmsg c 1 11
mknod tty c 5 0
mknod console c 5 1
} 2>null
umask 077
mount -t proc proc /proc
== * =
/null i use for hiding possible error messages from mkdir && mknod,
because i think too much checking isn't needed here. It can me removed
then (or will be removed, when klibc's init will wipe initramfs)
Then goes driver loading and rootfs mounting part:
== == = simplified debian's init =
modprobe $drivers
mountroot
mount /sys " $rootmnt/sys"
mount -n -o move /proc "$rootmnt/proc"
exec run-init "$rootmnt" "$init" "$@"
<>"$rootmnt/dev/console"
== * =
As you can see run-init is the last thing on initramfs.
To make usable initrd image for bootloader i use something like this:
== == = making initramfs image =
mount /dev/sda2 /mnt/bootkey/ -onoatime
mkdir /tmp/initramfs && cd /tmp/initramfs && {
gunzip -c /mnt/bootkey/test-setup/initrd | cpio -i
cat /mnt/work/app-src-build/shell/init >init
find | cpio -H newc -o | gzip -9 > /mnt/bootkey/test-setup/va-initrd
}
cd /tmp
rm -rf /tmp/initramfs
== * =
Where /mnt/work/app-src-build/shell/init is my current version of the
script, and /mnt/bootkey/test-setup/va-initrd is A GRUB's directory
for testing stuff on my usb-key. Of course initial va-initrd has all
binaries i've mentioned.
Currently i'm trying to do tty(text) splash screen with silly animated
debian logo, i've posted here some time ago. It also features early
log files, split scrolling regions for errors and messages, user input.
____