Wednesday, August 7, 2013

How to Kill the Init Process (And recover from It)

What happens when we kill the init process?

Question 1 : Why the hell would you kill an init process?
Answer 1: To know what happens if someone,anyone tries to kill the init process
Answer 2: Inquisitiveness (My case!)

To see for yourself, please try the following:

1. Open a terminal
2. Type kill -9 [pid of init process]

The pid (or process id) of the init process can easily be obtained using the

top

command, or the following command

ps -afx | grep init

I think it is 1 for all the processes, but try the above two commands just to be sure.

Now, after killing the init process, reboot your system.

Rebooting will cause a kernel panic!

Cause :

Kernel panics because it tries to initialize the init process after initializing the kernel processes. However, it is unable to do so (because during previous shutdown, init process did not comprehensively free all user applications, which would lead to clearing all kernel data structures)

Note that some of these data structures would be maintained in the swap space (in the disk), also, the super block (in your bootable device i.e. disk) may get corrupted due to improper shutdown in the previous boot.  

Solution to rectify this problem :



In my case, using a live USB, I performed a memory check and a disk check. Ubuntu Live USB showed me two files in the superblock in the bootable device [HDD /dev/sda8] had been corrupted. In order to rectify these files, I did the following

sudo fsck /dev/sda8

A simple filesystem check was sufficient to recover my bootable device, without any data loss.

To check my file systems normal operation, I mounted the filesystem (/dev/sda8) using the Live USB itself. And it worked like a charm.

Rebooted the system, removed the USB, and my HDD was able to successfully boot my laptop. :)


No comments:

Post a Comment