Table of Contents

Rebuilding initramfs (Initial RAM filesystem) of EeePC

What is Initramfs?

The EeePC Linux use a two-stage boot process: The GRUB bootloader first loads the kernel (built with the most common drivers), then extracts the initramfs archive and mounts it as an initial RAM-based root filesystem. This allows loading of additional modules, e.g. USB drivers, and other initialization steps like F9 restore and Perform Disk Scan.

The loading of the kernel and initramfs image are specified in the following lines in /boot/grub/menu.lst:

kernel /boot/vmlinuz-2.6.21.4-eeepc quiet rw vga=785 irqpoll root=/dev/sda1
initrd /boot/initramfs-eeepc.img

If an initramfs is built into the kernel or passed to it, the kernel will try to execute the init script in the initramfs. Usually /init is a shell script that will find and mount the root partition, then switch_root onto the root partiton and execute /sbin/init.

What does initramfs do in EeePC?

In EeePC Linux, the default initramfs image as specified in /boot/grub/menu.lst is /boot/initramfs-eeepc.img. The init script of the default initramfs does the followings:

Steps to Modify initramfs

[NB. All these operations have to be done with “root” privilege. You can either su to change to a root terminal or add sudo before every command]

mkdir /boot/temp      # make temp directory to unpack the initramfs
cd /boot/temp         # enter temp directory
gunzip < ../initramfs-eeepc.img | cpio -i      # unpack the image
find | cpio -H newc -o | gzip -9 > ../initramfs-[new name]-eeepc.img

Note:

  1. If you pack the initramfs image to a new name, you will also need to edit /boot/grub/menu.lst to tell the GRUB bootloader to use the new image instead of the old one.
  2. If you have not removed unionfs, GRUB menu.lst and initramfs-eeepc.img are in the SYSTEM partition which is mounted READ ONLY. The files you have modified reside in the USER partition which is not loaded at bootup. You will have to boot into rescue mode to move the files from the USER partition to the SYSTEM partition to implement the change. Run these commands after you have booted into rescue mode:
#mount SYSTEM and USER partitions
mount /dev/sda1 /mnt-system
mount /dev/sda2 /mnt-user
#backup original initramfs image and copy new one to /boot in SYSTEM partition
cd /mnt-system/boot
mv initramfs-eeepc.img initramfs-eeepc.img.orig
cp /mnt-user/boot/initramfs-[new name]-eeepc.img .
#backup original GRUB menu.lst and copy new one to /boot/grub in SYSTEM partition
cd grub
mv menu.lst menu.lst.orig
cp /mnt-user/boot/grub/menu.lst .
#umount all partitions
cd /
umount -a
#then wait at least 8 sec before you reboot

Example: Load USB Modules at bootup

To support USB storage devices at bootup, the following changes need to be made to initramfs:

mknod -m 644 sdb1 b 8 17
mknod -m 644 sdc1 b 8 33
insmod -f /modules/usbcore.ko
insmod -f /modules/ehci-hcd.ko
insmod -f /modules/uhci-hcd.ko
insmod -f /modules/libusual.ko
insmod -f /modules/usb-storage.ko

[NB. Please note that the initramfs of EeePC only support ash commands and limited BusyBox commands including: [ cat cp cut dd dmesg echo env expr false grep insmod ln losetup ls mdev mkdir mknod mount mv pivot_root realpath rm rmmod sed sh sleep switch_root test true umount vi ]

Common Hacks of initramfs for EeePC



Reference:

rio sosh bouygues