Thursday, November 14, 2013

initrd and initramfs -- what are they?


NOTE: The post is written for computer professionals and I will use terms as such without defining them. If you don't know what a term means, you may look it up on Wikipedia.

A while ago I installed Linux on my Proforma 6400, there is a special bootear that runs in Mac OS(since old Macs are really only meant to run Mac OS). The booter has trouble booting Linux in it's normal form since it hasn't been updated since the 2000 or 2001 and Linux has. They introduced a new boot process involving the initrd. What is the initrd -- read on too find out.

Initrd is a ram-disk which simplifies that amount of boot code in the kenerl. Before it's introduction the kernel had to know about every type of hard disk(i.e. PATA or SCSCII) and how to boot from it. If you had RAID, it had to know this and the RAID configuration. (There are lots of different configurations if you have more then 2 disks in the RAID).

With initrd, the kerenal only needs to know how to boot a ram disk, the ram disk then takes care of the rest. It also will take care of things such as disk encryption. Code separation is not the only advantage, the ram disk is actually dynamically generated when you install Linux so, whats in it the image depends on your configuration. This will reduce the size of the kernel. The ram disk will aslo be very small if  configuration is very simple.

Ofcouse there is another boot disk for installastion, this appears to be a much older practis since my Linux boot loader does support it -- what it does not expect is having too load another boot disk after the install is done.

In case you wanted to know the processes of booting the installed Linux on an old Mac is a bit complicated since you have to boot the install after installing, go into recovery mode and grab the new initrd file the OS generated after install. (apparently the installer for Linux Mint PowerPC actually does this for you)

You never have to worry about this on a PC since Grub automatically updates the augments too point too the new initrd(actually initramfs) every time you get a new kernel. The initrds and  initramfs, have to be run with a kernel of the same version number.

Three final points, firstly what is initramfs? initramfs is a replacement of initrd but the kenerel still boots the same way, initramfs is just more powerful.

My second final point is the fact that initrd has a built in recovery mode in it, so if for some reason your hard disk dies or acts up(and you don't have RAID) you can still boot a minimal OS and check out what's going. (The kernel itself will freeze if it can't boot).

Lastly initrd would seem nice and small but I believe it takes up around 20 MB of ram which can be a lot on an older machine. You will need it loaded into memory plus the kernel and it's often compressed so you need a bit more RAM for that and don't forget the memory used by your devecies it's small but does count for something. In fact this is the problem I ran into on my Mac when it only had ~ 32 MB of ram and I had to upgrade it to it's max(get ready for this...) of 128 MB of ram.(+ 8 MB on-board).

I think this is one of the reasons for Linux dropping support for 386 processes(I littly mean 386 processes, you need a 486 or newer to run Linux now) with new kernels, since a 386 topically doesn't have the memory to hold initramfs.



No comments:

Post a Comment