Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How to put /etc on separate partition? Obviously i can't do that by editing /etc/fstab like i did with /home, because... it's in /etc. I want /etc and /home on one partition (sda7), and the rest on the other (sda6). I guess /etc must be symlink to /mnt/part2/etc (/mnt/part2 being mount point of sda7), and same with /home. But how to tell the system to mount part2 without access to fstab?

I'm using Arch Linux x64, if that helps.

share|improve this question
2  
You must make your own kernel patched in way that it will automount your etc before init. Or you could make minimal bin dev etc lib proc sysdisk with minimal libraries / utilities (sh, mount and few libs). Will easily fit under 1MB... btw. this is somewhat same as asking about how to build house without walls, you can do that but it is mostly useless and it will be hard to add walls afterwards. –  Sampo Sarrala May 30 '13 at 19:23
    
I just learned that it's pretty much undoable. But not because of Linux - because of systemd. Gonna get back to this when I'll have full week free for switching from systemd to something else. Thank you all guys for your support. And inb4: you say it's pointless. I say, maybe, but this is the reason I have Linux in the first place - to have fun while messing with it! –  Xirdus May 30 '13 at 20:05
    
use lvm and don't put /etc on a different partition –  Ulrich Dangel May 30 '13 at 20:12
    
But more seriously, dude, don't try this unless you really, really, really know what you're doing because one mistake will likely render your system unbootable. More to the point, /etc will rarely exceed a couple dozen megabytes at most unless you're doing something incredibly stupid elsewhere down the line, so it literally fits into a hollow tooth. Keep it with / like absolutely everyone does. –  Shadur May 31 '13 at 9:59
    
@Xirdus Again,the same thing we said about writing a kernel patch would also apply to systemd -- and it still is a bad idea. –  Shadur Jun 1 '13 at 14:46
add comment

5 Answers 5

One of the first things a linux system is doing is mounting all file systems to the correct mountpoint in order to let all other parts of the system find their files.

The root file system is usually given on the kernel command line. It will mount this file system and look in /etc/fstab for all the other mount points.

If you really want to do anything weird before this happens you can use the initrd for those kind of setup.

share|improve this answer
    
+1 for weird... –  Hauke Laging May 30 '13 at 19:01
    
+1 for the initrd as correct answer –  Bananguin May 30 '13 at 20:01
add comment

The simple answer is you don't. /etc is where all the configuration stuff is: how can the system operate if it doesn't know where to find it's configurations? Why would you even want to?

share|improve this answer
1  
This is right. Any directory that must exist at the early stages of boot must be part of /. –  jordanm May 30 '13 at 18:43
    
If I wanted something to be undoable, I would use Windows. –  Xirdus May 30 '13 at 19:28
2  
*nix aren't there to give free reign to stupidity –  Bananguin May 30 '13 at 20:00
    
@xirdus There's "undoable" and there's "very hard to do because anyone who could make it easy to do knows it's a really bloody stupid idea". –  Shadur May 31 '13 at 10:02
add comment

I want /etc and /home on one partition

No you don't. It's like asking to have your brain transplanted to your knee :-) Whatever your problem is, making /etc a separate partition or merging it with /home is not the solution. What is the actual problem you want to solve?

share|improve this answer
2  
+1 for asking the important question of what he's trying to accomplish. –  Shadur May 31 '13 at 10:07
add comment

Not a straight up answer, but it may help:

The directory /etc stores the configuration for your operating system, therefore it should be considered a good idea to have your configuration with your operating system, that is on the same partition. To keep a sensible backup or maybe even share configurations, you could use git:

  • create a git repository from your /etc and clone/put it to whereever you want to store it
  • write an init script which does a git pull on "start" to get the most recent version from that special partition into /etc
  • put the script right after said partition is mounted in your bootup order, somewhere in runlevel S
  • have the script do a git commit and git push on shutdown/reboot to save your current configuration

Two advantages:

  1. when something breaks you will always have your configuration where the OS expects it to be
  2. you will have versioning and can revert and debig your configurations if you messed up
share|improve this answer
add comment

This is a terrible, terrible idea, and I can't honestly think of a single situation where it'd even be desirable.

However, if you really want to do this, your best bet would be to write a kernel patch to make it take a second argument similar to root=/dev/sda1 that lets you specify etc=/dev/sda2 as well, then have it try to mount /etc from there after mounting root and before attempting to execute init.

Note that any single mistake at this point would render your entire system unbootable unless you had the sanity to set up a safe fallback /etc on the root partition.

share|improve this answer
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.