Wednesday, March 10, 2010

Why can't you mount /etc as a separate partition in Linux

When you start installation of Linux (say RHEL), during partitioning try to create a separate partition for /etc - the installer wont let you do that. Linux doesn't like some important partitions like /etc, /sbin to be mounted on a different partition - Question is why?

This can be answered in two steps:

1) /boot/grub/menu.lst has "kernel" line with parameter like "root=/dev/sda2"

During the boot up process the kernel needs to be told the device of the / partition. In the above example its /dev/sda2. There's no way to specify separately the device like /dev/sda1 or /dev/sda3 for /etc.

2) /sbin/init needs a file named /etc/inittab.

Once kernel is loaded, it executes the /sbin/init script. Now the man page for this script says "Its primary role is to create processes from a script stored in the file /etc/inittab".
Uptil the point of executing /sbin/init, the kernel knows device only of one partition i.e. "/" . So, hypothetically speaking, if there were no /etc (folder etc inside /), then init would not know where the inittab file is. As a result, the booting will fail.

In other words, if there was a way to tell the kernel or /sbin/init the device where /etc files are present, then we could have created a separate partition for /etc.


Note: When I mention that you can't mount /etc as a separate partition, I'm assuming that you're not interested in being anal about it. We all know programming/scripting language can be used to modify almost anything in Linux and make it deviate from its "normal" behaviour. Here's a blog on how you can actually make /etc mount on different partition http://power-of-linux.blogspot.com/2010/03/booting-with-etc-in-separate-partition.html

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home