CNT4603 - 2016
Assignment 3
No journal due

Assignment: Working with initrd

Objective: modify your initial filesystem to add new functionality.

The first step is to edit your grub defaults, /etc/default/grub, so that you have a bit more time to react; I suggest changing your timeout to 10 seconds:

Now reboot, and go to advanced options:

Add "break=premount" after the "ro" bit, to force the kernel to stop before it mounts any file systems, and thus you would be in the initial RAM filesystem rather than your ordinary root filesystem:

If you do a "cd" into /bin, you should see that while there are lots of programs, that they are mostly hard links to busybox (try "ls -li".) If you start a shell here with "./sh", and enter help, you may notice that your busybox supports many more programs than just the ones that are hard linked; in particular, you should notice that "ip" is not there.

Let's fix that. Do an "exit", and let your system boot up.

Become root. Create a subdirectory something like "new-initrd"; I used "/tmp/new-initrd", but you can do this in your /root home directory if you prefer (if you end up doing this multiple times, you will appreciate having it around after each reboot!)

Now you can "cd new-initrd && zcat /boot/initrd-somevers.gz | cpio -id" to extract your current initrd to your subdirectory.

Change directory down into "bin/"; there you should see the same exact structure as you saw in premount. Do a "ln busybox ip" to create the new hardlink:

Now create a new gzipped initrd, using "cpio" with both "--create" and "--format='newc'" (the man page for cpio's various format is here) and piping to gzip:

Copy the old version to an "ORIG" file:

Install your new version into "/boot":

And now reboot, again specifying "break=premount":

Change directory into "/bin", and, voila, you should see your shiny new ip command: