Tuesday, February 1, 2011

Linux Filesystem Hierarchy & Probable Partition Size

Linux adheres to the Filesystem Hierarchy Standard for directory and file naming. This standard allows users and software programs to predict the location of files and directories. The root level directory is represented simply by the slash /. At the root level, all Linux systems include these directories:


Directory         Content

bin                  Essential command binaries
boot                Static files of the boot loader
dev                 Device files
etc                  Host-specific system configuration
home              User home directories
lib                  Essential shared libraries and kernel modules
media             Contains mount points for replaceable media
mnt                Mount point for mounting a file system temporarily
proc               Virtual directory for system information (2.4 and 2.6 kernels)
root                Home directory for the root user
sbin                Essential system binaries
srv                  Data for services provided by this system
sys                  Virtual directory for system information (2.6 kernels)
tmp                 Temporary files
usr                  Secondary hierarchy
var                  Variable data
opt                  Add-on application software packages

The following is a list of important considerations regarding directories and partitions. Note that disk usage varies widely given system configuration and specific usage patterns. The recommendations here are general guidelines and provide a starting point for partitioning.

    * With respect to the issue of swap partition size, there are many views. One rule of thumb which works well is to use as much swap as you have system memory. It also shouldn't be smaller than 16MB, in most cases. Of course, there are exceptions to these rules. If you are trying to solve 10000 simultaneous equations on a machine with 256MB of memory, you may need a gigabyte (or more) of swap.
On 32-bit architectures (i386, m68k, 32-bit SPARC, and PowerPC), the maximum size of a swap partition is 2GB. That should be enough for nearly any installation. However, if your swap requirements are this high, you should probably try to spread the swap across different disks (also called “spindles”) and, if possible, different SCSI or IDE channels. The kernel will balance swap usage between multiple swap partitions, giving better performance.
As an example, an older home machine might have 32MB of RAM and a 1.7GB IDE drive on /dev/hda. There might be a 500MB partition for another operating system on /dev/hda1, a 32MB swap partition on /dev/hda3 and about 1.2GB on /dev/hda2 as the Linux partition.

    * The root partition / must always physically contain /etc, /bin, /sbin, /lib and /dev, otherwise you won't be able to boot. Typically 150–250 MB is needed for the root partition.

    * /usr: contains all user programs (/usr/bin), libraries (/usr/lib), documentation (/usr/share/doc), etc. This is the part of the file system that generally takes up most space. You should provide at least 500 MB of disk space. This amount should be increased depending on the number and type of packages you plan to install. A standard Ubuntu desktop requires a minimum of 1.5 GB here. A generous workstation or server installation should allow 4-6 GB.

    * /var: variable data like news articles, e-mails, web sites, databases, the packaging system cache, etc. will be placed under this directory. The size of this directory depends greatly on the usage of your system, but for most people will be dictated by the package management tool's overhead.
If you are going to do a full installation of just about everything Ubuntu has to offer, all in one session, setting aside 2 or 3 gigabyte of space for /var should be sufficient.
If you are going to install in pieces (that is to say, install services and utilities, followed by text stuff, then X, ...), you can get away with 300–500 MB. If hard drive space is at a premium and you don't plan on doing major system updates, you can get by with as little as 30 or 40 MB.

    * /tmp: temporary data created by programs will most likely go in this directory. 40–100 MB should usually be enough. Some applications — including archive manipulators, CD/DVD authoring tools, and multimedia software — may use /tmp to temporarily store image files. If you plan to use such applications, you should adjust the space available in /tmp accordingly.

    * /home: every user will put his personal data into a subdirectory of this directory. Its size depends on how many users will be using the system and what files are to be stored in their directories. Depending on your planned usage you should reserve about 100 MB for each user, but adapt this value to your needs. Reserve a lot more space if you plan to save a lot of multimedia files (pictures, MP3, movies) in your home directory.

For multi-user systems or systems with lots of disk space, it's best to put /usr, /var, /tmp, and /home each on their own partitions separate from the / partition.

You might need a separate /usr/local partition if you plan to install many programs that are not part of the Ubuntu distribution. If your machine will be a mail server, you might need to make /var/mail a separate partition. Often, putting /tmp on its own partition, for instance 20 to 50MB, is a good idea. If you are setting up a server with lots of user accounts, it's generally good to have a separate, large /home partition. In general, the partitioning situation varies from computer to computer depending on its uses.

For very complex systems, you should see the Multi Disk HOWTO. This contains in-depth information, mostly of interest to ISPs and people setting up servers.

Linux represents the primary partitions as the drive name, plus the numbers 1 through 4. For example, the first primary partition on the first IDE drive is /dev/hda1. The logical partitions are numbered starting at 5, so the first logical partition on that same drive is /dev/hda5. Remember that the extended partition, that is, the primary partition holding the logical partitions, is not usable by itself. This applies to SCSI disks as well as IDE disks.

Reference
http://www.tldp.org/HOWTO/Multi-Disk-HOWTO.html

No comments:

Post a Comment