Labels

hpunix (63) marathi kavita (52) linux (21) solaris11 (10) AWS (5) numerology (5)

Friday, March 24, 2017

Linux Query or Interview question - 9

Query 1. If you remove initrd or initramfs image or kernel from server what will happen?

Ans: If you remove initrd or initramfs image or kernel (vmlinuz) from running server then server will run in good condition till the reboot. Because the kernel or initrd image is present on memory (RAM). 

When we give reboot signal on server the kernel/initrd image will get loaded back to HDD via RAM. And after reboot while the server coming up, it (boot loader) will try to search kernel or iinitrd image to load on to RAM from HDD but it will not get so the server will not come up.

The kernel (vmlinuz) or initrd image is present under /boot directory or mountpoint.

[root@testmachine boot]# ls -lrt |egrep -i "initrd|vmlinuz"
-rwxr-xr-x. 1 root root  4128944 Nov 11  2013 vmlinuz-2.6.32-431.el6.x86_64
-rwxr-xr-x  1 root root  4223504 Aug 10  2015 vmlinuz-2.6.32-573.3.1.el6.x86_64
-rw-------  1 root root  5965847 Aug 17  2015 initrd-2.6.32-431.el6.x86_64kdump.img
-rw-------  1 root root  5953546 Oct  8  2015 initrd-2.6.32-573.3.1.el6.x86_64kdump.img

In older version we were having initrd (init ram disk) image and in newer version we have initramfs image. The main purpose of this file is to mount / partition in read only mode.

*************************************************************


Query 2: How to view initramfs image?

Ans: We can find the initramfs file under /boot partition.

[root@testmachine boot]# ls -lrt |grep -i initramfs
-rw-------. 1 root root 17551982 Jun 24  2015 initramfs-2.6.32-431.el6.x86_64.img
-rw-------  1 root root 28095966 Aug 17  2015 initramfs-2.6.32-573.3.1.el6.x86_64.img

In older version we were having initrd (init ram disk) image and in newer version we have initramfs (init ram filesystem) image. The main purpose of this file is to mount / partition in read only mode. After mounting the / partition, it calls /sbin/init program which is father of all processes in user space having PID=1 & start the system initialization.

[root@testmachine ~]# pidof init
1

We can view content of initramfs file by lsinitrd command.

[root@testmachine ~]# lsinitrd /boot/initramfs-2.6.32-573.3.1.el6.x86_64.img |more
Image: /boot/initramfs-2.6.32-573.3.1.el6.x86_64.img: 27M
========================================================================
dracut-004-388.el6
========================================================================
drwxr-xr-x  26 root     root            0 Aug 17  2015 .
drwxr-xr-x   2 root     root            0 Aug 17  2015 bin
lrwxrwxrwx   1 root     root            4 Aug 17  2015 bin/awk -> gawk
-rwxr-xr-x   1 root     root        23720 Aug 17  2015 bin/basename
-rwxr-xr-x   1 root     root       906152 Aug 17  2015 bin/bash
-rwxr-xr-x   1 root     root        45224 Aug 17  2015 bin/cat
-rwxr-xr-x   1 root     root       116824 Aug 17  2015 bin/cp
-rwxr-xr-x   1 root     root       109672 Aug 17  2015 bin/dash


Thanks & Regards,
Kirann Jadhav




No comments:

Post a Comment