This is to all the Linux newbies out there who mess around with the Linux system and end up crashing. For starters, it's good to mess around as this is the only way you get to learn, make mistakes and sweat as you work them out. So it's a Friday afternoon and I thought of doing a system update on my Kali rolling distro (in case you forgot, Kali is part of the Debian family). So I fired up my script;
#sudo apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y
The command worked perfectly without any issues and after a short while my Kali was fully upgraded. (Now, am sure you are wondering whether I wrote this article just to show you how to update your Linux, am pretty sure you would do that in your sleep...so keep reading). Due to my Friday laziness, I decided to shut down my machine using a shortcut.
#sudo init 0
Within a few seconds, the machine was off and I safely tacked it into my backpack. Upon arriving home, after some few house chores, (the bachelors understand this...) I decided to fire up my machine and do some tasks before calling it a night, only for the boot process to drop at the BusyBox shell opening a prompt at the initramfs. Waah!! the nightmare of every Linux admin; a system crash. So before we continue let me tell you a little about the init command.
overview of init
init in full means initialize. when the init command is called, it becomes the parent or grandparent of all the processes running on your Linux system. The first thing init does when the kernel loads, is reading its initialization file. This instructs init to read an initial configuration script for the environment, which sets the path, starts swapping, checks the file systems, and so on. This step takes care of everything that your system needs to have done at system initialization: setting the clock, initializing serial ports and so forth. Then init continues to read the file, which describes how the system should be set up in each run level and sets the default run level. A run level is a configuration of processes. Now there are a couple run levels on Linux systems but the most common is
init 0 - This halts the systems (dangerous, sometimes causes files to crash)
init 1 - This command sets the Linux system into single-user mode
init 6 - This command reboots the Linux system (it is safe to use)
[FMI; Google init command]
Now the initramfs in full means Initial Random-Access-Memory File Systems. This crash occurs when the system can not read files on /etc/fstab that enables the kernel to mount the Operating System. The only way to solve this problem is by running a file check-up command to correct any error that may have been caused when the system was halted. You do this by typing;
(initramfs)# fsck -a /dev/sda5
[replace sda5 with your root drive] [-a enables the command to correct any errors detected]. After the File System check (fsck -a) is complete, run the reboot command and your Linux system will boot back to normal as if it never almost gave you a heart attack.
As I said, keep messing around, it is the only way to learn.
Comments
Post a Comment