From owner-freebsd-questions Tue May 2 16:24: 2 2000 Delivered-To: freebsd-questions@freebsd.org Received: from merganser.its.uu.se (merganser.its.uu.se [130.238.6.236]) by hub.freebsd.org (Postfix) with ESMTP id BE41D37BB36 for ; Tue, 2 May 2000 16:23:55 -0700 (PDT) (envelope-from ertr1013@student.csd.uu.se) Received: from regulus.student.UU.SE ([130.238.5.2]:42274 "HELO ertr1013.student.csd.uu.se") by merganser.its.uu.se with SMTP id ; Wed, 3 May 2000 01:23:37 +0200 Received: (qmail 3388 invoked by uid 1001); 2 May 2000 23:23:30 -0000 Date: Wed, 3 May 2000 01:23:29 +0200 From: Erik Trulsson To: FREEBSD-Questions Subject: Re: BSD Theology: swap, /var, /tmp and /usr/tmp Message-ID: <20000503012329.A3265@student.csd.uu.se> References: <390F41FD.5880279E@telinco.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <390F41FD.5880279E@telinco.net>; from Peter.McGarvey@telinco.net on Tue, May 02, 2000 at 10:00:45PM +0100 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tue, May 02, 2000 at 10:00:45PM +0100, Peter McGarvey wrote: > Theological problem this. Facts and Opinions welcome... > > Okay, I /think/ I know what I'm doing when I slice-up a disk for a > FreeBSD system... > > / -> 64MB > swap -> 2 * memory (rounded-up to the nearest MB) > /usr -> the remaining disk > > Once setup I link /var and /tmp to /usr/var and /usr/temp > > This is the way I've always done it, I'm quite happy doing it this way, > it works for me and I've never had any problems. Yeah, that is pretty much how I do it too. (Although swap might need to be adjusted up- or downwards depending on physical memory.) > > Fine, but now some upstart has asked me to set up a FreeBSD system with > the following.... > > / -> 5MB > swap 1 -> 512MB (equal to memory) > swap 2 -> 512MB > /var -> 2GB > /tmp -> 2GB > /usr -> remaining disk > > My first instinct is that the guy is barking mad (he is a Linux groupie > so... (and Linux does have a nasty habit of apropriating every entry in > the partition table)) The only problem that I see is that if swap1 and swap2 is on the same (physical) disk you might as well just make one big swap partition from them. Otherwise it looks fine too. > > However I've hit a snag - when it comes to FreeBSD partitions and slices > I know the HOW (and there is lot's of help on that), but I'm not too > sure of the WHY (and help here is lacking). > > 1. What I need is some rational reasoning why the way I do > things is right/wrong. > > 2. Why the way Linux man wants it is right/wrong. > > 3. Some info on the optimal size of swap > > 4. Where's the best place to put /var and /tmp > > Here is what I was told... > > On the issue of the 2 swap I was told two swap partitions were needed as > "we may need to turn one off as too much swap will slow the machine > down". I think that is bullshit. AFAIK the only negative effect of having a huge swap partition is that you can't use that diskspace for normal files. > > Furthermore, I was told the 2*memory rule is no longer valid "once the > physical memory has exceeded 64MB" Can this true? Have I needlessly > been waisting mt HDD space by making swap too big? The 2*memory rule is only a rule of thumb. If you have very little memory you want swap to be larger than 2*memory. (For example: If you only have 8MB in a box and you think that you sometimes will use as much as 30MB of memory you obviously want more than 16 MB memory.) The idea behind the 2*memory rule is basically that if you need to use more memory than twice your physical memory the system will have such lousy performance due to all the swapping that you really want more RAM. OTOH you don't want to make swap too small either since that will make programs fail due to lack of memory. 2*memory is usually a good compromise. Figure out how much memory you will at maximum use at any given time and then add some to that for safety and make sure that swap+RAM is that big. (If you have 512MB of physical RAM but rarely if ever use more than, say, 100MB of memory then you might not need any swap at all.) > > My thoughts were that swap was used as needed, when needed, and that > pages are not swapped to disk on a whim just because the swap space > existed (or perhaps this is how linux works so he's assuming FreeBSD > does it this way too). I think you are correct here. > > As for /var and /tmp why not link them to /usr/var and /usr/tmp. I can > understand putting them on physically seperate devices. But is it > strictly necissary to put them in their own slice? Is there a > performance benefit? or a is there some extra resiliency? > Two reasons for having them sepearate silces. First, as some others have noted, if one or both of them fill up (due to large temp files or lots of mail) you don't want to have the other slices affected by that. Second, if you for some reason have problems such that you get a corrupted filesystem in /var or /tmp you don't want that to affect anything else. Since there will be a lot of writes to /tmp (and /var/tmp) there is a good chance that if you have some filesystem problems (due to a power failure for example) it is quite likely to be with some file(s) in /tmp. With /tmp you can just wipe the whole directory at boottime without caring if there was some corrupted files in there. You can't do that with /usr. The only negative thing with seperate /tmp and /var slices is that you get decreased flexibility since one of the slices might fill up while there is plenty of space on the others. (So if you are tight on diskspace you might wish to have only a single slice mounted as / with /usr and /var (etc.) just being normal directories. This will give the least amount of wasted diskspace but any trouble with the file system will affect *all* files. > Whilst I'm at it what is the difference between /tmp and /usr/tmp. I've > always treated them a seperate entities - assuming linking /tmp to > /usr/tmp was a bad thing. Linux man maligned FreeBSD big time when he > found there were two temporary directories. I couldn't respond as I > didn't know - and I refused to descent to his level by insulting his > prefered OS. I think the difference is that /tmp is not guaranteed to keep its contents between reboots (it might be a memory file system, for example) while /var/tmp is supposed to keep its contents between reboots. Personally I have /tmp as a link to /var/tmp and haven't run into any problems (yet). > > Like I said this is mainly a theological problem. so all Facts and > Opinions welcome... > Not really a theological problem, more one of tastes and purposes with the system. What is good for your system at home might be bad for a big server and vice versa. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message