Occasionally, one may discover that they need to adjust the contents of the initial RAM disk. For example, when trying to figure out how to get the Network Security Toolkit to boot from a USB thumbdrive, we needed to experiment with the loading of different modules and adding some sleep commands, device entries, etc.
The process of updating the initial RAM disk goes as follows:
First, we need to mount the partition containing the
Network Security Toolkit installation (obviously this is only required if it
isn't yet mounted). In this example, its assumed that the
Network Security Toolkit was installed in partition
/dev/sda1
.
Example 10.1. Mounting NST Installation Partition
[root@probe ~]
mkdir /tmp/nstboot
[root@probe ~]
mount /dev/sda1 /tmp/nstboot
[root@probe ~]
Next, we need to use gzip and
cpio to extract the current contents of
the initial RAM disk. The following
example extracts this to a new working directory of
/tmp/initrd
.
Example 10.2. Extracting Initial RAM Disk
[root@probe ~]
mkdir /tmp/initrd
[root@probe ~]
cd /tmp/initrd
[root@probe initrd]
gzip -dc < /mnt/nstboot/boot/initrd-nsthd.img | cpio --extract
4973 blocks
[root@probe initrd]
ls
bin dev etc init lib loopfs proc sbin sys sysroot
[root@probe initrd]
At this point we are free to add, remove and or edit
files which make up the initial RAM
disk. Most likely you will want to modify the
init
script as this controls how the
Operating System is brought up by loading modules and
mounting the file system.
Finally, we need to use gzip and cpio to save our updates back into the initial RAM disk image that the Network Security Toolkit will use the next time it boots.
Example 10.3. Saving Modified Initial RAM Disk
[root@probe initrd]
find . | cpio -oc | gzip -c -9 >| /mnt/nstboot/boot/initrd-nsthd.img
4973 blocks
[root@probe initrd]
cd
[root@probe ~]
rm -fr /tmp/initrd
[root@probe ~]
umount /mnt/nstboot
[root@probe ~]
At this point, we can try booting the system.