Date: Wed, 3 May 2000 12:47:05 +0930 From: Greg Lehey <grog@lemis.com> To: Peter McGarvey <Peter.McGarvey@telinco.net> Cc: FREEBSD-Questions <freebsd-questions@FreeBSD.ORG> Subject: Re: BSD Theology: swap, /var, /tmp and /usr/tmp Message-ID: <20000503124705.E8284@freebie.lemis.com> In-Reply-To: <390F41FD.5880279E@telinco.net> References: <390F41FD.5880279E@telinco.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday, 2 May 2000 at 22:00:45 +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 That looks good to me. > 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. > > Fine, but now some upstart has asked me to set up a FreeBSD system with > the following.... > > / -> 5MB This is *far* too small. It also bears no relationship to anything that Linux recommends. Consider 30 MB an absolute minimum. Considering how generous he is with the next four partitions, this makes no sense at all. > swap 1 -> 512MB (equal to memory) > swap 2 -> 512MB This makes sense if you have them on two different disks. It makes no sense whatsoever if it's on one disk, as has already been commented on this thread. > /var -> 2GB > /tmp -> 2GB This could be right. But he needs a good reason for these values, otherwise he's only wasting space. In particular, why separate partitions for each? > /usr -> remaining disk OK. > 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)) I haven't seen that. > 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". This is nonsense, of course. > Furthermore, I was told the 2*memory rule is no longer valid "once > the physical memory has exceeded 64MB" Can this true? Not quite. It's not valid under 64 MB either. You need as much swap as you need, but calculating it is very difficult. It also relates to how much loss in performance you're prepared to accept. > Have I needlessly been waisting mt HDD space by making swap too big? It's difficult to say without knowing what you were doing. > 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). In fact, FreeBSD *does* swap dirty pages out even when memory isn't full. But it's done when the system is idle, so that if it suddenly needs more memory, it can just nuke the pages it has already swapped. But this shouldn't be a performance problem: on the contrary, it improves performance. > 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? No. But many people will cite overflows of the individual partitions. Of course, if there's one case where an overflow causes real problems, it's with /var or /tmp, so I don't think much of this reasoning. > Is there a performance benefit? No, on the contrary. > or a is there some extra resiliency? Well, only as stated. > 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've just checked. Linux uses both /tmp and /var/tmp. I suspect your client isn't too sure of his facts. So, what's the right thing to do? I've always been a proponent of "/, swap and /usr", but lately I've been rethinking. Here are some of the considerations: 1. / and /usr were originally separated because the drives used at the time were simply too small to take both. In those days, as the name suggests, /usr was left mainly for user programs. System V still often carries the complete system, including the kernel build environment, on /, which is correspondingly larger. 2. People carried on using this split after disks became larger. Part of this is traditional, like writing "return (0)" instead of "return 0" in C, part of it is because the root file system doesn't get written very often, so if you have a file system crash, you can probably still get / up. 3. As the system software increased, people started putting it in /usr, to the point where a third file system was added, with names like /u or /home. 4. Now that the complete system wasn't on /, we had problems in single user mode: a large number of programs weren't available, and we currently go to some trouble to decide whether a particular program should go into /bin or /usr/bin, or to /sbin or /usr/sbin. Programs in /bin and /sbin must be statically linked, because the dynamic libraries are in /usr/lib. In BSD, the /lib file system has died out altogether. With these considerations in mind, I installed a new system yesterday. This is a 750MHz Athlon with 256 MB of memory. The disk is a 20GB ata. This is how I partitioned: # df Filesystem 1048576-blocks Used Avail Capacity Mounted on /dev/ad0s1a 1984 738 1087 40% / /dev/ad0s1e 16490 640 14531 4% /home # pstat -s Device 1048576-blocks Used Avail Capacity Type /dev/ad0s1b 511 0 511 0% Interleaved In other words, the *entire* system, including /usr, is now in the root file system. There's not much in there which I write; /var is a link to /home/var, and /tmp will be (isn't quite yet) mfs. Mainly, /usr is just an extension of the system files, and has no user files in there at all. Everything that gets worked on is in /home. What about the sizes? I don't know yet. I've decided I have to move /usr/src and /usr/obj to /home, since a lot of writing takes place there, but I think that the main increase in size will come from additional packages installed in /usr/local. Even then, I expect /usr to end up with a significant amount of space left over. I'd be interested in any comments people have. Please remember to trim away the irrelevant parts of the reply. Greg -- When replying to this message, please copy the original recipients. For more information, see http://www.lemis.com/questions.html Finger grog@lemis.com for PGP public key See complete headers for address and phone numbers To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000503124705.E8284>