Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This seems like a chicken-and-egg problem.

Inside the /etc/fstab file on the root partition, can I specify a different partition to mount at the /etc mount-point, such as:

/dev/sda6 /etc defaults 0 0  

Could this cause any problems?
Assume that I have some sensible contents on the new /etc , including the identical fstab and proper init and rc directories.

As a slight rephrasing of the question: What is the order of operations of booting?
Is /etc/fstab checked first for mounting drives before the rest of init.d scripts are run?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

This is a terrible idea. You should not and can not put /etc on a different partition from /. The kernel searches for /etc/fstab and a bunch of other configuration files as it boots from /. If /etc was on a different, as-yet unknown partition, how would the kernel find /etc/fstab to mount it?

share|improve this answer
    
The kernel does not use /etc/fstab for anything. It's the initramfs that mounts / (and often /usr), and init running from / mounts the rest. –  grawity Jun 1 '13 at 17:30
    
@grawity - that's true, I was trying to be quick in my reply. I was just using the word "kernel" to refer to "the general startup process." Thanks for clarifying. –  MattDMo Jun 1 '13 at 17:34
add comment

Sounds like you are talking about Debian.

This tells you everything if you have it using the traditional init system. Specifically:

The "/sbin/init" program is executed as the first program and performs the main boot process. The Debian normally uses the traditional sysvinit scheme with the sysv-rc package. See init(8), inittab(5), and "/usr/share/doc/sysv-rc/README.runlevels.gz" for the exact explanation. This main boot process essentially goes through the following.

  • The Debian system goes into runlevel N (none) to initialize the system by following the "/etc/inittab" description.

  • The Debian system goes into runlevel S to initialize the system under the single-user mode to complete hardware initialization etc.

  • The Debian system goes into one of the specified multi-user runlevels (2 to 5) to start the system services.

What happens per runlevel is that everything in /etc/rcX.d is executed, in alphabetical order, where X is the run level.

So, if you cd /etc/rcS.d, you will see a bunch of symlinks to /etc/init.d, that begin with a number. The number is there to determine the order. The ones beginning with S are executed when the run level is entered, and the ones beginning with K are executed when the run level is exited. Runlevel "S" is just used for initialization so there are no K links there.

Tread with caution here if you modify or rename anything. Make sure you test your scripts before subjecting yourself to a boot process.

Ok, going to try to actually answer the question now, with the above information as necessary background.

Under Debian the /etc/rc.S/S11mountall.sh is where the crucial "mount everything in fstab" happens. However, fstab is consulted to mount the root filesystem at /etc/rc.S/S07checkroot.sh.

If you use fstab to automount a new /etc, everthing in /etc/rc.S/S12* and higher will then be using the /etc on your "overlay" volume. However, you need a valid /etc/fstab on the root volume at that time beforehand.

Other things that /etc is consulted for include /etc/hostname, possibly some stuff related to udev (which is extremely important). You need to look at all the scripts from /etc/rc.S/S11* and lower to know exactly. If you really want no /etc at all until it is mounted from an external partition you are looking at modifying these scripts. It's probably not going to be as simple as switching the order of /etc/rc.S/S12mountall.sh to, for example /etc/rc.S/S00mountall.sh, but you possibly could add a new script that brings in /etc from an external partition earlier.

You can use the Linux mount --bind command to mount the root volume's original /etc somewhere (like /etc_from_rootfs) to copy it over when you make changes to fstab or other files that are consulted before /etc/rc.S/S12mountall.sh.

The Linux kernel does not do what Windows does, which is to use and require the presence of the registry before and during boot. The kernel itself will boot fine (but not terribly useably in 99% of instances) with no /etc, but it's up to userspace programs called after (starting with init), which then look at /etc, to get a decent user environment ready.

Sound complicated? It is, which is why listening to @MattDMo is likely prudent.

share|improve this answer
    
This is informative, but doesn't really address my question. –  Josh Jun 1 '13 at 13:31
    
Haha, now that I re-read it, it didn't, but hopefully it explained how the order of boot operations are determined under Debian and where to go to change what it does, which is very customizable. –  ultrasawblade Jun 1 '13 at 16:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.