freebsd-skq/share/FAQ/diskspace.FAQ
1995-01-03 15:54:08 +00:00

268 lines
12 KiB
Plaintext

How to assign disk space to FreeBSD.
$Id$
1.0 Getting started.
---------------------
After a general introduction, you will find some explanation on what you
need to do to assign space to FreeBSD on your disk(s). This is done
through the "sysinstall" program, which lives on the inital boot floppy.
Those already expert with PCs may wish to skip ahead to section 1.2, the
rest of you may (or may not) enjoy the brief history lesson.
1.1 The ins and outs of allocating disk storage on your PC.
------------------------------------------------------------
Modern hard disk drives are now getting big enough that people don't want
to allocate all of one to just one operating system anymore, especially
given the increasing size of disk drives (the latest 9.0 Gbyte models
holding the equivalent of some six thousand 1.44MB floppies!) and the
virtual explosion of operating system options available for the PC. To
solve this problem, IBM came up with a scheme for "slicing" the disks
into more manageable chunks, or partitions. It works, but only just.
To better understand why, first a brief bit of history:
MS-DOS, when hard disk support was unceremoniously grafted on back in the
late eighties, didn't have such "slices". What it had was a way to install
Xenix and MS-DOS on the same disk (Remember when Microsoft were in the UNIX
business?).
In the first sector on the disk was a piece of "primary boot code" and a
table with four entries. Each of those entries pointed at an arbitrary
slice of the disk, with one of them was marked "active". The machine would
boot by reading the first sector containing the boot code into RAM and then
jumping to it. The job of this small piece of boot code was to look at
the 4 entry table and decide which OS was to be booted by looking
for the "active" flag. It would go and load the first sector of that slice
of the disk into RAM and then and jump to it in turn. This bit of boot
code was called the "secondary boot", and could be specific to a given
operating system. The primary boot code and 4-entry table is known
as the Master Boot Record, or MBR, and is very important to the proper
operation of your PC! We will discuss the MBR in more detail later.
It was later realized, with the hindsight that IBM is famous for, that disks
could be bigger than the 32Mb that the early DOS FAT-12 file system could
handle, so they added a kludge: They had two MSDOS slices, a "Primary" and
a "Secondary". The primary could still only be 32Mb, but the Secondary had
no size limit. And the trick was that the secondary had ANOTHER "table
entry" so that now suddenly up to 5 slices could be available to MS-DOS.
The Secondary boot record was later made recursive, thus effectively
avoiding any fixed limit. Of course, they were still stuck with a maximum
of 26 slices given the use of "drive letters" in DOS. They also reserved
only 10 bits for cylinder addressing, limiting DOS to being able to address
a maximum of 1024 cylinders (and cause of the dreaded "cylinder translation"
kludges, the misconfiguration of which many users have seen as the notorious
"Missing Operating System" message). Yes, truly DOS was and is an utterly
terrible operating system, which of course explains its amazing degree of
success. Anyway, this all brings us up to today, which is where FreeBSD
comes in:
1.2 What FreeBSD does
----------------------
FreeBSD has, like any other UNIX-like operating system, the concept of
"partitions." Partitions are used to implement its own "slicing"
abstraction, and although there is no real difference between a slice and a
partition as such, we use the two words to distinguish between these two
different levels of slicing.
The result is that we have a two-tier structure on the disk:
+-----------+
| MBR-table |
+-----------+ +---------+
| Slice 1 | -----> | MSDOS |
+-----------+ +---------+
| Slice 2 |
+-----------+ +-------------------+
| Slice 3 | -----> | FreeBSD-disklabel |
+-----------+ +-------------------+ +-----------------+
| Slice 4 | | Partition A | -----> | Root-filesystem |
+-----------+ +-------------------+ +-----------------+
| Partition B | ---
+-------------------+ \ +----------------+
| Partition C | --> | swap-partition |
+-------------------+ +----------------+
| ... |
Here are the rules that FreeBSD plays by:
A: FreeBSD always has an MBR slice with type 0xa5 (each of the 4 slices can
also have a unique integer identifier so you can tell your DOS slices
from your FreeBSD slices from your Linux slices, etc). This means that
there should always be an MBR record, even in the case where FreeBSD
occupies the entire disk.
B: The FreeBSD slice contains the FreeBSD disklabel in the second sector
(remember, the first sector contains the secondary boot code for FreeBSD,
which is what prints that FreeBSD prompt at you when you first boot
FreeBSD from a floppy or hard disk).
C: The 'C' partition in the FreeBSD disklabel corresponds to the entire
FreeBSD slice.
D: The 'D' partition corresponds to the entire physical disk.
E: Should a disk not have a FreeBSD slice (because there simply is no
FreeBSD on it anywhere), then the MBR slices are mapped into partitions
'E' to 'H' of an artificially created FreeBSD disklabel. This is useful
for getting at DOS-only disks.
Therefore, to get FreeBSD onto your disk, you need to do the following:
Step FreeBSD utility
------------------------------------------------------------ ---------------
1. Make an MBR slice for FreeBSD (FDISK)
2. Partition the diskspace in the MBR slice into partitions (DISKLABEL)
3. Assign mountpoints to the partitions. (DISKLABEL)
2. The sysinstall utility
--------------------------
The sysinstall utility is the program you first see when you boot
FreeBSD's install floppy. It is responsible for partitioning your
disk, creating an MBR slice for FreeBSD, setting up the disklabel
within that slice and creating filesystems for each FreeBSD partition
you create within that slice. It is composed of a number of screens.
These are described below.
2.1 The main screen
--------------------
The main screen shows you the current status, It shows you which disks
FreeBSD has found, how big they are and how much of it is assigned to
FreeBSD in a FreeBSD MBR slice. It also shows the partitions which have
had a mountpoint assigned to them (not necessarily FreeBSD partitions;
FreeBSD is perfectly capable of mounting DOS disks directly).
(H)elp -- shows you this file.
(F)disk -- enters the Fdisk editor, where you can change the MBR record.
This is what you want to use to assign some part of the disk to FreeBSD.
(D)isklabel -- enters the Disklabel editor, here you can change how the
FreeBSD slice is partitioned for FreeBSD.
(P)rocede -- will continue the installation process.
(Q)uit -- Go back to the entry screen.
2.2 FDISK - how to make an MBR slice
-------------------------------------
There are some rules to follow here since altering your MBR is a potential
minefield. There is really no way for the sysinstall program to genuinely
know that you have a valid MBR, so you have to be extra careful in what
you edit. Failure to do this properly can and will destroy your other
operating system entries!
Even if you don't plan to have MSDOS on a disk, make an MSDOS slice
using the MSDOS's FDISK.COM program. The reason for this is that if you
do it that way, you are 100% sure that FreeBSD will use the same number
of heads, sectors and cylinders as MSDOS would use. If you really don't
plan to have MSDOS on the disk, just (D)elete the slice in the FreeBSD's
(F)disk editor.
From the main screen press 'F' to enter the MBR editor. You have five
commands available:
(H)elp -- Shows you this file.
(D)elete -- Deletes a slice entirely.
(E)dit -- Allows you to edit a slice. It will ask how many megabytes
you want to assign to the slice, and will suggest the maximum possible
as a default. It might say zero, even though there is disk space
available, in which case you will probably need to delete and recreate the
other partitions to get it to see where the free space is.
It will then ask you what type to give the slice, for which the default is
0xa5 (a FreeBSD slice). You can enter any other number here too, which
can be useful as a placeholder for some other OS you plan to install
later. Finally, it will ask you about the "boot flag". 0x80 means "boot
from this" slice by default, and anything else means "don't".
If you specified a FreeBSD slice, any existing slices with the 0xa5
type will be reset to 0x00 "unused". FreeBSD only supports one slice
per disk for FreeBSD.
(R)eread -- This is your "undo" function. It will read the data of the
disk again, disposing of any changes you may have made.
(W)rite -- When you are satisfied with the data, this function will write
the new MBR to the disk.
(Q)uit -- Go back to the main screen.
2.3 Disklabel - How to divide up the FreeBSD slice.
----------------------------------------------------
The disklabel screen provides the following commands:
(H)elp -- Shows you this file.
(S)ize -- Resizes a partition for you, it will suggest as a default the
maximum amount of diskspace it can find. This algorithm isn't too smart
and may say zero, even though there is diskspace available. If it
does, delete and resize the other partitions.
(A)ssign -- Here you assign where the filesystem in a partition is to
be mounted. `b' partitions will always be made into "swap" partitions.
(D)elete -- Delete a partition.
(R)eread -- The undo function. It will reread the current disklabel from
the kernel.
(W)rite -- This will write the disklabel to the disk. You must always write
before you quit, otherwise your changes will be lost.
(Q)uit -- Exit back to the main screen.
2.4. Hints on partition sizing
-------------------------------
While it's impossible to say how much space you're going to want to
make your various partitions without knowing more about your intended
applicatins, here are some good rules of thumb to follow:
1. Root (/) should be at least 18MB, and probably no more than 50MB unless
you have some special reason for making your root partition really
large. Remember that the root filesystem is only supposed to contain
vital system files and little else.
2. Swap should be at least 2*memory. That is to say if you have 8MB of
memory, then you probably want 16MB of swap. Even more swap space
certainly doesn't hurt, if you can afford to allocate it, and you should
also think ahead a little to any planned memory upgrades you may have
in mind since increasing this later can be very painful!
If you're going to run the X Window System (XFree86), you should also
consider having a *minimum* of 16MB of swap, since X tends to really
use it up.
3. /usr can take up the rest of your disk, though some people like to create
extra partitions for user home directories and the like. Be sure to make
your /usr big enough to contain the system software (about 50MB) and
perhaps some of your own, unless you're going to use symbolic links to
point things like /usr/local (or /usr/src) somewhere else.
Here are some suggested filesystem names and sizes, just for reference:
Mountpoint Filesystem size
-------------------------------
/var 10Mb
/usr 50Mb
/ 16Mb
/usr/src 120Mb If you want to have the sources online
/usr/obj 100Mb If you want to compile all of them at one time
/usr/X11R6 50Mb If you load the entire XFree86 binary kit.
$Id: diskspace.FAQ,v 1.1 1995/01/03 15:48:36 gclarkii Exp $