LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 05-18-2009, 10:13 PM   #1
wabbalee
Member
 
Registered: Oct 2006
Location: brisbane - australia
Distribution: ubuntu
Posts: 335

Rep: Reputation: 38
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?

thanks.
 
Old 05-18-2009, 10:21 PM   #2
lumak
Member
 
Registered: Aug 2008
Location: Phoenix
Distribution: Arch
Posts: 799
Blog Entries: 32

Rep: Reputation: 111Reputation: 111
I believe you could do a bind mount in the fstab

/home/sys/var /var none bind


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.
 
Old 05-18-2009, 11:10 PM   #3
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
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".
 
Old 05-18-2009, 11:19 PM   #4
wabbalee
Member
 
Registered: Oct 2006
Location: brisbane - australia
Distribution: ubuntu
Posts: 335

Original Poster
Rep: Reputation: 38
Quote:
I believe you could do a bind mount in the fstab

/home/sys/var /var none bind


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.

Last edited by wabbalee; 05-18-2009 at 11:21 PM.
 
Old 05-18-2009, 11:33 PM   #5
wabbalee
Member
 
Registered: Oct 2006
Location: brisbane - australia
Distribution: ubuntu
Posts: 335

Original Poster
Rep: Reputation: 38
Quote:
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.

thanks.
 
Old 05-19-2009, 01:18 AM   #6
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
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.
 
Old 05-19-2009, 09:54 AM   #7
wabbalee
Member
 
Registered: Oct 2006
Location: brisbane - australia
Distribution: ubuntu
Posts: 335

Original Poster
Rep: Reputation: 38
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.
 
Old 05-19-2009, 10:25 AM   #8
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
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.

Forrest
 
Old 05-19-2009, 01:50 PM   #9
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
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.
 
Old 05-19-2009, 01:56 PM   #10
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
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
 
Old 05-19-2009, 02:12 PM   #11
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
Quote:
Originally Posted by forrestt View Post
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.
 
Old 05-19-2009, 02:28 PM   #12
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
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).

Forrest
 
Old 05-19-2009, 02:31 PM   #13
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
OK, when all else fails, RTFM.

From TFM (man):
Quote:
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.
 
Old 05-19-2009, 03:08 PM   #14
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
To wabbalee:

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.
 
Old 05-20-2009, 11:21 PM   #15
lumak
Member
 
Registered: Aug 2008
Location: Phoenix
Distribution: Arch
Posts: 799
Blog Entries: 32

Rep: Reputation: 111Reputation: 111
Quote:
Originally Posted by wabbalee View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot write $(HOME).dmrc file home is on a seperate partition Person_1873 Linux - Newbie 5 12-07-2008 01:41 PM
I am creating a website Server what is the best partition for /var /root /home etc. RMLinux Linux - Newbie 3 12-01-2008 07:46 AM
8.10 partition size requirements for / /home/ /swap /var /usr going from 8.04 Ubuntu Thane Ubuntu 10 11-30-2008 07:27 PM
change $HOME var paul_mat Linux - Networking 3 05-01-2006 09:57 PM
moving /home /root & /var to new partition CrashedAgain Linux - General 8 11-24-2005 10:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration