home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Enter 1999 June / enter_06_1999.iso / doc / HOWTO / mini / Partition < prev    next >
Text File  |  1998-10-14  |  30KB  |  661 lines

  1.   Linux Partition HOWTO
  2.   Kristan Koehntopp, kris@koehntopp.de
  3.   v2.4, 3 November 1997
  4.  
  5.   This Linux Mini-HOWTO teaches you how to plan and layout disk space
  6.   for your Linux system. It talks about disk hardware, partitions, swap
  7.   space sizing and positioning considerations. file systems, file system
  8.   types and related topics. The intent is to teach some background
  9.   knowledge, not procedures.
  10.   ______________________________________________________________________
  11.  
  12.   Table of Contents
  13.  
  14.  
  15.   1. Introduction
  16.  
  17.      1.1 What is this?
  18.      1.2 What is in it? and related HOWTO documents
  19.  
  20.   2. What is a partition anyway?
  21.  
  22.      2.1 Backups are important
  23.      2.2 Device numbers and device names
  24.  
  25.   3. What Partitions do I need?
  26.  
  27.      3.1 How many partitions do I need?
  28.      3.2 How large should my swap space be?
  29.      3.3 Where should I put my swap space?
  30.      3.4 Some facts about file systems and fragmentation
  31.      3.5 File lifetimes and backup cycles as partitioning criteria
  32.  
  33.   4. An example
  34.  
  35.      4.1 A recommended model for ambitious beginners
  36.  
  37.   5. How I did it on my machine
  38.  
  39.  
  40.  
  41.   ______________________________________________________________________
  42.  
  43.   1.  Introduction
  44.  
  45.   1.1.  What is this?
  46.  
  47.  
  48.   This is a Linux Mini-HOWTO text. A Mini-HOWTO is a small text
  49.   explaining some business related to Linux installation and maintenance
  50.   tutorial style. It's mini, because either the text or the topic it
  51.   discusses are too small for a real HOWTO or even a book. A HOWTO is
  52.   not a reference:  that's what manual pages are for.
  53.  
  54.  
  55.   1.2.  What is in it? and related HOWTO documents
  56.  
  57.  
  58.   This particular Mini-HOWTO teaches you how to plan and layout disk
  59.   space for your Linux system. It talks about disk hardware, partitions,
  60.   swap space sizing and positioning considerations, file systems, file
  61.   system types and related topics. The intent is to teach some
  62.   background knowlegde, so we are talking mainly principles and not
  63.   tools in this text.
  64.  
  65.   Ideally, this document should be read before your first installation,
  66.   but this is somehow difficult for most people.  First timers have
  67.   other problems than disk layout optimization, too. So you are probably
  68.   someone who just finished a Linux installation and is now thinking
  69.   about ways to optimize this installation or how to avoid some nasty
  70.   miscalculations in the next one. Well, expect some desire to tear down
  71.   and rebuild your installation when you are finished with this text.
  72.   :-)
  73.  
  74.  
  75.   This Mini-HOWTO limits itself to planning and layouting disk space
  76.   most of the time. It does not discuss the usage of fdisk, LILO, mke2fs
  77.   or backup programs. There are other HOWTOs that address these
  78.   problems. Please see the Linux HOWTO Index for current information on
  79.   Linux HOWTOs. There are instructions for obtaining HOWTO documents in
  80.   the index, too.
  81.  
  82.   To learn how to estimate the various size and speed requirements for
  83.   different parts of the filesystem, see "Linux Multiple Disks Layout
  84.   mini-HOWTO", by Gjoen Stein <gjoen@nyx.net>.
  85.  
  86.   For instructions and considerations regarding disks with more than
  87.   1024 cylinders, see "Linux Large Disk mini-HOWTO", Andries Brouwer
  88.   <aeb@cwi.nl>.
  89.  
  90.   For instructions on limiting disk space usage per user (quotas), see
  91.   "Linux Quota mini-HOWTO", by Albert M.C. Tam <bertie@scn.org>
  92.  
  93.   Currently, there is no general document on disk backup, but there are
  94.   several documents with pointers to specific backup solutions. See
  95.   "Linux ADSM Backup mini-HOWTO", by Thomas Koenig
  96.   <Thomas.Koenig@ciw.uni-karlsruhe.de> for instructions on integrating
  97.   Linux into an IBM ADSM backup environment. See "Linux Backup with
  98.   MSDOS mini-HOWTO", by Christopher Neufeld
  99.   <neufeld@physics.utoronto.ca> for information about MS-DOS driven
  100.   Linux backups.
  101.  
  102.   For instructions on writing and submitting a HOWTO document, see the
  103.   Linux HOWTO Index, by Tim Bynum <linux-howto@sunsite.unc.edu>.
  104.  
  105.   Browsing through /usr/src/linux/Documentation can be very instructive,
  106.   too. See ide.txt and scsi.txt for some background information on the
  107.   properties of your disk drivers and have a look at the filesystems/
  108.   subdirectory.
  109.  
  110.  
  111.   2.  What is a partition anyway?
  112.  
  113.  
  114.   When PC hard disks were invented people soon wanted to install
  115.   multiple operating systems, even if their system had only one disk.
  116.   So a mechanism was needed to divide a single physical disk into
  117.   multiple logical disks. So that's what a partition is: A contiguous
  118.   section of blocks on your hard disk that is treated like a completely
  119.   seperate disk by most operating systems.
  120.  
  121.   It is fairly clear that partitions must not overlap: An operating
  122.   system will certainly not be pleased, if another operating system
  123.   installed on the same machine were overwriting important information
  124.   because of overlapping partitions. There should be no gap between
  125.   adjacent partitions, too. While this constellation is not harmful, you
  126.   are wasting precious disk space by leaving space between partitions.
  127.  
  128.   A disk need not be partitioned completely. You may decide to leave
  129.   some space at the end of your disk that is not assigned to any of your
  130.   installed operating systems, yet. Later, when it is clear which
  131.   installation is used by you most of the time, you can partition this
  132.   left over space and put a file system on it.
  133.   Partitions can not be moved nor can they be resized without destroying
  134.   the file system contained in it. So repartitioning usually involves
  135.   backup and restore of all file systems touched during the
  136.   repartitioning.  In fact it is fairly common to mess up things
  137.   completely during repartitioning, so you should back up anything on
  138.   any disk on that particular machine before even touching things like
  139.   fdisk.
  140.  
  141.   Well, some partitions with certain file system types on them actually
  142.   can be split into two without losing any data (if you are lucky). For
  143.   example there is a program called "fips" for splitting MS-DOS
  144.   partitions into two to make room for a Linux installation without
  145.   having to reinstall MS-DOS. You are still not going to touch these
  146.   things without carefully backing up everything on that machine, aren't
  147.   you?
  148.  
  149.  
  150.   2.1.  Backups are important
  151.  
  152.  
  153.   Tapes are your friend for backups. They are fast, reliable and easy to
  154.   use, so you can make backups often, preferably automatically and
  155.   without hassle.
  156.  
  157.   Step on soapbox: And I am talking about real tapes, not that disk
  158.   controller driven ftape crap. Consider buying SCSI: Linux does support
  159.   SCSI natively. You don't need to load ASPI drivers, you are not losing
  160.   precious HMA under Linux and once the SCSI host adapter is installed,
  161.   you just attach additional disks, tapes and CD-ROMs to it. No more I/O
  162.   addresses, IRQ juggling or Master/Slave and PIO-level matching.
  163.  
  164.   Plus: Proper SCSI host adapters give you high I/O performance without
  165.   much CPU load. Even under heavy disk activity you will experience good
  166.   response times. If you are planning to use a Linux system as a major
  167.   USENET news feed or if you are about to enter the ISP business, don't
  168.   even think about deploying a system without SCSI. Climb of soapbox.
  169.  
  170.  
  171.   2.2.  Device numbers and device names
  172.  
  173.  
  174.   The number of partitions on an Intel based system was limited from the
  175.   very beginning: The original partition table was installed as part of
  176.   the boot sector and held space for only four partition entries.  These
  177.   partitions are now called primary partitions. When it became clear
  178.   that people needed more partitions on their systems, logical
  179.   partitions were invented.  The number of logical partitions is not
  180.   limited: Each logical partition contains a pointer to the next logical
  181.   partition, so you can have a potentially unlimited chain of partition
  182.   entries.
  183.  
  184.   For compatibility reasons, the space occupied by all logical
  185.   partitions had to be accounted for. If you are using logical
  186.   partitions, one primary partition entry is marked as "extended
  187.   partition" and its starting and ending block mark the area occupied by
  188.   your logical partitions. This implies that the space assigned to all
  189.   logical partitions has to be contiguous.  There can be only one
  190.   extended partition: no fdisk program will create more than one
  191.   extended partition.
  192.  
  193.   Linux cannot handle more than a limited number of partitions per
  194.   drive. So in Linux you have 4 primary partitions (3 of them useable,
  195.   if you are using logical partitions) and at most 15 partitions
  196.   altogether on an SCSI disk (63 altogether on an IDE disk).
  197.  
  198.  
  199.   In Linux, partitions are represented by device files. A device file is
  200.   a file with type c (for "character" devices, devices that do not use
  201.   the buffer cache) or b (for "block" devices, which go through the
  202.   buffer cache). In Linux, all disks are represented as block devices
  203.   only. Unlike other Unices, Linux does not offer "raw" character
  204.   versions of disks and their partitions.
  205.  
  206.   The only important thing with a device file are its major and minor
  207.   device number, shown instead of the files size:
  208.  
  209.  
  210.  
  211.        ______________________________________________________________________
  212.        $ ls -l /dev/hda
  213.        brw-rw----   1 root     disk       3,   0 Jul 18  1994 /dev/hda
  214.                                           ^    ^
  215.                                           |    minor device number
  216.                                           major device number
  217.        ______________________________________________________________________
  218.  
  219.  
  220.  
  221.  
  222.   When accessing a device file, the major number selects which device
  223.   driver is being called to perform the input/output operation. This
  224.   call is being done with the minor number as a parameter and it is
  225.   entirely up to the driver how the minor number is being interpreted.
  226.   The driver documentation usually describes how the driver uses minor
  227.   numbers. For IDE disks, this documentation is in
  228.   /usr/src/linux/Documentation/ide.txt.  For SCSI disks, one would
  229.   expect such documentation in /usr/src/linux/Documentation/scsi.txt,
  230.   but it isn't there. One has to look at the driver source to be sure
  231.   (/usr/src/linux/driver/scsi/sd.c:184-196). Fortunately, there is Peter
  232.   Anvin's list of device numbers and names in
  233.   /usr/src/linux/Documentation/devices.txt; see the entries for block
  234.   devices, major 3, 22, 33, 34 for IDE and major 8 for SCSI disks. The
  235.   major and minor numbers are a byte each and that is why the number of
  236.   partitions per disk is limited.
  237.  
  238.   By convention device files have certain names and many system programs
  239.   have knowledge about these names compiled in. They expect your IDE
  240.   disks to be named /dev/hd* and your SCSI disks to be named /dev/sd*.
  241.   Disks are numbered a, b, c and so on, so /dev/hda is your first IDE
  242.   disk and /dev/sda is your first SCSI disk. Both devices represent
  243.   entire disks, starting at block one.  Writing to these devices with
  244.   the wrong tools will destroy the master boot loader and partition
  245.   table on these disks, rendering all data on this disk unusable or
  246.   making your system unbootable. Know what you are doing and, again,
  247.   back up before you do it.
  248.  
  249.   Primary partitions on a disk are 1, 2, 3 and 4. So /dev/hda1 is the
  250.   first primary partition on the first IDE disk and so on.  Logical
  251.   partitions have numbers 5 and up, so /dev/sdb5 is the first logical
  252.   partition on the second SCSI disk.
  253.  
  254.   Each partition entry has a starting and an ending block address
  255.   assigned to it and a type. The type is a numerical code (a byte) which
  256.   designates a particular partition to a certain type of operating
  257.   system. For the benefit of computing consultants partition type codes
  258.   are not really unique, so there is always the probability of two
  259.   operating systems using the same type code.
  260.  
  261.   Linux reserves the type code 0x82 for swap partitions and 0x83 for
  262.   "native" file systems (that's ext2 for almost all of you).  The once
  263.   popular, now outdated Linux/Minix file system used the type code 0x81
  264.   for partitions. OS/2 marks it's partitions with a 0x07 type and so
  265.   does Windows NT's NTFS. MS-DOS allocates several type codes for its
  266.   various flavors of FAT file systems: 0x01, 0x04 and 0x06 are known.
  267.   DR-DOS used 0x81 to indicate protected FAT partitions, creating a type
  268.   clash with Linux/Minix at that time, but neither Linux/Minix nor DR-
  269.   DOS are widely used any more. The extended partition which is used as
  270.   a container for logical partitions has a type of 0x05, by the way.
  271.  
  272.   Partitions are created and deleted with the fdisk program.  Every self
  273.   respecting operating system program comes with an fdisk and
  274.   traditionally it is even called fdisk (or FDISK.EXE) in almost all
  275.   OSes. Some fdisks, noteable the DOS one, are somehow limited when they
  276.   have to deal with other operating systems partitions. Such limitations
  277.   include the complete inability to deal with anything with a foreign
  278.   type code, the inability to deal with cylinder numbers above 1024 and
  279.   the inability to create or even understand partitions that do not end
  280.   on a cylinder boundary. For example, the MS-DOS fdisk can't delete
  281.   NTFS partitions, the OS/2 fdisk has been known to silently "correct"
  282.   partitions created by the Linux fdisk that do not end on a cylinder
  283.   boundary and both, the DOS and the OS/2 fdisk, have had problems with
  284.   disks with more than 1024 cylinders (see the "large-disk" Mini-Howto
  285.   for details on such disks).
  286.  
  287.  
  288.   3.  What Partitions do I need?
  289.  
  290.   3.1.  How many partitions do I need?
  291.  
  292.  
  293.   Okay, so what partitions do you need? Well, some operating systems do
  294.   not believe in booting from logical partitions for reasons that are
  295.   beyond the scope of any sane mind. So you probably want to reserve
  296.   your primary partitions as boot partitions for your MS-DOS, OS/2 and
  297.   Linux or whatever you are using. Remember that one primary partition
  298.   is needed as an extended partition, which acts as a container for the
  299.   rest of your disk with logical partitions.
  300.  
  301.   Booting operating systems is a real-mode thing involving BIOSes and
  302.   1024 cylinder limitations. So you probably want to put all your boot
  303.   partitions into the first 1024 cylinders of your hard disk, just to
  304.   avoid problems. Again, read the "large-disk" Mini-Howto for the gory
  305.   details.
  306.  
  307.  
  308.   To install Linux, you will need at least one partition. If the kernel
  309.   is loaded from this partition (for example by LILO), this partition
  310.   must be readable by your BIOS. If you are using other means to load
  311.   your kernel (for example a boot disk or the LOADLIN.EXE MS-DOS based
  312.   Linux loader) the partition can be anywhere. In any case this
  313.   partition will be of type 0x83 "Linux native".
  314.  
  315.   Your system will need some swap space. Unless you swap to files you
  316.   will need a dedicated swap partition. Since this partition is only
  317.   accessed by the Linux kernel and the Linux kernel does not suffer from
  318.   PC BIOS deficiencies, the swap partition may be positioned anywhere.
  319.   I recommed using a logical partition for it (/dev/?d?5 and higher).
  320.   Dedicated Linux swap partitions are of type 0x82 "Linux swap".
  321.  
  322.   These are minimal partition requirements. It may be useful to create
  323.   more partitions for Linux. Read on.
  324.  
  325.  
  326.  
  327.   3.2.  How large should my swap space be?
  328.  
  329.  
  330.  
  331.   If you have decided to use a dedicated swap partition, which is
  332.   generally a Good Idea [tm], follow these guidelines for estimating its
  333.   size:
  334.  
  335.  
  336.   ╖  In Linux RAM and swap space add up (This is not true for all
  337.      Unices). For example, if you have 8 MB of RAM and 12 MB swap space,
  338.      you have a total of about 20 MB virtual memory.
  339.  
  340.   ╖  When sizing your swap space, you should have at least 16 MB of
  341.      total virtual memory. So for 4 MB of RAM consider at least 12 MB of
  342.      swap, for 8 MB of RAM consider at least 8 MB of swap.
  343.  
  344.   ╖  In Linux, a single swap partition can not be larger than 128 MB.
  345.      That is, the partition may be larger than 128 MB, but excess space
  346.      is never used. If you want more than 128 MB of swap, you have to
  347.      create multiple swap partitions.
  348.  
  349.   ╖  When sizing swap space, keep in mind that too much swap space may
  350.      not be useful at all.
  351.  
  352.      Every process has a "working set". This is a set of in-memory pages
  353.      which will be referenced by the processor in the very near future.
  354.      Linux tries to predict these memory accesses (assuming that
  355.      recently used pages will be used again in the near future) and
  356.      keeps these pages in RAM if possible. If the program has a good
  357.      "locality of reference" this assumption will be true and prediction
  358.      algorithm will work.
  359.  
  360.      Holding a working set in main memory does only work if there is
  361.      enough main memory. If you have too many processes running on a
  362.      machine, the kernel is forced to put pages on disk that it will
  363.      reference again in the very near future (forcing a page-out of a
  364.      page from another working set and then a page-in of the page
  365.      referenced). Usually this results in a very heavy increase in
  366.      paging activity and in a sustantial drop of performance. A machine
  367.      in this state is said to be "thrashing" (For you german readers:
  368.      That's "thrashing" ("dreschen", "schlagen", "haemmern") and not
  369.      trashing ("muellen")).
  370.  
  371.      On a thrashing machine the processes are essentially running from
  372.      disk and not from RAM. Expect performance to drop by approximately
  373.      the ratio between memory access speed and disk access speed.
  374.  
  375.      A very old rule of thumb in the days of the PDP and the Vax was
  376.      that the size of the working set of a program is about 25% of its
  377.      virtual size. Thus it is probably useless to provide more swap than
  378.      three times your RAM.
  379.  
  380.      But keep in mind that this is just a rule of thumb. It is easily
  381.      possible to create scenarios where programs have extremely large or
  382.      extremely small working sets. For example, a simulation program
  383.      with a large data set that is accessed in a very random fashion
  384.      would have almost no noticeable locality of reference in its data
  385.      segment, so its working set would be quite large.
  386.  
  387.      On the other hand, an xv with many simultaneously opened JPEGs, all
  388.      but one iconified, would have a very large data segment. But image
  389.      transformations are all done on one single image, most of the
  390.      memory occupied by xv is never touched.  The same is true for an
  391.      editor with many editor windows where only one window is being
  392.      modified at a time.  These programs have - if they are designed
  393.      properly - a very high locality of reference and large parts of
  394.      them can be kept swapped out without too severe performance impact.
  395.  
  396.      One could suspect that the 25% number from the age of the command
  397.      line is no longer true for modern GUI programs editing multiple
  398.      documents, but I know of no newer papers that try to verify these
  399.      numbers.
  400.  
  401.   So for a configuration with 16 MB RAM, no swap is needed for a minimal
  402.   configuration and more than 48 MB of swap are probably useless. The
  403.   exact amount of memory needed depends on the application mix on the
  404.   machine (what did you expect?).
  405.  
  406.  
  407.   3.3.  Where should I put my swap space?
  408.  
  409.  
  410.  
  411.   ╖  Mechanics are slow, electronics are fast.
  412.  
  413.      Modern hard disks have many heads. Switching between heads of the
  414.      same track is fast, since it is purely electronic.  Switching
  415.      between tracks is slow, since it involves moving real world matter.
  416.  
  417.      So if you have a disk with many heads and one with less heads and
  418.      both are identical in other parameters, the disk with many heads
  419.      will be faster.
  420.  
  421.      Splitting swap and putting it on both disks will be even faster,
  422.      though.
  423.  
  424.   ╖  Older disks have the same number of sectors on all tracks.  With
  425.      this disks it will be fastest to put your swap in the middle of the
  426.      disks, assuming that your disk head will move from a random track
  427.      towards the swap area.
  428.  
  429.   ╖  Newer disks use ZBR (zone bit recording). They have more sectors on
  430.      the outer tracks. With a constant number of rpms, this yields a far
  431.      greater performance on the outer tracks than on the inner ones. Put
  432.      your swap on the fast tracks.
  433.  
  434.   ╖  Of course your disk head will not move randomly. If you have swap
  435.      space in the middle of a disk between a constantly busy home
  436.      partition and an almost unused archive partition, you would be
  437.      better of if your swap were in the middle of the home partition for
  438.      even shorter head movements. You would be even better off, if you
  439.      had your swap on another otherwise unused disk, though.
  440.  
  441.   Summary: Put your swap on a fast disk with many heads that is not busy
  442.   doing other things. If you have multiple disks: Split swap and scatter
  443.   it over all your disks or even different controllers.
  444.  
  445.   Even better: Buy more RAM.
  446.  
  447.  
  448.   3.4.  Some facts about file systems and fragmentation
  449.  
  450.  
  451.   Disk space is administered by the operating system in units of blocks
  452.   and fragments of blocks. In ext2, fragments and blocks have to be of
  453.   the same size, so we can limit our discussion to blocks.
  454.  
  455.   Files come in any size. They don't end on block boundaries.  So with
  456.   every file a part of the last block of every file is wasted. Assuming
  457.   that file sizes are random, there is approximately a half block of
  458.   waste for each file on your disk.  Tanenbaum calls this "internal
  459.   fragmentation" in his book "Operating Systems".
  460.  
  461.   You can guess the number of files on your disk by the number of
  462.   allocated inodes on a disk. On my disk
  463.        ______________________________________________________________________
  464.        # df -i
  465.        Filesystem           Inodes   IUsed   IFree  %IUsed Mounted on
  466.        /dev/hda3              64256   12234   52022    19%  /
  467.        /dev/hda5              96000   43058   52942    45%  /var
  468.        ______________________________________________________________________
  469.  
  470.  
  471.  
  472.  
  473.   there are about 12000 files on / and about 44000 files on /var.  At a
  474.   block size of 1 KB, about 6+22 = 28 MB of disk space are lost in the
  475.   tail blocks of files. Had I chosen a block size of 4 KB, I had lost 4
  476.   times this space.
  477.  
  478.  
  479.   Data transfer is faster for large contiguous chunks of data, though.
  480.   That's why ext2 tries to preallocate space in units of 8 contigous
  481.   blocks for growing files. Unused preallocation is released when the
  482.   file is closed, so no space is wasted.
  483.  
  484.   Noncontiguous placement of blocks in a file is bad for performance,
  485.   since files are often accessed in a sequential manner. It forces the
  486.   operating system to split a disk access and the disk to move the head.
  487.   This is called "external fragmentation" or simply "fragmentation" and
  488.   is a common problem with DOS file systems.
  489.  
  490.   ext2 has several strategies to avoid external fragmentation.  Normally
  491.   fragmentation is not a large problem in ext2, not even on heavily used
  492.   partitions such as a USENET news spool. While there is a tool for
  493.   defragmentation of ext2 file systems, nobody ever uses it and it is
  494.   not up to date with the current release of ext2. Use it, but do so on
  495.   your own risk.
  496.  
  497.   The MS-DOS file system is well known for its pathological managment of
  498.   disk space. In conjunction with the abysmal buffer cache used by MS-
  499.   DOS the effects of file fragmentation on performance are very
  500.   noticeable. DOS users are accustomed to defragging their disks every
  501.   few weeks and some have even developed some ritualistic beliefs
  502.   regarding defragmentation.  None of these habits should be carried
  503.   over to Linux and ext2.  Linux native file systems do not need
  504.   defragmentation under normal use and this includes any condition with
  505.   at least 5% of free space on a disk.
  506.  
  507.  
  508.   The MS-DOS file system is also known to lose large amounts of disk
  509.   space due to internal fragmentation. For partitions larger than 256
  510.   MB, DOS block sizes grow so large that they are no longer useful (This
  511.   has been corrected to some extent with FAT32).
  512.  
  513.   ext2 does not force you to choose large blocks for large file systems,
  514.   except for very large file systems in the 0.5 TB range (that's
  515.   terabytes with 1 TB equaling 1024 GB) and above, where small block
  516.   sizes become inefficient. So unlike DOS there is no need to split up
  517.   large disks into multiple partitions to keep block size down. Use the
  518.   1 KB default block size if possible. You may want to experiment with a
  519.   block size of 2 KB for some partitions, but expect to meet some seldom
  520.   exercised bugs: Most people use the default.
  521.  
  522.  
  523.   3.5.  File lifetimes and backup cycles as partitioning criteria
  524.  
  525.  
  526.   With ext2, Partitioning decisions should be governed by backup
  527.   considerations and to avoid external fragmentation from different file
  528.   lifetimes.
  529.   Files have lifetimes. After a file has been created, it will remain
  530.   some time on the system and then be removed. File lifetime varies
  531.   greatly throughout the system and is partly dependent on the pathname
  532.   of the file. For example, files in /bin, /sbin, /usr/sbin, /usr/bin
  533.   and similar directories are likely to have a very long lifetime: many
  534.   months and above.  Files in /home are likely to have a medium
  535.   lifetime: several weeks or so. File in /var are usually short lived:
  536.   Almost no file in /var/spool/news will remain longer than a few days,
  537.   files in /var/spool/lpd measure their lifetime in minutes or less.
  538.  
  539.  
  540.   For backup it is useful if the amount of daily backup is smaller than
  541.   the capacity of a single backup medium. A daily backup can be a
  542.   complete backup or an incremental backup.
  543.  
  544.   You can decide to keep your partition sizes small enough that they fit
  545.   completely onto one backup medium (choose daily full backups). In any
  546.   case a partition should be small enough that its daily delta (all
  547.   modified files) fits onto one backup medium (choose incremental backup
  548.   and expect to change backup media for the weekly/monthly full dump -
  549.   no unattended operation possible).
  550.  
  551.   Your backup strategy depends on that decision.
  552.  
  553.   When planning and buying disk space, remember to set aside a
  554.   sufficient amount of money for backup! Unbackuped data is worthless!
  555.   Data reproduction costs are much higher than backup costs for
  556.   virtually everyone!
  557.  
  558.  
  559.   For performance it is useful to keep files of different lifetimes on
  560.   different partitions. This way the short lived files on the news
  561.   partition may be fragmented very heavily.  This has no impact on the
  562.   performance of the / or /home partition.
  563.  
  564.  
  565.   4.  An example
  566.  
  567.   4.1.  A recommended model for ambitious beginners
  568.  
  569.  
  570.   A common model creates /, /home and /var partitions as discussed
  571.   above. This is simple to install and maintain and differentiates well
  572.   enough to avoid adverse effects from different lifetimes. It fits well
  573.   into a backup model, too:  Almost noone bothers to backup USENET news
  574.   spools and only some files in /var are worth backing up
  575.   (/var/spool/mail comes to mind). On the other hand, / changes
  576.   infrequently and can be backuped upon demand (after configuration
  577.   changes) and is small enough to fit on most modern backup media as a
  578.   full backup (plan 250 to 500 MB depending on the amount of installed
  579.   software). /home contains valuable user data and should be backuped
  580.   daily.  Some installations have very large /homes and must use
  581.   incremental backups.
  582.  
  583.   Some systems put /tmp onto a seperate partition as well, others
  584.   symlink it to /var/tmp to achieve the same effect (note that this can
  585.   affect single user mode, where /var will be unavailable and the system
  586.   will have no /tmp until you create one or mount /var manually) or put
  587.   it onto a RAM disk (Solaris does this for example). This keeps /tmp
  588.   out of /, a good idea.
  589.  
  590.   This model is convenient for upgrades or reinstallations as well: Save
  591.   your configuration files (or the entire /etc) to some /home directory,
  592.   scrap your /, reinstall and fetch the old configurations from the save
  593.   directory on /home.
  594.  
  595.   5.  How I did it on my machine
  596.  
  597.  
  598.   There was this old ISA bus 386/40 sitting on my shelf that I abandoned
  599.   two years ago because it no longer cut it. I was planning to turn it
  600.   into a small X-less server for my household LAN.
  601.  
  602.   Here is how I did it: I took that 386 and put 16 MB RAM into it.
  603.   Added a cheap EIDE disk, the smallest I could get (800 MB) and an
  604.   ethernet card. Added an old Hercules because I still had a monitor for
  605.   it. Installed Linux on it and there I have my local NFS, SMB, HTTP,
  606.   LPD/LPR and NNTP server as well as my mail router and POP3 server.
  607.   With an additional ISDN card the machine became my TCP/IP router and
  608.   firewall, too.
  609.  
  610.   Most of the disk space on this machine went into the /var directories,
  611.   /var/spool/mail, /var/spool/news and /var/httpd/html. I put /var on a
  612.   separate partition and made this one large. There will be almost no
  613.   users on this machine, so I created no home partition and mounted
  614.   /home from some other workstation via NFS.
  615.  
  616.   Linux without X plus several locally installed utilities will be fine
  617.   with a 250 MB partition as /. The machine has 16 MB of RAM, but it
  618.   will be running many servers. 16 MB swap should be in order, 32 MB
  619.   should be plenty. We are not short on disk space, so the machine will
  620.   get 32 MB.  Out of sentimentality a MS-DOS partition of some 20 MB is
  621.   kept on it.  I decided to import /home from another machine, so the
  622.   remaining 500+ MB will end up as /var. This is more than sufficient
  623.   for a household USENET news feed.
  624.  
  625.   We get
  626.  
  627.  
  628.  
  629.        ______________________________________________________________________
  630.        Device     Mounted on                      Size
  631.        /dev/hda1  /dos_c                           25 MB
  632.        /dev/hda2  - (Swapspace)                    32 MB
  633.        /dev/hda3  /                               250 MB
  634.        /dev/hda4  - (Extended Container)          500 MB
  635.        /dev/hda5  /var                            500 MB
  636.  
  637.        homeserver:/home /home                     1.6 GB
  638.        ______________________________________________________________________
  639.  
  640.  
  641.  
  642.  
  643.   I am backing up this machine via the network using the tape in
  644.   homeserver. Since everything on this machine has been installed from
  645.   CD-ROM all I have to save are some configuration files from /etc, my
  646.   customized locally installed *.tgz files from /root/Source/Installed
  647.   and /var/spool/mail as well as /var/httpd/html.  I copy these files
  648.   into a dedicated directory /home/backmeup on homeserver every night,
  649.   where the regular homeserver backup picks them up.
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.