个人工具

UbuntuHelp:DiskSpace

来自Ubuntu中文

跳转至: 导航, 搜索


The goal of this page is to offer advice and strategy on partitioning a Linux system.

Partitioning Strategies

Simple

The easiest partitioning scheme is simply a root partition and a swap partition.

Name Size
`swap` size of RAM
`/` the rest of the disk

Swap

Modern operating systems have virtual memory systems that allow the system to have more memory than the amount of RAM in the system, amongst other things. The hard disk is used to realize this extra memory, known as swap. In Linux, it is possible to have a swap file, swap partition, a combination of either, or no swap at all. Swap partitions are slightly faster than files, and are more traditional in a Linux system. The advantage of swap files is that they can be created on the fly. Windows uses a swap-file, often called "pagefile.sys" which is often one of the main causes of slowdowns in a Windows system after a few months/weeks use. See SwapFaq. A good rule of thumb is to make your swap partition slightly larger than the size of your RAM. If you need more memory than that, it is much better to buy more RAM. Slightly over 2xRam ensures that when you upgrade your Ram then you will probably still have enough Swap. Swap is much slower than RAM, and you will notice when the system starts dipping into swap when there is not enough RAM to satisfy the demand for memory. Though it is slow, swap is still important, because the kernel puts data from RAM that is not being used at the moment into Swap so that RAM can be used for other things like disk caching. Also the contents of Ram are copied into Swap when closing down to sleep or hibernate modes. This is the main reason Swap needs to be slightly larger than Ram, especially in anything portable such as devices between a phone/hand-held up to full laptop. Not all areas of a hard drive are equal. Generally, the cylinders that are on the edge of the platter are faster than the ones near the spindle, about twice as fast! How to determine where the a given region is physically located on the platter is another matter. In my experience, the beginning of the drive corresponds to the outer edge. Thus it is probably best to put swap at the beginning of the drive. Alternatively, it could be argued that placing swap in the middle will reduce seek times if the disk is seeking all over. The only way to know is to try it in several places and do some benchmarking. The best way is to realize that you will probably not notice the difference and not waste time and effort on such things. If you have several physical disks, put a portion of swap on each or put the entire swap on a separate drive from the / partition. The kernel will automatically use the different swap partitions in parallel, thus you will see a nearly linear increase in throughput performance.

Separate /home

It is very prudent to put `/home` on it's own partition. All of your data and settings goes into `/home`. You can be confident that your data will be safe even if you decide to reinstall the system, or install a new version of Ubuntu. Also, you could use an "Ntfs" (NT !FileSystem) or "Fat" (File Allocation Table) file-system in order to share your data between Ubuntu and Windows (it is not a good idea to use Ntfs or Fat for the root file-system). It is usually better to make a separate Ntfs partition from the `/home` because Ntfs & Fat have trouble with fragmentation and permissions. If space is very limited then putting your /home onto an Ntfs can be worth the risk. If you install another Linux alongside Ubuntu the `/home` partition (and swap) can be shared amongst them.

Name Size
`swap` size of RAM
`/` at least 5GB, at most 15 GB
`/home` the rest of the disk

Separate /boot

If you want to install more than one Linux distribution, it can be easier to make a dedicated `/boot` partition. That way, all of the data needed to boot the system will be on one partition, and you will have to jump through fewer hoops when configuring the bootloader (GrubHowto). As of 7.04, a kernel image is about 15-20 MB, and you need enough space for about 3 of them (current, old, and space for a new one).

Name Size
`swap` size of RAM
`/` at least 5GB, at most 15 GB
`/boot` at least 100 MB, at most 250 MB
`/home` the rest of the disk

More Complex Schemes

Work in progress.

Space Requirements

This information was taken from forum/installation/DiskSpace. The original article was last edited on 2006-05-28, thus it is probably out of date and should be verified.

Absolute Requirements

The required disk space for an out-of-the-box Ubuntu installation is said to be 15 Gb. However, that does not take into account the space needed for a file-system or a swap partition. It is more realistic to give yourself a little bit more than 15 Gb of space. Give yourself 15-25 GB to have some space left for actually doing things. If your file-system is full to the brim, you will feel some performance loss. A certain percentage of an ext3 file-system is dedicated to root, as a way of preventing a rogue process from filling the disk to the point that the system is unusable. This dedicated portion is 5% by default. Also, the anti-fragmentation strategies used by Linux file-systems require that the disk is not nearly full. A rule of thumb is to keep them less than 90% full.

Installation on a small disk

(This section is out-of-date & may need research for sizes) During a normal install, the installer copies the packages from the Cd to the hard drive (in addition to actually installing them). If you are short on disk space before you install, you can tell the installer not to use extra disk space. The packages take up about xxx Mb. You will be able to install a full Ubuntu system with less than xx Gb of hard drive space. At the installation prompt (just after you boot from cd) type:

linux archive-copier/copy=false