Mounting directories under '/' to different mount points?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Mounting directories under '/' to different mount points?
I want to create two directories under '/' - 'e' and 'c'. Under 'c' i want to mount all directories except 'home, and under 'e' i want to mount 'home' directory. So, i want my root directoy to look like this:
you got a figure out partitions, and mount points, and maybe even bind if you want everything mounted separately.
which is not necessarily needed, in linux it mounts / (root) which is everything on one partition. Like in Windows everything gets C drive and then we have what is called the 'tree' with all of its 'branches that have leafs'. Windows got that too.
which would look like this
Code:
C would be
sda1 / (with everything system side on it)
D or E would be this
sda2 /home (everything users stuff side)
No, you can't do that. While you could mount a drive at /c/, and move all of your /etc, /var, etc directories into it, it'll all come crashing down as soon as an application tries to access something in its normal location, since it's no longer there. You could symlink these directories back into place, so /etc is actually a symlink that points to /c/etc, for example, but you'll never be able to get an ls of / to look like what you posted. It would have /c, /e, as well as symlinks or bind mounts or something similar for all of the other directories that are supposed to be there.
I think we should back up a bit and re-visit what you're actually trying to accomplish and why. I imagine, whatever it is, that there is a much MUCH better way of going about it.
Last edited by suicidaleggroll; 07-06-2017 at 02:38 PM.
Directories /etc and /usr are examples of directories that either need to part of the root filesystem or have arrangements to be mounted early in the boot process when the root filesystem gets mounted. In modern systems, /dev is a special type of tmpfs and only the mount point directory exists on disk. The point of moving that mount point, or other mount points like the one for cdrom, escapes me.
Yes it can be done, given enough time and effort. But other than making life difficult for yourself, just what are you trying to accomplish?
Yes. Just define your mode of mounting the "/" to "/c", modify it in many ways "--remount", "--make-shared", "--make-slave", etc. and this works for any purpose, except... do not boot into the secondary mount-point of "/" (viz-- /c ) as things can go awry as warned above by suicidaleggroll, if you want to boot into it use "--bind" switch.
I want to create two directories under '/' - 'e' and 'c'. Under 'c' i want to mount all directories except 'home, and under 'e' i want to mount 'home' directory. So, i want my root directoy to look like this:
1. If you are willing to break all support updates for your system
2. If you are willing to lose the ability to boot.
It can work...
If you are doing your own distribution (good luck with getting help)
Rather than doing that, you could set up a chroot jail environment that is set up that way.
This isolates your environment from that which is supportable. When you have realized that you will have to rebuild every application to run with that environment you can easily revert to a working environment.
I agree with the thoughts that just because a thing is possible, does not mean it is worthy.
There used to be a rotate root concept, either specific to one distribution or a general thing, but I cannot find any references. Either case this was during startup and it was necessary to remap the specific physical resource to become root, thereupon root would still be named "/".
Meanwhile I agree that you can remount and have in fact done a remount of "/" unintentionally; such as I was trying to remount /tmp, /var, and /log but mis-typed the command. The end result was no prompt and slowly repeating complaints that something was inaccessible or not found. At that point I looked at my last typed command and realized I had obliterated the path to my RFS. Thankfully things like mounts are ephemeral things and a reboot took care of it ... excepting the various things I had open and unsaved.
Which brings this back to BW-userx's question in post #2, "Why do you want to do this?"
It is used during boot to exchange the root mount from being the ramfs from the initrd to the identified real root filesystem; just before releasing the memory occupied by the ramfs.
The expectation is that the directory structure beneath that mount point will still permit the identification of init (expected to be in /sbin/init). So to change that you also have to change the initrd...
That is why my objections to this useless change exist.
The applications used during boot are expected to be in /bin, /sbin, and the configuration files to be in /etc. So that requires even more changes - and changes to the binaries to change their use of /etc at a minimum. Then you have to include in that rebuild udev (it expects things in /etc for configuration, and /dev; changing the configuration also requires rewriting all the udev rules).
Changing all of that will tend to require rebuilding the initrd in the same way.
And changing the location of init also means you have change the kernels reference to init - so you have to rebuild the kernel as well.
Then there is everything that refers to network configuration... and don't forget login.
Then there is all the programming support documentation and tools, along with changing many of the include files because they also contain some configuration references like the terminfo tables, man page references, /var,/proc,/dev,/tmp,/etc references...
At this point, you have your own distribution, incompatible with any other software too.
Yes, thank you for the memory assist jpollard. It has been years with that one for me.
And for many of the reasons you cite is why I totally agree. Things like ls, cd, cat, more, ps, ... all that stuff, many are located in the /bin, /sbin, or other similar directories and once you rip / away, it all is not longer capable of being referenced. Hence my former experience of the machine doing the equivalent of "Uh ... Uh ..."
there is a Linux distro out there that I seen on distrowatch a while back that puts just about everything into one pile (directory) so one does not have to go looking for it in separate directories.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.