From: hedrick@geneva.rutgers.edu (Charles Hedrick)
Newsgroups: comp.os.linux
Subject: Re: Newbie partitioning question
Date: 10 Oct 92 01:01:49 GMT
Distribution: comp
Organization: Rutgers Univ., New Brunswick, N.J.

mcampbel@cs.ucf.edu (Mike Campbell ) writes:

>First, is it necessary to have a /root and /usr partition, or can they reside
>on the same one?

root and /usr can be on the same partition.  It's traditional to keep
a small root partition, and put most software on a separate /usr
partition.  But this wasn't ever required, and I'm not sure the
reasons it was done apply to typical Linux systems.  In a traditonal
Unix system root was more likely to get corrupted in a crash, and thus
by keeping root small you put fewer files at risk.  It's not so clear
that this is true of Linux.  I haven't lost a file system for quite
some time (back in the days of buggy file system code).  With a
single-user system, where I'm not running any daemons other than init,
update, and getty, file system corruption isn't really an issue.  Of
course some people use Linux for more complex or I/O intensive things
than I do.  They might want to think about this.

Rather at this point your partitioning is more likely to be dictated
by issues of disk space and backup.  Assuming you use the Minix file
system, which I recommend, you're limited to 64MB for each partition.
Thus you need to find a combination of things that will fit into
partitions of that size.  While I haven't done this, I could imagine
that someone might try to put things that don't change (e.g.  system
software) into one partition, so they only have to do regular backups
on the other one.  (SunOS and some other systems have taken this to
the limit.  /usr is designed to be mounted read-only.)

>Also swap space.  Is a swap file necessarily needed on a seperate partition?

You don't need swap space at all.  BSD (and I assume other systems)
requires you to have as much swap space as memory.  You don't start
gaining any additional virtual memory until your swap space exceeds
your physical memory (more or less -- of course the kernel takes some
space, so not all physical memory is really usable).  With Linux, you
don't start swapping until physical memory is full (more or less), so
all swap space is additional VM.  If you've got lots of memory, you
might well not need swap space at all.  

I don't recall whether Linus got swapping to a file to work, but in
general I would think performance would be better if you use a
separate partition.  I seem to recall that with recent versions
there's a limit of 16MB per swap area (or has that been fixed?)

>If I want a swap of 10 megs, should I re-partition the remaining 50 into
>something else?  What are the advantages of doing so  (or not?)

If you're using a partition for swap space, don't make it any bigger
than the amount of swap space you need, or you'll be wasting space.
So yes, put the other 50 MB in another partition and put a file system
on it.  When you swap to a partition, the whole partition gets
dedicated to swapping.  

If Linus has implemented it, there's an alternative: swapping to a
file.  In this case you don't need to do anything special when doing
the partitioning.  You'd just create a 10 MB file in a regular file
system and enable swapping to that file.  (Again: I don't know whether
this has been implemented yet.)  While nobody has reported performance
results, I would generally expect performance to be better when
swapping to a partition rather than a file, because you don't have to
go through the file system code, and the data is going to be stored
contiguously in a partition.  Swapping to a file does have a couple of
neat uses though.  (1) Suppose you know that 10 MB is normally enough
swap space, but now and then you have to run a big program.  You can
allocate a 10 MB partition for swapping, and then when you need to do
the big program create a swapping file.  The advantage is that you
only use disk space for swapping when you actually need it.  The
problem is that you have to make sure you keep enough free space that
you can actually create the swap file when you need it.  (2) If you
underestimate your need for swap space, you can always add a swap
file.  Even if you only want to swap to partitions, this can be a
useful temporary measure.  For the moment create a file and start
swapping to it.  Later, when you have time, repartition the disk to
give yourself a large enough swap partition.

Note by the way that you are not limited to 4 partitions, though with
a 120MB disk I doubt you'd want more than that.  Probably you'll want
two file systems, a swap partition, and possibly a small DOS file
system if you still need to use DOS.  But if you find that you need
more than 4, you can create a DOS "extended partition".  This takes
one of the 4 possible partitions and suballocates it into multiple
logical partitions.  Linux can use these logical partitions just like
a normal partition.  In fact my entire Linux system is sitting in
logical partitions.  I don't use any "real" partitions at all.
(Yes, you can boot from an extended partition, though it requires some
hackery.)  But that's probably an extreme case.