Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Absolute BSD - The Ultimate Guide To FreeBSD (2002).pdf
Скачиваний:
25
Добавлен:
17.08.2013
Размер:
8.15 Mб
Скачать

short answer is, "it depends on the system." General wisdom says that you should have at least twice as much swap as you have physical memory. This isn't a bad rule, so long as you understand that it's very general. More won't hurt. Less might, if your system runs out of RAM. FreeBSD's virtual memory system assumes that you have at least twice your physical memory in swap space, and makes certain choices and optimizations based on that assumption.

It's difficult to add swap space when you add memory because this is a disk partition, after all. To change it you'd have to resize the partition—always a bit risky! As a general rule, try to create at least twice as much swap as you think you will have memory. If your system currently has 128MB of RAM, but you expect to increase it to 1GB, use 2GB of swap space.

Swap Splitting

If you have multiple disks, you can vastly improve the efficiency of your swap space by splitting it among multiple drives. Put the first swap on the second−outermost partition of your boot drive (the one with the root partition), and other swaps on the outermost partition of the other drives. (This works well for up to four partitions on four drives; if you create more than four swap partitions, the partitions after the first four will be used as optimally as the first four.)

For swap−space splitting to work best, however, the disks must be SCSI. If you have IDE drives, the drives need to be on different IDE controllers. Remember, each IDE controller splits its total data throughput among all the connected hard drives. If you have two hard drives on the same IDE controller, and you're accessing both simultaneously, each disk will only be half as fast. The major bottleneck in using swap space is data throughput speed, so you won't gain anything.

If you split your swap space among multiple drives, create partitions that are roughly the same size. FreeBSD has some optimizations for four swap partitions.

Four swap partitions leads to a conflicting problem, however. Upon a system crash, FreeBSD can write a copy of its physical memory image to a swap partition. This allows a developer to try to debug and fix whatever caused the crash.To dump a memory image, however, at least one swap partition must be at least the same size as the system's physical memory. If you have four swap partitions, each as large as the system's physical memory, you'll wind up with four times as much swap as physical memory. That's a lot of swap, especially on modern systems. That's even twice the standard "twice−physical−memory" rule of thumb. Extra swap won't hurt, mind you, and disk space is very cheap these days. If you really need your swap, you'll have it. If you find you're continually using swap, you'll want to buy more RAM anyway.

Once you decide how much swap space to allocate, create a partition by pressing C. Enter the size you want—for example, for a 1,000MB swap partition you would enter 1000m. When the installer asks if you want to create a swap partition or a filesystem, choose "Swap".

/var, /usr, and /home

The next step is to create the /var partition, which holds rapidly changing data, such as log files, databases, mail spools, and the like. If your system will have a lot of logs or mail files, this partition might very well need to be 1GB or more. On a small server, I'll frequently make this 20 percent of the remaining disk space. On a mail server, I'll kick that up to 70 percent or more.

The /usr partition holds the operating system programs, source code, and other little details like that. Many people use the rest of their disk for the /usr partition; it's frequently the most populated.

26