Sun Nov 20 19:04:03 2022 UTC

Building an initrd

What's an initrd ?

If we stick to Wikipedia, in computing (specifically as regards Linux computing), initrd (initial ramdisk) is a scheme for loading a temporary root file system into memory, which may be used as part of the Linux startup process.

initrd and initramfs refer to two different methods of achieving this. Both are commonly used to make preparations before the real root file system can be mounted.

What would you need an initrd for ?

The first file your computer is loading is the kernel which is responsible of almost everything regarding hardware. The kernel is his name means, the core of the system. Unfortunatly, it can not guess things alone. You might use a RAID, LVM, NFS systems or an encrypted partition. For all thoses reason, and perhaps more other, you need an initrd image to complete that task.

How does it work on NuTyX

An initrd has a naming schema that follows the name and the version of the kernel that is associate with. For example, if you are running on the latest kernel version as today. The name of the kernel is: kernel-stable . If we look in the directory where all the kernels reside, we find indeed a kernel with such a name file to it:
ls -al /boot/kernel*
-rw-r--r-- 1 root root 9.7M  7 oct 15:09 /boot/kernel-stable

In this example, the name of the initrd file would be: initrd-stable

Build an initrd

If you decide to use an initrd image at boot time, you need to build the initrd yourself ONES. To build this file, the only restriction is that you have the root credentials rights. Either you use sudo command either you activate the root account and switch to root:

To know which kernel you are running on, use this command:

uname -r
I'm running on the kernel 5.10 LTS version and going to build an initrd for it. The command mkinitramfs needs one argument which is exactly the result of the uname -r above.
sudo mkinitramfs $(uname -r)
[sudo] Mot de passe de thierry : 
Creating ... 

If we look in the directory where all the kernels reside, we find indeed a new file named: initrd-5.10.155-NuTyX-510

l /boot -tr 
-rw-r--r--  1 root root  80M 10 oct 19:47 initrd-5.10.155-NuTyX-510
drwxr-xr-x  4 root root 4.0K 10 oct 19:47 .

As a convention, the name of the initrd is ALWAYS made of initrd and last part of the initrd filename separated by a dash, in our example:


We can now make the link with following command:

sudo ln -svf  initrd-5.10.155-NuTyX-510 /boot/initrd-510
[sudo] Mot de passe de thierry : 
'/boot/initrd-510' -> 'initrd-5.10.155-NuTyX-510'

That's it, we are done and ready to check if the upgrade process works.

Check the upgrade process

Checking the upgrade consist just of reinstalling the kernel-510 package:

sudo cards install kernel-510
[sudo] Mot de passe de thierry :
  kernel-510 5.10.155-1   62.70 MB (111.97 MB/s) 100 % - 0 s 
Obtenir les infos sur les 704 paquets: 100 %
SUPPRIME: (cli-extra) kernel-510 5.10.155-1, 5138 fichiers: 100 %
  AJOUTE: (cli-extra) kernel-510 5.10.155-1, 5146 fichiers: 100 %
post-installation: démarrée
This is a bios installation
Creating ... 
post-installation: finie
post-installation: démarrée
  /sbin/ldconfig -r /
post-installation: finie

We can see by the result above that an new initrd have been created. Still with following command, everything should be clear:

l /boot -tr 
lrwxrwxrwx  1 root root   23 10 oct 20:13 kernel-510
lrwxrwxrwx  1 root root   23 10 oct 20:13 initrd-510
drwxr-xr-x 35 root root 4.0K 10 oct 20:13 ..
drwxr-xr-x  4 root root 4.0K 10 oct 20:13 .

Adjusting your GRUB

Adjusting the grub is explain here. Only adjust the name of initrd with your.

Good luck !!!