can '/var' and '/home' be on the same different partition from '/'?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
can '/var' and '/home' be on the same different partition from '/'?
it is one of those things that I have been wanting to know for some time but kept forgetting to ask. Or is it better to make a separate partition for each? if so, then why?
the reason I am asking the initial question is because I can't remember if there are any facilities to do this during a fresh install of the OS (Ubuntu in my case). I know that one can assign a directory to a partition during the installation wizard, but I don't know if one can do the same with two side by side directories on one partition. if this can be done then briefly, how is this done?
Everything comes from root ("/"). Therefore, it is possible to have /anything, i.e. /home, /var, and anything else be on the root partition. It is also possible for them to be on another partition or on another drive, altogether. Normally the installer will give you lots of options in the partitioning section, if you select "manual" or maybe "expert".
But I don't know how well your system would handle this or what your OS stores in var. I wouldn't recommend it, but you could try.
may be I should create a separate partition for each. I know what my system stores in /var (amongst other things that I don't know) and that is lots of downloaded packages that I would like to keep.
Everything comes from root ("/"). Therefore, it is possible to have /anything, i.e. /home, /var, and anything else be on the root partition. It is also possible for them to be on another partition or on another drive, altogether. Normally the installer will give you lots of options in the partitioning section, if you select "manual" or maybe "expert".
I always choose the manual partition option, never gone in 'expert' mode though. I set up my separate /storage partition that way but I can't remember seeing anything that may allow me to actually assign two directories to one partition this way. At the moment I am just asking this for future installations and if I may be want something that can't be done (or is just too hard) in this way. I will then use two partitions, it just makes it harder to guess a right size for '/' and '/var' and '/home'. atm these three are all on the same ('/') 12Gb partition, which is large enough for me as a total.
Have I misread you, then? Are you really asking if you can have, for example, a partition "hda1" which has "/" and everything else except "/var" and "/home" which are on "hda2"? I think you would have to use a pair of symlinks to accomplish this, and that would require opening up another virtual terminal (CTL-ALT-F1 or F2 or whatever) to do it manually - or waiting until after the install to do from a liveCD. What I think you would do would be to make some third directory on the partition, then put your two directories under that, then symlink those to the proper names in "/" so they're visible in the right place.
I.e:
/borkable is on /dev/hda2
/borkable/var symlinked to /var
/borkable/home symlinked to /home
I'm not sure why one would want to do this, though. It would depend on which two directories you wanted to put in there. It would be a pain in the ass, in any case, and probably a bit fragile. I wouldn't do it, unless there were some special circumstance, and I'd fix it as soon as possible.
Last edited by Quakeboy02; 05-19-2009 at 01:21 AM.
Thanks for your input Quakeboy02, that cleared things up a bit. I now know I should create two separate partitions, one for /home and one for /var. The other option with the symlinks seems far too complicated and as you say, a bit on the fragile side. The reason is practical; I have kubuntu and xubuntu on the same machine and I find myself constantly copying files across from one home to the other (thunderbird, firefox and few others). The same with updated packages, which are stored in /var, if one needs updating, so does the other which would mean double the downloads. I am trying to eliminate these inconveniences and it would also allow me to testdrive an other distro or upgrade a bit easier.
well, that's the idea anyway, so far it is just a brainwave but once I worked it out, I will set my system up in this manner in the not too distant future.
Quakeboy02, I think that mount --bind is more what wabbalee would want (as lumak pointed out). It was new to me, but it does sound interesting. I don't think I would set a system up using it by default (better to set partitions up from the start with a well thought out plan), but I could see the usefulness of being able to do it with an already built system a year or two later.
Thanks forrest, I've never seen that before, but this ("If the thing you want to link to is a mounted file system, you can use the "--bind" option of mount to create an unbreakable link.") makes me wonder if it would work for the OP, since it's not actually a "mounted file system" that he would want to create a link to, but a directory on another mounted filesystem. In any case, I gave you a thank-you.
Well, it is a mounted filesystem. That's why the link is "unbreakable". In order to get rid of it, you must first unmount it.
HTH
Forrest
I guess I don't understand, then. In my example, "/borkable" is the mounted filesystem, but the places we would want to link to are "/borkable/var" and "/borkable/home" (to meet the OP's needs) which are merely directories.
The way it would work (from my understanding) is you would create a /var partition (for example) with a /var/home directory. You would then mount /var as normal and /var/home to /home with the --bind option. Thus, /var and /home would be on the same physical partition, but the system would see /home as a separate location (I'm sure you could still access the files via /home or /var/home).
Since Linux 2.4.0 it is possible to remount part of the file hierarchy
somewhere else. The call is
mount --bind olddir newdir
After this call the same contents is accessible in two places. One can
also remount a single file (on a single file).
This call attaches only (part of) a single filesystem, not possible
submounts. The entire file hierarchy including submounts is attached a
second place using
mount --rbind olddir newdir
So, it looks like the article's reference to a "single filesystem" was just a "for instance", but not a limit of the --bind option.
So, it looks like you actually can do what you want to accomplish using the --bind option to the mount command. You might also look into UnionFS and AUFS, but I think "--bind" might be better for what you want.
it is one of those things that I have been wanting to know for some time but kept forgetting to ask. Or is it better to make a separate partition for each? if so, then why?
I realized I answered the second question but not the first.
On my system /var only takes up 75 MB of it's 500 MB partition.
If you are hosting an http or var server, you just have to make user that those directories... if on /var... are pointing to directories on /home.
At least on slackware /var is use for the default root webpage host directory, log files, persistent temporary program data, and the package management system. By my current use, even 500 MB is generous. It wouldn't hurt to make /var a logical partition for peace of mind that if you run a service that creates logs, that it won't fill up your / partition unexpectedly when it goes into a continuous error loop.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.