How to assign disk-space to FreeBSD. 1. What is all this about -------------------------- After a general introduction, you will find explanations on what you need to do to assign space for FreeBSD on your disk(s). The program documented herein is the "sysinstall" program which lives on the install-disks. 1.1 What is the problem ------------------------ The problem is that disks are big. So big that people don't want to use them in one piece. With the latest disks being in the 9.0 Gbyte range (which for comparision is some six thousand floppydisks of the 1.4 Mb type) you cannot blame them. It has always been this way, and most computers have some way of "slicing" the disks into more manageble chunks. 1.2 A history-lesson --------------------- MS-DOS, when hard-disk support was slammed on back in the late eighties, didn't have this. What it had was a way to install Xenix and MS-DOS on the same disk (MicroSoft were in the UNIX-business once, remember ?). In the first sector on the disk, was a piece of "boot-code" and a table with four entries. Each of those entries pointed at a slice of the disk, and one of them was marked "active". The machine would boot by reading the first sector into RAM, and jump to it. The small piece of boot-code would look at the table and decide which OS was to be booted by looking for the "active" flag, load the first sector of that slice of the disk and jump to it. Later of course, they realized that disks could be bigger than the 32Mb the FAT-12 "filesystem" 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, it had another MBR in it, so now suddenly 5 slices could be availabel to MS-DOS, later the made the Secondary MBR recursive, and thereby effectively avoided any number limit. Of course you can still only have the 26 slices in MSDOS because they use "drive-letters". 1.3 What FreeBSD does ---------------------- FreeBSD has, like any other UNIX, a concept of "partitions". There is no difference between a slice and a partition as such, but we use the two words to distinguish between the 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 is the rule-set that FreeBSD uses: A: FreeBSD always has a MBR-slice with type 0xa5. This means that there should always be a MBR-record, even in the case where FreeBSD occupies the entire disk. B: The FreeBSD-slice contains the FreeBSD-disklabel in the second sector. 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 a artificially created FreeBSD-disklabel. Therefore, to get FreeBSD onto your disk, you need to do the following: 1. Make a MBR-slice for FreeBSD (FDISK) 2. Partition the diskspace in the MBR-slice into partitions (DISKLABEL) 3. Assign mount-points to the partitions. (DISKLABEL) 2. 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. (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 used. (Q)uit -- will continue the installation process. 3. FDISK - how to make an MBR-slice ------------------------------------- There is some rules to follow everywhere, and the MBR is a potential mine- field. There is no way to really make sure that you have a valid MBR. It is very complicated to write a validation check for it, because there are no real rules. Even if you don't plan to have MSDOS on this disk, make a 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 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 -- Will launch you into this file. (D)elete -- Will delete a slice entirely. (E)dit -- Will allow you to edit a slice. It will ask how many megabytes you want to assign to this slice, and will suggest the maximum possible as default. It might say zero, even though there is disk-space available, then you need to delete and recreate the other partitions to get the puzzle solved. It will then ask you what type to give the slice, and the default here is 0xa5, which is a FreeBSD slice. You can enter any other number here too, which can be useful as a placeholder. Finally it will ask you about the "boot-flag", 0x80 means "boot from this" and anything else means "don't". If you specified a FreeBSD slice, any existing slices witht 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. (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. 4. Disklabel - How to divide the FreeBSD-slice. ------------------------------------------------ (H)elp -- Will launch you into this file. (S)ize -- Will resize a partition for you, it will suggest as default the maximum amount of diskspace it can find. This algorithm isn't too smart so it might say zero, even though there is diskspace available. If it does, delete and resize the other partitions. (M)ountpoint -- Here you assign where the filesystem in a partition is to be mounted. 'b' partitions will always be made into "swap" partitions. (D)elete -- Will delete a partition. (R)eread -- Is a 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. 5. Some hints on diskspace needed ---------------------------------- 5.1 Swapspace -------------- Always assign at least as much diskspace to swap as you have RAM in the machine. If you expect to run X11 (XFree86) on the machine, twice that amount. 5.2 Filesystems ---------------- 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$