CNT4603 - 2018
Assignment 2
No journal due

Assignment: Working with initrd



Objective: modify your initial filesystem to add new functionality.

A possible first step could be 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:

If you do so, then 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:

Now you can use F10 to go ahead and continue the boot, which should take you to:

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".) It turns out that ip is linked in the directory /sbin/, but not in /bin/.

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: