5147 lines
86 KiB
HTML
5147 lines
86 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Linux Partition HOWTO</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"></HEAD
|
|
><BODY
|
|
CLASS="article"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="ARTICLE"
|
|
><DIV
|
|
CLASS="TITLEPAGE"
|
|
><H1
|
|
CLASS="title"
|
|
><A
|
|
NAME="AEN2"
|
|
></A
|
|
>Linux Partition HOWTO</H1
|
|
><H3
|
|
CLASS="author"
|
|
><A
|
|
NAME="AEN4"
|
|
>Anthony Lissot</A
|
|
></H3
|
|
><DIV
|
|
CLASS="revhistory"
|
|
><TABLE
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
><TR
|
|
><TH
|
|
ALIGN="LEFT"
|
|
VALIGN="TOP"
|
|
COLSPAN="3"
|
|
><B
|
|
>Revision History</B
|
|
></TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
ALIGN="LEFT"
|
|
>Revision 3.5</TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
>26 Dec 2005</TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
ALIGN="LEFT"
|
|
COLSPAN="3"
|
|
>reorganized document page ordering.
|
|
added page on setting up swap space.
|
|
added page of partition labels.
|
|
updated max swap size values in section 4.
|
|
added instructions on making ext2/3 file systems.
|
|
broken links identified by Richard Calmbach are fixed.
|
|
created an XML version.</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
ALIGN="LEFT"
|
|
>Revision 3.4.4</TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
>08 March 2004</TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
ALIGN="LEFT"
|
|
COLSPAN="3"
|
|
>synchronized SGML version with HTML version.
|
|
Updated lilo placement and swap size discussion.</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
ALIGN="LEFT"
|
|
>Revision 3.3</TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
>04 April 2003</TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
ALIGN="LEFT"
|
|
COLSPAN="3"
|
|
>synchronized SGML and HTML versions</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
ALIGN="LEFT"
|
|
>Revision 3.3</TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
>10 July 2001</TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
ALIGN="LEFT"
|
|
COLSPAN="3"
|
|
>Corrected Section 6, calculation of cylinder numbers</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
ALIGN="LEFT"
|
|
>Revision 3.2</TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
>1 September 2000</TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
ALIGN="LEFT"
|
|
COLSPAN="3"
|
|
>Dan Scott provides sgml conversion 2 Oct. 2000.
|
|
Rewrote Introduction.
|
|
Rewrote discussion on device names in Logical Devices.
|
|
Reorganized Partition Types.
|
|
Edited Partition Requirements.
|
|
Added Recovering a deleted partition table.</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
ALIGN="LEFT"
|
|
>Revision 3.1</TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
>12 June 2000</TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
ALIGN="LEFT"
|
|
COLSPAN="3"
|
|
>Corrected swap size limitation in Partition
|
|
Requirements, updated various links in Introduction, added
|
|
submitted example in How to Partition with fdisk, added file
|
|
system discussion in Partition Requirements.</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
ALIGN="LEFT"
|
|
>Revision 3.0</TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
>1 May 2000</TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
ALIGN="LEFT"
|
|
COLSPAN="3"
|
|
>First revision by
|
|
Anthony Lissot based on Linux Partition HOWTO by Kristian Koehntopp.</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
ALIGN="LEFT"
|
|
>Revision 2.4</TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
>3 November 1997</TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
ALIGN="LEFT"
|
|
COLSPAN="3"
|
|
>Last revision by Kristian Koehntopp.</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
><DIV
|
|
><DIV
|
|
CLASS="abstract"
|
|
><A
|
|
NAME="AEN40"
|
|
></A
|
|
><P
|
|
></P
|
|
><P
|
|
> This Linux Mini-HOWTO teaches you how to plan and create partitions
|
|
on IDE and SCSI hard drives. It discusses partitioning terminology
|
|
and considers size and location issues. Use of the fdisk
|
|
partitioning utility for creating and recovering of partition tables
|
|
is covered. The most recent version of this document is <A
|
|
HREF="http://lissot.net/partition"
|
|
TARGET="_top"
|
|
>here</A
|
|
>. The Turkish
|
|
translation is <A
|
|
HREF="http://belgeler.org/howto/partition-howto.html"
|
|
TARGET="_top"
|
|
>here</A
|
|
>.
|
|
</P
|
|
><P
|
|
></P
|
|
></DIV
|
|
></DIV
|
|
><HR></DIV
|
|
><DIV
|
|
CLASS="TOC"
|
|
><DL
|
|
><DT
|
|
><B
|
|
>Table of Contents</B
|
|
></DT
|
|
><DT
|
|
>1. <A
|
|
HREF="#intro"
|
|
>Introduction</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
>1.1. <A
|
|
HREF="#explanation"
|
|
>What is a partition?</A
|
|
></DT
|
|
><DT
|
|
>1.2. <A
|
|
HREF="#AEN57"
|
|
>Other Partitioning Software:</A
|
|
></DT
|
|
><DT
|
|
>1.3. <A
|
|
HREF="#howtos"
|
|
>Related HOWTOs</A
|
|
></DT
|
|
><DT
|
|
>1.4. <A
|
|
HREF="#AEN141"
|
|
>Additional information on your system:</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
>2. <A
|
|
HREF="#devices"
|
|
>Devices</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
>2.1. <A
|
|
HREF="#names"
|
|
>Device names</A
|
|
></DT
|
|
><DT
|
|
>2.2. <A
|
|
HREF="#numbers"
|
|
>Device numbers</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
>3. <A
|
|
HREF="#partition-types"
|
|
>Partition Types</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
>3.1. <A
|
|
HREF="#types"
|
|
>Partition Types</A
|
|
></DT
|
|
><DT
|
|
>3.2. <A
|
|
HREF="#AEN429"
|
|
>Foreign Partition Types</A
|
|
></DT
|
|
><DT
|
|
>3.3. <A
|
|
HREF="#primary"
|
|
>Primary Partitions</A
|
|
></DT
|
|
><DT
|
|
>3.4. <A
|
|
HREF="#logical"
|
|
>Logical Partitions</A
|
|
></DT
|
|
><DT
|
|
>3.5. <A
|
|
HREF="#swap-partitions"
|
|
>Swap Partitions</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
>4. <A
|
|
HREF="#requirements"
|
|
>Partitioning requirements</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
>4.1. <A
|
|
HREF="#number"
|
|
>What Partitions do I need?</A
|
|
></DT
|
|
><DT
|
|
>4.2. <A
|
|
HREF="#AEN467"
|
|
>Discussion:</A
|
|
></DT
|
|
><DT
|
|
>4.3. <A
|
|
HREF="#AEN493"
|
|
>File Systems</A
|
|
></DT
|
|
><DT
|
|
>4.4. <A
|
|
HREF="#SwapSize"
|
|
>Swap Partitions</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
>5. <A
|
|
HREF="#fdisk_partitioning"
|
|
>Partitioning with fdisk</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
>5.1. <A
|
|
HREF="#fdisk"
|
|
>fdisk usage</A
|
|
></DT
|
|
><DT
|
|
>5.2. <A
|
|
HREF="#primary-example"
|
|
>Four primary partitions</A
|
|
></DT
|
|
><DT
|
|
>5.3. <A
|
|
HREF="#mixed"
|
|
>Mixed primary and logical partitions</A
|
|
></DT
|
|
><DT
|
|
>5.4. <A
|
|
HREF="#submitted"
|
|
>Submitted Examples</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
>6. <A
|
|
HREF="#labels"
|
|
>Labels</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
>6.1. <A
|
|
HREF="#volumelabels"
|
|
>Volume Labels</A
|
|
></DT
|
|
><DT
|
|
>6.2. <A
|
|
HREF="#devicelabels"
|
|
>Device Labels</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
>7. <A
|
|
HREF="#formatting"
|
|
>Formatting an ext2/3 partition</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
>.1. <A
|
|
HREF="#formatting-invocation"
|
|
>Simple Invocation</A
|
|
></DT
|
|
><DT
|
|
>.2. <A
|
|
HREF="#reservedblocks"
|
|
>Reserved blocks</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
>8. <A
|
|
HREF="#recovering"
|
|
>Recovering a Deleted Partition Table</A
|
|
></DT
|
|
><DT
|
|
>9. <A
|
|
HREF="#setting_up_swap"
|
|
>Setting Up Swap Space</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
>9.1. <A
|
|
HREF="#swap_partitions"
|
|
>Swap Files</A
|
|
></DT
|
|
><DT
|
|
>9.2. <A
|
|
HREF="#swapfiles"
|
|
>Swap Files</A
|
|
></DT
|
|
><DT
|
|
>9.3. <A
|
|
HREF="#multiple_swap_areas"
|
|
>Multiple Swap Areas</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
><DT
|
|
>10. <A
|
|
HREF="#appendix"
|
|
>Appendix</A
|
|
></DT
|
|
><DD
|
|
><DL
|
|
><DT
|
|
>10.1. <A
|
|
HREF="#formating"
|
|
>Formating Partitions</A
|
|
></DT
|
|
><DT
|
|
>10.2. <A
|
|
HREF="#swap"
|
|
>Activating Swap Space</A
|
|
></DT
|
|
><DT
|
|
>10.3. <A
|
|
HREF="#mounting"
|
|
>Mounting Partitions</A
|
|
></DT
|
|
><DT
|
|
>10.4. <A
|
|
HREF="#fragmentation"
|
|
>Some facts about file systems and fragmentation</A
|
|
></DT
|
|
></DL
|
|
></DD
|
|
></DL
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect1"
|
|
><H1
|
|
CLASS="sect1"
|
|
><A
|
|
NAME="intro"
|
|
></A
|
|
>1. Introduction</H1
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="explanation"
|
|
></A
|
|
>1.1. What is a partition?</H2
|
|
><P
|
|
> Partitioning is a means to divide a single hard drive into many
|
|
logical drives. A partition is a contiguous set of blocks on a drive
|
|
that are treated as an independant disk. A partition table (the
|
|
creation of which is the topic of this HOWTO) is
|
|
an index that relates sections of the hard drive to partitions.
|
|
</P
|
|
><P
|
|
> Why have multiple partitions?
|
|
<P
|
|
></P
|
|
><UL
|
|
><LI
|
|
><P
|
|
> Encapsulate your data. Since file system corruption is local to
|
|
a partition, you stand to lose only some of your data if an
|
|
accident occurs.
|
|
</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
> Increase disk space efficiency. You can format partitions with
|
|
varying block sizes, depending on your usage. If your data is in
|
|
a large number of small files (less than 1k) and your partition
|
|
uses 4k sized blocks, you are wasting 3k for every file. In
|
|
general, you waste on average one half of a block for every
|
|
file, so matching block size to the average size of your files
|
|
is important if you have many files.
|
|
</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
> Limit data growth. Runaway processes or maniacal users can
|
|
consume so much disk space that the operating system no longer
|
|
has room on the hard drive for its bookkeeping operations. This
|
|
will lead to disaster. By segregating space, you ensure that
|
|
things other than the operating system die when allocated disk
|
|
space is exhausted.
|
|
</P
|
|
></LI
|
|
></UL
|
|
>
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN57"
|
|
></A
|
|
>1.2. Other Partitioning Software:</H2
|
|
><P
|
|
> <P
|
|
></P
|
|
><UL
|
|
><LI
|
|
><P
|
|
><B
|
|
CLASS="command"
|
|
>sfdisk</B
|
|
>: a command-line version of fdisk</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
><B
|
|
CLASS="command"
|
|
>cfdisk</B
|
|
>: a curses-based version of fdisk</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
><A
|
|
HREF="http://www.gnu.org/software/parted/parted.html"
|
|
TARGET="_top"
|
|
><B
|
|
CLASS="command"
|
|
>parted</B
|
|
></A
|
|
>: Gnu partition editor</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
><A
|
|
HREF="http://www.powerquest.com/partitionmagic/index.html"
|
|
TARGET="_top"
|
|
><SPAN
|
|
CLASS="productname"
|
|
>Partition Magic</SPAN
|
|
></A
|
|
>:
|
|
a commercial utility to create, resize, merge and convert partitions, without destroying data.
|
|
</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
><A
|
|
HREF="http://www.linux-mandrake.com/diskdrake"
|
|
TARGET="_top"
|
|
><SPAN
|
|
CLASS="productname"
|
|
>Disk Drake</SPAN
|
|
></A
|
|
>: a Perl/Gtk program to create, rsize, and delete partitions</P
|
|
></LI
|
|
></UL
|
|
>
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="howtos"
|
|
></A
|
|
>1.3. Related HOWTOs</H2
|
|
><P
|
|
> <DIV
|
|
CLASS="table"
|
|
><A
|
|
NAME="AEN82"
|
|
></A
|
|
><P
|
|
><B
|
|
>Table 1. Related HOWTOs</B
|
|
></P
|
|
><TABLE
|
|
BORDER="1"
|
|
CLASS="CALSTABLE"
|
|
><THEAD
|
|
><TR
|
|
><TH
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>Title</TH
|
|
><TH
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>Author</TH
|
|
><TH
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>Description</TH
|
|
></TR
|
|
></THEAD
|
|
><TBODY
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
><A
|
|
HREF="http://www.tldp.org/HOWTO/Install-Strategies"
|
|
TARGET="_top"
|
|
> Dual boot install strategies</A
|
|
>
|
|
</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
> <A
|
|
HREF="mailto:tobbyb@usa.net"
|
|
TARGET="_top"
|
|
>Gjoen Stein</A
|
|
>
|
|
</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
> How to estimate the various size and speed requirements for
|
|
different parts of the filesystem.
|
|
</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
><A
|
|
HREF="http://www.nyx.net/~sgjoen/disk.html"
|
|
TARGET="_top"
|
|
>Linux Multiple
|
|
Disk System Tuning</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
><A
|
|
HREF="mailto:sgjoen@mail.nyx.net"
|
|
TARGET="_top"
|
|
>Gjoen Stein</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>How to estimate the various size and speed requirements for
|
|
different parts of the filesystem.</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
> <A
|
|
HREF="http://www.tldp.org/HOWTO/Large-Disk-HOWTO.html"
|
|
TARGET="_top"
|
|
> Linux Large Disk
|
|
</A
|
|
>
|
|
</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
> <A
|
|
HREF="mailto:aeb@cwi.nl"
|
|
TARGET="_top"
|
|
> Andries Brouwer
|
|
</A
|
|
>
|
|
</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
> Instructions and considerations regarding disks with more than 1024 cylinders
|
|
</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
> <A
|
|
HREF="http://metalab.unc.edu/mdw/HOWTO/mini/Quota.html"
|
|
TARGET="_top"
|
|
> Linux Quota
|
|
</A
|
|
>
|
|
</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
> <A
|
|
HREF="mailto:mailto:r.vdooren@snow.nl"
|
|
TARGET="_top"
|
|
> Ralf van Dooren
|
|
</A
|
|
>
|
|
</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
> Instructions on limiting disk space usage per user (quotas)
|
|
</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
> <A
|
|
HREF="http://www.linuxdocs.org/HOWTOs/mini/Partition-Rescue.html"
|
|
TARGET="_top"
|
|
> Partition-Rescue mini-HOWTO
|
|
</A
|
|
>
|
|
</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
> <A
|
|
HREF="mailto:jdanield@dodin.net"
|
|
TARGET="_top"
|
|
> Jean-Daniel Dodin
|
|
</A
|
|
>
|
|
</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
> How to restore linux partitions after they have been deleted by a
|
|
Windows install. Does not appear to preserve data.
|
|
</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
> <A
|
|
HREF="http://www.tldp.org/HOWTO/ADSM-Backup.html"
|
|
TARGET="_top"
|
|
> Linux ADSM Backup
|
|
</A
|
|
>
|
|
</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
> <A
|
|
HREF="mailto:Thomas.Koenig@ciw.uni-karlsruhe.de"
|
|
TARGET="_top"
|
|
> Thomas Koenig
|
|
</A
|
|
>
|
|
</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
> Instructions on integrating Linux into an IBM ADSM backup
|
|
environment.
|
|
</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
> <A
|
|
HREF="http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/Backup-With-MSDOS.html"
|
|
TARGET="_top"
|
|
> Linux Backup with MSDOS
|
|
</A
|
|
>
|
|
</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
> <A
|
|
HREF="mailto:neufeld@physics.utoronto.ca"
|
|
TARGET="_top"
|
|
> Christopher Neufeld
|
|
</A
|
|
>
|
|
</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
> Information about MS-DOS driven Linux backups.
|
|
</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
> Linux HOWTO Index</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
><A
|
|
HREF="mailto:linux-howto@sunsite.unc.edu"
|
|
TARGET="_top"
|
|
>Tim Bynum</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>Instructions on writing and submitting a HOWTO document</TD
|
|
></TR
|
|
></TBODY
|
|
></TABLE
|
|
></DIV
|
|
>
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN141"
|
|
></A
|
|
>1.4. Additional information on your system:</H2
|
|
><P
|
|
> <P
|
|
></P
|
|
><UL
|
|
><LI
|
|
><P
|
|
> <A
|
|
HREF="file:/usr/src/linux/Documentation"
|
|
TARGET="_top"
|
|
><TT
|
|
CLASS="filename"
|
|
>/usr/src/linux/Documentation</TT
|
|
></A
|
|
>
|
|
<P
|
|
></P
|
|
><UL
|
|
><LI
|
|
><P
|
|
> <A
|
|
HREF="file:/usr/src/linux/Documentation/ide.txt"
|
|
TARGET="_top"
|
|
> <TT
|
|
CLASS="filename"
|
|
>ide.txt</TT
|
|
></A
|
|
>:
|
|
Info about your IDE drivers
|
|
</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
> <A
|
|
HREF="file:/usr/src/linux/Documentation/scsi.txt"
|
|
TARGET="_top"
|
|
><TT
|
|
CLASS="filename"
|
|
>scsi.txt</TT
|
|
></A
|
|
>:
|
|
Info about your SCSI drivers
|
|
</P
|
|
></LI
|
|
></UL
|
|
>
|
|
</P
|
|
></LI
|
|
></UL
|
|
>
|
|
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect1"
|
|
><HR><H1
|
|
CLASS="sect1"
|
|
><A
|
|
NAME="devices"
|
|
></A
|
|
>2. Devices</H1
|
|
><P
|
|
> There is a special nomenclature that linux uses to refer to hard drive
|
|
partitions that must be understood in order to follow the discussion
|
|
on the following pages.
|
|
</P
|
|
><P
|
|
> In Linux, partitions are represented by device files. These are phoney
|
|
files located in <TT
|
|
CLASS="filename"
|
|
>/dev</TT
|
|
>. Here are a few entries:
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> brw-rw---- 1 root disk 3, 0 May 5 1998 hda
|
|
brw-rw---- 1 root disk 8, 0 May 5 1998 sda
|
|
crw------- 1 root tty 4, 64 May 5 1998 ttyS0
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
A device file is a file with type c ( for "character" devices, devices
|
|
that do not use the buffer cache) or b (for "block" devices, which go
|
|
through the buffer cache). In Linux, all disks are represented as
|
|
block devices only.
|
|
</P
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="names"
|
|
></A
|
|
>2.1. Device names</H2
|
|
><DIV
|
|
CLASS="sect3"
|
|
><H3
|
|
CLASS="sect3"
|
|
><A
|
|
NAME="NamingConvention"
|
|
></A
|
|
>2.1.1. Naming Convention</H3
|
|
><P
|
|
> By convention, IDE drives will be given device
|
|
names <TT
|
|
CLASS="literal"
|
|
>/dev/hda</TT
|
|
> to <TT
|
|
CLASS="literal"
|
|
>/dev/hdd</TT
|
|
>.
|
|
<EM
|
|
>H</EM
|
|
>ard <EM
|
|
>D</EM
|
|
>rive
|
|
<EM
|
|
>A</EM
|
|
> (<TT
|
|
CLASS="literal"
|
|
>/dev/hda</TT
|
|
>) is the first drive and
|
|
<EM
|
|
>H</EM
|
|
>ard <EM
|
|
>D</EM
|
|
>rive
|
|
<EM
|
|
>C</EM
|
|
> (<TT
|
|
CLASS="literal"
|
|
>/dev/hdc</TT
|
|
>) is the third.
|
|
|
|
|
|
<DIV
|
|
CLASS="table"
|
|
><A
|
|
NAME="AEN179"
|
|
></A
|
|
><P
|
|
><B
|
|
>Table 2. IDE controller naming convention</B
|
|
></P
|
|
><TABLE
|
|
BORDER="1"
|
|
CLASS="CALSTABLE"
|
|
><TBODY
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>drive name</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>drive controller</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>drive number</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hda</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hdb</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>2</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hdc</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>2</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hdd</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>2</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>2</TD
|
|
></TR
|
|
></TBODY
|
|
></TABLE
|
|
></DIV
|
|
>
|
|
</P
|
|
><P
|
|
> A typical PC has two IDE
|
|
controllers, each of which can have two drives connected to it. For
|
|
example, <TT
|
|
CLASS="filename"
|
|
>/dev/hda</TT
|
|
> is the first drive (master) on the
|
|
first IDE controller and <TT
|
|
CLASS="filename"
|
|
>/dev/hdd</TT
|
|
> is
|
|
the second (slave) drive on the second controller (the fourth IDE
|
|
drive in the computer).
|
|
</P
|
|
><P
|
|
> You can write to these devices directly (using <B
|
|
CLASS="command"
|
|
>cat</B
|
|
> or
|
|
<B
|
|
CLASS="command"
|
|
>dd</B
|
|
>). However,
|
|
since these devices represent the entire disk, starting at the first
|
|
block, you can mistakenly overwrite the master boot record and the
|
|
partition table, which will render the drive unusable.
|
|
</P
|
|
><P
|
|
> <DIV
|
|
CLASS="table"
|
|
><A
|
|
NAME="AEN213"
|
|
></A
|
|
><P
|
|
><B
|
|
>Table 3. partition names</B
|
|
></P
|
|
><TABLE
|
|
BORDER="1"
|
|
CLASS="CALSTABLE"
|
|
><TBODY
|
|
><TR
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>drive name</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>drive controller</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>drive number</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>partition type</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>partition number</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hda1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>primary</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hda2</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>primary</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>2</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hda3</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>primary</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>3</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hda4</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>swap</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>NA</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hdb1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>2</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>primary</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hdb2</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>2</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>primary</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>2</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hdb3</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>2</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>primary</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>3</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hdb4</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>2</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>primary</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>4</TD
|
|
></TR
|
|
></TBODY
|
|
></TABLE
|
|
></DIV
|
|
>
|
|
</P
|
|
><P
|
|
> Once a drive has been partitioned, the partitions will represented
|
|
as numbers on the end of the names. For example, the second
|
|
partition on the second drive will be
|
|
<TT
|
|
CLASS="filename"
|
|
>/dev/hdb2</TT
|
|
>. The partition type (primary) is
|
|
listed in the table above for clarity, although the concept is not
|
|
explained until <A
|
|
HREF="#primary"
|
|
>Section 3.3</A
|
|
>.
|
|
</P
|
|
><P
|
|
> <DIV
|
|
CLASS="table"
|
|
><A
|
|
NAME="AEN280"
|
|
></A
|
|
><P
|
|
><B
|
|
>Table 4. SCSI Drives</B
|
|
></P
|
|
><TABLE
|
|
BORDER="1"
|
|
CLASS="CALSTABLE"
|
|
><TBODY
|
|
><TR
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>drive name</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>drive controller</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>drive number</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>partition type</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>partition number</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/sda1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>6</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>primary</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/sda2</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>6</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>primary</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>2</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/sda3</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>6</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>primary</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>3</TD
|
|
></TR
|
|
></TBODY
|
|
></TABLE
|
|
></DIV
|
|
>
|
|
|
|
</P
|
|
><P
|
|
> SCSI drives follow a similar pattern; They are represented by 'sd'
|
|
instead of 'hd'. The first partition of the second SCSI drive would
|
|
therefore be <TT
|
|
CLASS="filename"
|
|
>/dev/sdb1</TT
|
|
>. In
|
|
the table above, the drive number is arbitraily chosen to be 6 to
|
|
introduce the idea that SCSI ID numbers do not map onto device names
|
|
under linux.
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect3"
|
|
><HR><H3
|
|
CLASS="sect3"
|
|
><A
|
|
NAME="AEN315"
|
|
></A
|
|
>2.1.2. Name Assignment</H3
|
|
><P
|
|
> Under (Sun) Solaris and (SGI) IRIX, the device name given to a
|
|
SCSI drive has some relationship to where you plug it in. Under
|
|
linux, there is only wailing and gnashing of teeth.
|
|
</P
|
|
><P
|
|
> <EM
|
|
>Before</EM
|
|
>
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> SCSI ID #2 SCSI ID #5 SCSI ID #7 SCSI ID #8
|
|
/dev/sda /dev/sdb /dev/sdc /dev/sdd
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
</P
|
|
><P
|
|
> <EM
|
|
>After</EM
|
|
>
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> SCSI ID #2 SCSI ID #7 SCSI ID #8
|
|
/dev/sda /dev/sdb /dev/sdc
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
</P
|
|
><P
|
|
> SCSI drives have ID numbers which go from 1 through 15. Lower SCSI
|
|
ID numbers are assigned lower-order letters. For example, if you
|
|
have two drives numbered 2 and 5, then #2 will be
|
|
<TT
|
|
CLASS="filename"
|
|
>/dev/sda</TT
|
|
> and #5 will be
|
|
<TT
|
|
CLASS="filename"
|
|
>/dev/sdb</TT
|
|
>. If you remove either, all the higher
|
|
numbered drives will be renamed the next time you boot up.
|
|
</P
|
|
><P
|
|
> If you have two SCSI controllers in your linux box, you will need to
|
|
examine the output of <B
|
|
CLASS="command"
|
|
>/bin/dmesg</B
|
|
> in order to
|
|
see what name each drive was assigned. If you remove one of two
|
|
controllers, the remaining controller might have all its drives
|
|
renamed. Grrr...
|
|
</P
|
|
><P
|
|
> There are two work-arounds; both involve using a program to put a
|
|
label on each partition (see <A
|
|
HREF="#labels"
|
|
>Section 6</A
|
|
>). The label is
|
|
persistent even when the device is physically moved. You then refer
|
|
to the partition directly or indirectly by label.
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect3"
|
|
><HR><H3
|
|
CLASS="sect3"
|
|
><A
|
|
NAME="AEN331"
|
|
></A
|
|
>2.1.3. Logical Partitions</H3
|
|
><P
|
|
>
|
|
<DIV
|
|
CLASS="table"
|
|
><A
|
|
NAME="AEN334"
|
|
></A
|
|
><P
|
|
><B
|
|
>Table 5. Logical Partitions</B
|
|
></P
|
|
><TABLE
|
|
BORDER="1"
|
|
CLASS="CALSTABLE"
|
|
><TBODY
|
|
><TR
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>drive name</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>drive controller</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>drive number</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>partition type</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>partition number</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hdb1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>2</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>primary</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hdb2</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>2</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>extended</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>NA</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hda5</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>2</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>logical</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>2</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hdb6</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>2</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>logical</TD
|
|
><TD
|
|
WIDTH="20%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>3</TD
|
|
></TR
|
|
></TBODY
|
|
></TABLE
|
|
></DIV
|
|
>
|
|
|
|
</P
|
|
><P
|
|
> The table above illustrates a mysterious jump in the name
|
|
assignments. This is due to the use of logical partitions (see <A
|
|
HREF="#logical"
|
|
>Section 3.4</A
|
|
>, which always start with 5, for
|
|
reasons explained later.
|
|
</P
|
|
><P
|
|
> This is all you have to know to deal with linux disk devices. For
|
|
the sake of completeness, see Kristian's discussion of device
|
|
numbers below.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="numbers"
|
|
></A
|
|
>2.2. Device numbers</H2
|
|
><P
|
|
> The only important thing with a device file are its major and minor
|
|
device numbers, which are shown instead of the file size:
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> $ ls -l /dev/hda
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
<DIV
|
|
CLASS="table"
|
|
><A
|
|
NAME="AEN380"
|
|
></A
|
|
><P
|
|
><B
|
|
>Table 6. Device file attributes</B
|
|
></P
|
|
><TABLE
|
|
BORDER="1"
|
|
CLASS="CALSTABLE"
|
|
><TBODY
|
|
><TR
|
|
><TD
|
|
WIDTH="12%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>brw-rw----</TD
|
|
><TD
|
|
WIDTH="12%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>1</TD
|
|
><TD
|
|
WIDTH="12%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>root</TD
|
|
><TD
|
|
WIDTH="12%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>disk</TD
|
|
><TD
|
|
WIDTH="12%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>3,</TD
|
|
><TD
|
|
WIDTH="12%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>0</TD
|
|
><TD
|
|
WIDTH="12%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>Jul 18 1994</TD
|
|
><TD
|
|
WIDTH="12%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hda</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="12%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>permissions</TD
|
|
><TD
|
|
WIDTH="12%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
> </TD
|
|
><TD
|
|
WIDTH="12%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>owner</TD
|
|
><TD
|
|
WIDTH="12%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>group</TD
|
|
><TD
|
|
WIDTH="12%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>major device number</TD
|
|
><TD
|
|
WIDTH="12%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>minor device number</TD
|
|
><TD
|
|
WIDTH="12%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>date</TD
|
|
><TD
|
|
WIDTH="12%"
|
|
ALIGN="CENTER"
|
|
VALIGN="MIDDLE"
|
|
>device name</TD
|
|
></TR
|
|
></TBODY
|
|
></TABLE
|
|
></DIV
|
|
>
|
|
</P
|
|
><P
|
|
>When accessing a device file, the major number
|
|
selects which device driver is being called to perform the
|
|
input/output operation. This call is being done with the minor number
|
|
as a parameter and it is entirely up to the driver how the minor
|
|
number is being interpreted. The driver documentation usually
|
|
describes how the driver uses minor numbers. For IDE disks, this
|
|
documentation is in
|
|
<A
|
|
HREF="file:/usr/src/linux/Documentation/ide.txt"
|
|
TARGET="_top"
|
|
> <TT
|
|
CLASS="filename"
|
|
>/usr/src/linux/Documentation/ide.txt</TT
|
|
></A
|
|
>.
|
|
For SCSI disks, one would expect such documentation in
|
|
<A
|
|
HREF="file:/usr/src/linux/Documentation/scsi.txt"
|
|
TARGET="_top"
|
|
> <TT
|
|
CLASS="filename"
|
|
>/usr/src/linux/Documentation/scsi.txt</TT
|
|
></A
|
|
>,
|
|
but it isn't there. One has to look at the driver source to be sure
|
|
(<A
|
|
HREF="file:/usr/src/linux/driver/scsi/sd.c"
|
|
TARGET="_top"
|
|
> <TT
|
|
CLASS="filename"
|
|
>/usr/src/linux/driver/scsi/sd.c</TT
|
|
></A
|
|
>:184-196).
|
|
Fortunately,
|
|
there is Peter Anvin's list of device numbers and names in
|
|
<A
|
|
HREF="file:/usr/src/linux/Documentation/devices.txt"
|
|
TARGET="_top"
|
|
> <TT
|
|
CLASS="filename"
|
|
>/usr/src/linux/Documentation/devices.txt</TT
|
|
></A
|
|
>;
|
|
see the entries for block devices, major 3, 22, 33, 34 for IDE and
|
|
major 8 for SCSI disks. The major and minor numbers are a byte each
|
|
and that is why the number of partitions per disk is limited.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect1"
|
|
><HR><H1
|
|
CLASS="sect1"
|
|
><A
|
|
NAME="partition-types"
|
|
></A
|
|
>3. Partition Types</H1
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="types"
|
|
></A
|
|
>3.1. Partition Types</H2
|
|
><P
|
|
> A partition is labeled to host a certain kind of file system (not to
|
|
be confused with a volume label (see <A
|
|
HREF="#labels"
|
|
>Section 6</A
|
|
>)).
|
|
Such a file system could be the linux standard ext2 file system or
|
|
linux swap space, or even foreign file systems like (Microsoft) NTFS
|
|
or (Sun) UFS. There is a numerical code associated with each
|
|
partition type. For example, the code for ext2 is
|
|
<TT
|
|
CLASS="literal"
|
|
>0x83</TT
|
|
> and linux swap is <TT
|
|
CLASS="literal"
|
|
>0x82</TT
|
|
>.
|
|
To see a list of partition types and their codes, execute
|
|
<TT
|
|
CLASS="userinput"
|
|
><B
|
|
><B
|
|
CLASS="command"
|
|
>/sbin/sfdisk</B
|
|
> -T </B
|
|
></TT
|
|
>
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN429"
|
|
></A
|
|
>3.2. Foreign Partition Types</H2
|
|
><P
|
|
> The partition type codes have been arbitrarily chosen (you can't
|
|
figure out what they should be) and they are particular to a given
|
|
operating system. Therefore, it is theoretically possible that if
|
|
you use two operating systems with the same hard drive, the same
|
|
code might be used to designate two different partition types. OS/2
|
|
marks its partitions with a 0x07 type and so does Windows NT's NTFS.
|
|
MS-DOS allocates several type codes for its various flavors of FAT
|
|
file systems: 0x01, 0x04 and 0x06 are known. DR-DOS used 0x81 to
|
|
indicate protected FAT partitions, creating a type clash with
|
|
Linux/Minix at that time, but neither Linux/Minix nor DR-DOS are
|
|
widely used any more.
|
|
</P
|
|
><P
|
|
>
|
|
OS/2 marks its partitions with a <TT
|
|
CLASS="literal"
|
|
>0x07</TT
|
|
> type and
|
|
so does Windows NT's NTFS. MS-DOS allocates several type codes for
|
|
its various flavors of FAT file systems: 0x01,
|
|
<TT
|
|
CLASS="literal"
|
|
>0x04</TT
|
|
> and <TT
|
|
CLASS="literal"
|
|
>0x06</TT
|
|
> are known.
|
|
DR-DOS used <TT
|
|
CLASS="literal"
|
|
>0x81</TT
|
|
> to indicate protected FAT
|
|
partitions, creating a type clash with Linux/Minix at that time,
|
|
but neither Linux/Minix nor DR-DOS are widely used any more.
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="primary"
|
|
></A
|
|
>3.3. Primary Partitions</H2
|
|
><P
|
|
> The number of partitions on an Intel-based system was limited from
|
|
the very beginning: The original partition table was installed as
|
|
part of the boot sector and held space for only four partition
|
|
entries. These partitions are now called primary partitions.
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="logical"
|
|
></A
|
|
>3.4. Logical Partitions</H2
|
|
><P
|
|
> One primary partition of a hard drive may be subpartitioned. These
|
|
are logical partitions. This effectively allows us to skirt the
|
|
historical four partition limitation.
|
|
</P
|
|
><P
|
|
> The primary partition used to house the logical partitions is called
|
|
an extended partition and it has its own file system type (0x05).
|
|
Unlike primary partitions, logical partitions must be contiguous.
|
|
Each logical partition contains a pointer to the next logical
|
|
partition, which implies that the number of logical partitions is
|
|
unlimited. However, linux imposes limits on the total number of any
|
|
type of partition on a drive, so this effectively limits the number
|
|
of logical partitions. This is at most 15 partitions total on an
|
|
SCSI disk and 63 total on an IDE disk.
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="swap-partitions"
|
|
></A
|
|
>3.5. Swap Partitions</H2
|
|
><P
|
|
> Every process running on your computer is allocated a number of
|
|
blocks of RAM. These blocks are called pages. The set of in-memory
|
|
pages which will be referenced by the processor in the very near
|
|
future is called a "working set." Linux tries to predict these
|
|
memory accesses (assuming that recently used pages will be used
|
|
again in the near future) and keeps these pages in RAM if possible.
|
|
</P
|
|
><P
|
|
> If you have too many processes running on a machine, the kernel will
|
|
try to free up RAM by writing pages to disk. This is what swap space
|
|
is for. It effectively increases the amount of memory you have
|
|
available. However, disk I/O is about a hundred times slower than
|
|
reading from and writing to RAM. Consider this emergency memory and
|
|
not extra memory.
|
|
</P
|
|
><P
|
|
> If memory becomes so scarce that the kernel pages out from the
|
|
working set of one process in order to page in for another, the
|
|
machine is said to be thrashing. Some readers might have
|
|
inadvertenly experienced this: the hard drive is grinding away like
|
|
crazy, but the computer is slow to the point of being unusable. Swap
|
|
space is something you need to have, but it is no substitute for
|
|
sufficient RAM. See the discussion in <A
|
|
HREF="#SwapSize"
|
|
>Section 4.4</A
|
|
> for tips on determining the size of swap space
|
|
you need.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect1"
|
|
><HR><H1
|
|
CLASS="sect1"
|
|
><A
|
|
NAME="requirements"
|
|
></A
|
|
>4. Partitioning requirements</H1
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="number"
|
|
></A
|
|
>4.1. What Partitions do I need?</H2
|
|
><P
|
|
> For the Boot Drive:
|
|
If you want to boot your operating system from the drive you are about
|
|
to partition, you will need:
|
|
<P
|
|
></P
|
|
><UL
|
|
><LI
|
|
><P
|
|
>A primary partition</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>One or more swap partitions</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>Zero or more primary/logical partitions</P
|
|
></LI
|
|
></UL
|
|
>
|
|
For any other drive:
|
|
<P
|
|
></P
|
|
><UL
|
|
><LI
|
|
><P
|
|
>One or more primary/logical partitions</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>Zero or more swap partitions</P
|
|
></LI
|
|
></UL
|
|
>
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN467"
|
|
></A
|
|
>4.2. Discussion:</H2
|
|
><P
|
|
></P
|
|
><DIV
|
|
CLASS="variablelist"
|
|
><DL
|
|
><DT
|
|
><A
|
|
NAME="boot"
|
|
></A
|
|
>Boot Partition:</DT
|
|
><DD
|
|
><P
|
|
> Your boot partition ought to be a primary partition, not a logical
|
|
partition. This will ease recovery in case of disaster, but it is
|
|
not technically necessary. It must be of type
|
|
<TT
|
|
CLASS="literal"
|
|
>0x83</TT
|
|
> "Linux native". If you are using a version
|
|
of <A
|
|
HREF="http://tldp.org/HOWTO/LILO.html"
|
|
TARGET="_top"
|
|
><B
|
|
CLASS="command"
|
|
>lilo</B
|
|
></A
|
|
> before 21-3 (ie, from the 1990s), your boot partition must be
|
|
contained within the first 1024 cylinders of the drive. (Typically,
|
|
the boot partition need only contain the kernel image.)
|
|
</P
|
|
><P
|
|
> If you have more than one boot partition (from other OSs, for
|
|
example,) keep them all in the first 1024 cylinders
|
|
(<EM
|
|
>All</EM
|
|
> DOS partitions must be within the first
|
|
1024). If you are using a modern version of lilo, or a means other
|
|
than lilo to load your kernel (for example, a boot disk or the
|
|
<B
|
|
CLASS="command"
|
|
>LOADLIN.EXE</B
|
|
> MS-DOS based Linux loader), the
|
|
partition can be anywhere. See the <A
|
|
HREF="http://www.tldp.org/HOWTO/Large-Disk-HOWTO.html"
|
|
TARGET="_top"
|
|
>Large-disk</A
|
|
>
|
|
HOWTO for details.
|
|
</P
|
|
></DD
|
|
><DT
|
|
><A
|
|
NAME="swap-definition"
|
|
></A
|
|
>Swap Partition:</DT
|
|
><DD
|
|
><P
|
|
> Unless you swap to files (see <A
|
|
HREF="#swapfiles"
|
|
>Section 9.2</A
|
|
>) you will
|
|
need a dedicated swap partition. It must be of type
|
|
<TT
|
|
CLASS="literal"
|
|
>0x82</TT
|
|
> "Linux swap". It may be positioned anywhere on
|
|
the disk (but see <A
|
|
HREF="#SwapPlacement"
|
|
>Section 4.4.3</A
|
|
>). Either a primary or
|
|
logical partition can be used for swap. More than one swap partition can
|
|
exist on a drive. 8 total (across drives) are permitted. See notes on
|
|
swap size below (<A
|
|
HREF="#SwapSize"
|
|
>Section 4.4</A
|
|
>).
|
|
</P
|
|
></DD
|
|
><DT
|
|
><A
|
|
NAME="logical-definition"
|
|
></A
|
|
>Logical Partition:</DT
|
|
><DD
|
|
><P
|
|
> A single primary partition must be used as a container (extended
|
|
partition) for the logical partitions. The extended partition can go
|
|
anywhere on the disk. The logical partitions must be contiguous, but
|
|
needn't fill the extended partition.
|
|
</P
|
|
></DD
|
|
></DL
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN493"
|
|
></A
|
|
>4.3. File Systems</H2
|
|
><DIV
|
|
CLASS="sect3"
|
|
><H3
|
|
CLASS="sect3"
|
|
><A
|
|
NAME="filesystems"
|
|
></A
|
|
>4.3.1. Which file systems need their own partitions?</H3
|
|
><P
|
|
> Everything in your linux file system can go in the same (single)
|
|
partition. However, there are circumstances when you may want to
|
|
restrict the growth of certain file systems. For example, if your mail
|
|
spool was in the same partition as your root fs and it filled the
|
|
remaining space in the partition, your computer would basically
|
|
hang.
|
|
</P
|
|
><P
|
|
></P
|
|
><DIV
|
|
CLASS="variablelist"
|
|
><DL
|
|
><DT
|
|
><TT
|
|
CLASS="filename"
|
|
>/var</TT
|
|
></DT
|
|
><DD
|
|
><P
|
|
>This fs contains spool directories such as those for mail and
|
|
printing. In addition, it contains the error log
|
|
directory. If your machine is a server and develops a
|
|
chronic error, those msgs can fill the partition. Server
|
|
computers ought to have /var in a different partition than
|
|
/.
|
|
</P
|
|
></DD
|
|
><DT
|
|
><TT
|
|
CLASS="filename"
|
|
>/usr</TT
|
|
></DT
|
|
><DD
|
|
><P
|
|
>This is where most executable binaries go. In addition, the
|
|
kernel source tree goes here, and much documentation.
|
|
</P
|
|
></DD
|
|
><DT
|
|
><TT
|
|
CLASS="filename"
|
|
>/tmp</TT
|
|
></DT
|
|
><DD
|
|
><P
|
|
>Some programs write temporary data files here. Usually, they
|
|
are quite small. However, if you run computationally
|
|
intensive jobs, like science or engineering applications,
|
|
hundreds of megabytes could be required for brief periods of
|
|
time. In this case, keep /tmp in a different partition than
|
|
/.
|
|
</P
|
|
></DD
|
|
><DT
|
|
><TT
|
|
CLASS="filename"
|
|
>/home</TT
|
|
></DT
|
|
><DD
|
|
><P
|
|
>This is where users home directories go. If you do not impose
|
|
quotas on your users, this ought to be in its own partition.
|
|
</P
|
|
></DD
|
|
><DT
|
|
><TT
|
|
CLASS="filename"
|
|
>/boot</TT
|
|
></DT
|
|
><DD
|
|
><P
|
|
>This is where your kernel images go. See discussion above
|
|
for placement on old systems.
|
|
</P
|
|
></DD
|
|
></DL
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect3"
|
|
><HR><H3
|
|
CLASS="sect3"
|
|
><A
|
|
NAME="backups"
|
|
></A
|
|
>4.3.2. File lifetimes and backup cycles as partitioning criteria</H3
|
|
><P
|
|
>With ext2, partitioning decisions should be governed by backup
|
|
considerations and to avoid external fragmentation <A
|
|
HREF="#fragmentation"
|
|
>Section 10.4</A
|
|
>
|
|
from different file lifetimes.
|
|
</P
|
|
><P
|
|
>Files have lifetimes. After a file has been created, it will
|
|
remain some time on the system and then be removed. File
|
|
lifetime varies greatly throughout the system and is partly
|
|
dependent on the pathname of the file. For example, files in
|
|
<TT
|
|
CLASS="filename"
|
|
>/bin</TT
|
|
>, <TT
|
|
CLASS="filename"
|
|
>/sbin</TT
|
|
>, <TT
|
|
CLASS="filename"
|
|
>/usr/sbin</TT
|
|
>, <TT
|
|
CLASS="filename"
|
|
>/usr/bin</TT
|
|
> and similar directories are
|
|
likely to have a very long lifetime: many months and above.
|
|
Files in <TT
|
|
CLASS="filename"
|
|
>/home</TT
|
|
> are likely to have a medium lifetime: several
|
|
weeks or so. File in <TT
|
|
CLASS="filename"
|
|
>/var</TT
|
|
> are usually short lived: Almost no
|
|
file in <TT
|
|
CLASS="filename"
|
|
>/var/spool/news</TT
|
|
> will remain longer than a few days,
|
|
files in <TT
|
|
CLASS="filename"
|
|
>/var/spool/lpd</TT
|
|
> measure their lifetime in minutes or
|
|
less.
|
|
</P
|
|
><P
|
|
> For backup it is useful if the amount of daily backup is smaller
|
|
than the capacity of a single backup medium. A daily backup can be a
|
|
complete backup or an incremental backup.
|
|
</P
|
|
><P
|
|
> You can decide to keep your partition sizes small enough that they
|
|
fit completely onto one backup medium (choose daily full backups).
|
|
In any case a partition should be small enough that its daily delta
|
|
(all modified files) fits onto one backup medium (choose incremental
|
|
backup and expect to change backup media for the weekly/monthly full
|
|
dump - no unattended operation possible).
|
|
</P
|
|
><P
|
|
> Your backup strategy depends on that decision.
|
|
</P
|
|
><P
|
|
> When planning and buying disk space, remember to set aside a
|
|
sufficient amount of money for backup! Unbackuped data is worthless!
|
|
Data reproduction costs are much higher than backup costs for
|
|
virtually everyone!
|
|
</P
|
|
><P
|
|
> For performance it is useful to keep files of different lifetimes on
|
|
different partitions. This way the short lived files on the news
|
|
partition may be fragmented very heavily. This has no impact on the
|
|
performance of the <TT
|
|
CLASS="filename"
|
|
>/</TT
|
|
> or
|
|
<TT
|
|
CLASS="filename"
|
|
>/home</TT
|
|
> partition.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="SwapSize"
|
|
></A
|
|
>4.4. Swap Partitions</H2
|
|
><DIV
|
|
CLASS="sect3"
|
|
><H3
|
|
CLASS="sect3"
|
|
><A
|
|
NAME="AEN546"
|
|
></A
|
|
>4.4.1. How large should my swap space be?</H3
|
|
><P
|
|
> Conventional wisdom creates swap space equal to the amount of RAM. </P
|
|
><P
|
|
> But keep in mind that this is just a rule of thumb. It is easily
|
|
possible to create scenarios where programs have extremely large or
|
|
extremely small working sets (see <A
|
|
HREF="#swap-partitions"
|
|
>Section 3.5</A
|
|
>).
|
|
For example, a simulation program with
|
|
a large data set that is accessed in a very random fashion would
|
|
have almost no noticeable locality of reference in its data segment,
|
|
so its working set would be quite large.
|
|
</P
|
|
><P
|
|
> On the other hand, a graphics program with many simultaneously
|
|
opened JPEGs, all but one iconified, would have a very large data
|
|
segment. But image transformations are all done on one single image,
|
|
most of the memory occupied by the program is not accessed. The same
|
|
is true for an editor with many editor windows where only one window
|
|
is being modified at a time. These programs have - if they are
|
|
designed properly - a very high locality of reference and large
|
|
parts of them can be kept swapped out without too severe performance
|
|
impact. A user who never never quits programs once launched would
|
|
want a lot of swap space for the same reason.
|
|
</P
|
|
><P
|
|
> Servers typically are configured with more swap space than their
|
|
desktop counterparts. Even though a given amount of swap is
|
|
sufficient for its operations, the server might come under transient
|
|
heavy loads which cause it to page out at a high rate. Some
|
|
administrators prefer this to the server crashing altogether. In
|
|
these cases, swap might be several times the size of ram.
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect3"
|
|
><HR><H3
|
|
CLASS="sect3"
|
|
><A
|
|
NAME="max_swap_size"
|
|
></A
|
|
>4.4.2. How large <EM
|
|
>can</EM
|
|
> my swap space be?</H3
|
|
><P
|
|
> Currently, the maximum size of a swap partition is
|
|
architecture-dependent. For i386, m68k, ARM and PowerPC, it is
|
|
"officially" 2Gb. It is 128Gb on alpha, 1Gb on sparc, and 3Tb on
|
|
sparc64. An opteron on the 2.6 kernel can write to a 16 Tb swap
|
|
partition. For linux kernels 2.1 and earlier, the limit is
|
|
128Mb. The partition may be larger than 128 MB, but excess space
|
|
is never used. If you want more than 128 MB of swap for a 2.1
|
|
and earlier kernel, you have to create multiple swap partitions
|
|
(8 max). After 2.4, 32 swap areas are "officially" possible. See
|
|
setting up swap for details.
|
|
</P
|
|
><P
|
|
><EM
|
|
>footnote:</EM
|
|
>
|
|
"official" max swap size: With kernel 2.4, the limit is 64 swap spaces at a
|
|
maximum of 64Gb each, although this is not reflected in the man page
|
|
for <B
|
|
CLASS="command"
|
|
>mkswap</B
|
|
>. With the 64 bit opteron on the 2.6 kernel, 128 swap
|
|
areas are permitted, each a whopping 16 Tb! (thanks to Peter Chubb
|
|
for the calculation)
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect3"
|
|
><HR><H3
|
|
CLASS="sect3"
|
|
><A
|
|
NAME="SwapPlacement"
|
|
></A
|
|
>4.4.3. Where should I put my swap space?</H3
|
|
><P
|
|
> The short answer is anywhere is fine. However, if you are
|
|
interested in extracting as much speed as possible, there are
|
|
two basic strategies (other than buying more RAM).
|
|
</P
|
|
><P
|
|
> <P
|
|
></P
|
|
><UL
|
|
><LI
|
|
><P
|
|
>Split the swap space across multiple drives, or at least on the
|
|
drive you write to least.
|
|
</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>Put each swap partition on the outer tracks.
|
|
</P
|
|
></LI
|
|
></UL
|
|
>
|
|
</P
|
|
><P
|
|
>
|
|
Here are the considerations:
|
|
</P
|
|
><P
|
|
></P
|
|
><UL
|
|
><LI
|
|
><P
|
|
> If you have a disk with many heads and one with less heads and
|
|
both are identical in other parameters, the disk with many heads
|
|
will be faster. Reading data from different heads is fast, since
|
|
it is purely electronic. Reading data from different tracks is
|
|
slow, since it involves physically moving the head.
|
|
</P
|
|
><P
|
|
> It follows then that writing swap on a separate drive will be
|
|
faster than moving the head back and forth on a single drive.
|
|
</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
><EM
|
|
>Placement</EM
|
|
>:
|
|
Older disks have the same number of sectors on all tracks. With
|
|
these disks it will be fastest to put your swap in the middle of
|
|
the disks, assuming that your disk head will move from a random
|
|
track towards the swap area.
|
|
</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>
|
|
Newer disks use ZBR (zone bit recording). They have more sectors
|
|
on the outer tracks. With a constant number of rpms, this yields
|
|
a far greater performance on the outer tracks than on the inner
|
|
ones. Put your swap on the fast tracks. (In general,
|
|
low-numbered cylinders are associated low partition numbers.
|
|
However, see Kristian's more recent <A
|
|
HREF="http://lissot.net/partition/mapping.html"
|
|
TARGET="_top"
|
|
>comments</A
|
|
>
|
|
on this issue. -Tony)
|
|
</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
> <EM
|
|
>Usage</EM
|
|
>:
|
|
Of course your disk head will not move randomly. If you have swap
|
|
space in the middle of a disk between a constantly busy home
|
|
partition and an almost unused archive partition, you would be
|
|
better of if your swap were near the home partition for
|
|
even shorter head movements. You would be even better off, if you
|
|
had your swap on another otherwise unused disk, though.
|
|
</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
> <EM
|
|
>Striping</EM
|
|
>:
|
|
Speed can be increased by writing to multiple swap areas
|
|
simultaneously. Swap spaces with the same priority will be
|
|
written to like a RAID. See <A
|
|
HREF="#multiple_swap_areas"
|
|
>Section 9.3</A
|
|
>.
|
|
</P
|
|
></LI
|
|
></UL
|
|
><P
|
|
><EM
|
|
>Summary:</EM
|
|
>
|
|
Put your swap on a fast disk with many heads that is not busy doing
|
|
other things. If you have multiple disks: Split swap and scatter it
|
|
over all your disks or even different controllers.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect1"
|
|
><HR><H1
|
|
CLASS="sect1"
|
|
><A
|
|
NAME="fdisk_partitioning"
|
|
></A
|
|
>5. Partitioning with fdisk</H1
|
|
><P
|
|
> This section shows you how to actually partition your hard drive with
|
|
the <B
|
|
CLASS="command"
|
|
>fdisk</B
|
|
> utility. Linux allows only 4 primary
|
|
partitions. You can have a much larger number of logical partitions by
|
|
sub-dividing one of the primary partitions. Only one of the primary
|
|
partitions can be sub-divided.
|
|
</P
|
|
><P
|
|
> <EM
|
|
>Examples:</EM
|
|
>
|
|
<P
|
|
></P
|
|
><OL
|
|
TYPE="1"
|
|
><LI
|
|
><P
|
|
> Four primary partitions (see <A
|
|
HREF="#primary-example"
|
|
>Section 5.2</A
|
|
>)
|
|
</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
> Mixed primary and logical partitions (see <A
|
|
HREF="#mixed"
|
|
>Section 5.3</A
|
|
>)
|
|
</P
|
|
></LI
|
|
></OL
|
|
>
|
|
</P
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="fdisk"
|
|
></A
|
|
>5.1. fdisk usage</H2
|
|
><P
|
|
> <B
|
|
CLASS="command"
|
|
>fdisk</B
|
|
> is started by typing (as root)
|
|
<TT
|
|
CLASS="userinput"
|
|
><B
|
|
><B
|
|
CLASS="command"
|
|
>fdisk</B
|
|
>
|
|
<TT
|
|
CLASS="replaceable"
|
|
><I
|
|
>device</I
|
|
></TT
|
|
></B
|
|
></TT
|
|
> at the command prompt.
|
|
<TT
|
|
CLASS="replaceable"
|
|
><I
|
|
>device</I
|
|
></TT
|
|
> might be something like <TT
|
|
CLASS="filename"
|
|
>/dev/hda</TT
|
|
> or <TT
|
|
CLASS="filename"
|
|
>/dev/sda</TT
|
|
> (see <A
|
|
HREF="#NamingConvention"
|
|
>Section 2.1.1</A
|
|
>). The basic
|
|
<B
|
|
CLASS="command"
|
|
>fdisk</B
|
|
> commands you need are:
|
|
</P
|
|
><P
|
|
> <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>p</B
|
|
></TT
|
|
>
|
|
print the partition table
|
|
<P
|
|
> <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>n</B
|
|
></TT
|
|
>
|
|
create a new partition
|
|
</P
|
|
>
|
|
<P
|
|
> <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>d</B
|
|
></TT
|
|
>
|
|
delete a partition
|
|
</P
|
|
>
|
|
<P
|
|
> <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>q</B
|
|
></TT
|
|
>
|
|
quit without saving changes
|
|
</P
|
|
>
|
|
<P
|
|
> <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>w</B
|
|
></TT
|
|
>
|
|
write the new partition table and exit
|
|
</P
|
|
>
|
|
|
|
</P
|
|
><P
|
|
> Changes you make to the partition table do not take effect until you issue the write (w) command.
|
|
Here is a sample partition table:
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> Disk /dev/hdb: 64 heads, 63 sectors, 621 cylinders
|
|
Units = cylinders of 4032 * 512 bytes
|
|
|
|
Device Boot Start End Blocks Id System
|
|
/dev/hdb1 * 1 184 370912+ 83 Linux
|
|
/dev/hdb2 185 368 370944 83 Linux
|
|
/dev/hdb3 369 552 370944 83 Linux
|
|
/dev/hdb4 553 621 139104 82 Linux swap
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
The first line shows the geometry of your hard drive. It may not be
|
|
physically accurate, but you can accept it as though it were. The hard
|
|
drive in this example is made of 32 double-sided platters with one
|
|
head on each side (probably not true). Each platter has 621 concentric
|
|
tracks. A 3-dimensional track (the same track on all disks) is called
|
|
a cylinder. Each track is divided into 63 sectors. Each sector
|
|
contains 512 bytes of data. Therefore the block size in the partition
|
|
table is 64 heads * 63 sectors * 512 bytes er...divided by 1024. (See
|
|
<A
|
|
HREF="#BlockSize"
|
|
>4</A
|
|
> for discussion on
|
|
problems with this calculation.) The start and end values are cylinders.
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="primary-example"
|
|
></A
|
|
>5.2. Four primary partitions</H2
|
|
><P
|
|
> <EM
|
|
>The overview:</EM
|
|
>
|
|
</P
|
|
><P
|
|
> Decide on the size of your swap space (see <A
|
|
HREF="#SwapSize"
|
|
>Section 4.4</A
|
|
>) and where it ought to go (see <A
|
|
HREF="#SwapPlacement"
|
|
>Section 4.4.3</A
|
|
>).
|
|
Divide up the remaining space for the three other partitions.
|
|
</P
|
|
><P
|
|
> Example:
|
|
</P
|
|
><P
|
|
> I start fdisk from the shell prompt:
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> # <TT
|
|
CLASS="userinput"
|
|
><B
|
|
><B
|
|
CLASS="command"
|
|
>fdisk</B
|
|
> <TT
|
|
CLASS="filename"
|
|
>/dev/hdb</TT
|
|
></B
|
|
></TT
|
|
>
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
which indicates that I am using the second drive on my IDE controller.
|
|
(See <A
|
|
HREF="#names"
|
|
>Section 2.1</A
|
|
>.) When I print the (empty) partition table,
|
|
I just get configuration information.
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> Command (m for help): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>p</B
|
|
></TT
|
|
>
|
|
|
|
Disk /dev/hdb: 64 heads, 63 sectors, 621 cylinders
|
|
Units = cylinders of 4032 * 512 bytes
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
I knew that I had a 1.2Gb drive, but now I really know: 64 * 63 * 512
|
|
* 621 = 1281982464 bytes. I decide to reserve 128Mb of that space for
|
|
swap, leaving 1153982464. If I use one of my primary partitions for
|
|
swap, that means I have three left for ext2 partitions. Divided
|
|
equally, that makes for 384Mb per partition. Now I get to work.
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> Command (m for help): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>n</B
|
|
></TT
|
|
>
|
|
Command action
|
|
e extended
|
|
p primary partition (1-4)
|
|
<TT
|
|
CLASS="userinput"
|
|
><B
|
|
>p</B
|
|
></TT
|
|
>
|
|
Partition number (1-4): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>1</B
|
|
></TT
|
|
>
|
|
First cylinder (1-621, default 1):<TT
|
|
CLASS="userinput"
|
|
><B
|
|
><RETURN></B
|
|
></TT
|
|
>
|
|
Using default value 1
|
|
Last cylinder or +size or +sizeM or +sizeK (1-621, default 621): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>+384M</B
|
|
></TT
|
|
>
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
Next, I set up the partition I want to use for swap:
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> Command (m for help): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>n</B
|
|
></TT
|
|
>
|
|
Command action
|
|
e extended
|
|
p primary partition (1-4)
|
|
p
|
|
Partition number (1-4): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>2</B
|
|
></TT
|
|
>
|
|
First cylinder (197-621, default 197):<TT
|
|
CLASS="userinput"
|
|
><B
|
|
><RETURN></B
|
|
></TT
|
|
>
|
|
Using default value 197
|
|
Last cylinder or +size or +sizeM or +sizeK (197-621, default 621): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>+128M</B
|
|
></TT
|
|
>
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
Now the partition table looks like this:
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> Device Boot Start End Blocks Id System
|
|
/dev/hdb1 1 196 395104 83 Linux
|
|
/dev/hdb2 197 262 133056 83 Linux
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
I set up the remaining two partitions the same way I did the first.
|
|
Finally, I make the first partition bootable:
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> Command (m for help): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>a</B
|
|
></TT
|
|
>
|
|
Partition number (1-4): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>1</B
|
|
></TT
|
|
>
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
And I make the second partition of type swap:
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> Command (m for help): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>t</B
|
|
></TT
|
|
>
|
|
Partition number (1-4): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>2</B
|
|
></TT
|
|
>
|
|
Hex code (type L to list codes): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>82</B
|
|
></TT
|
|
>
|
|
Changed system type of partition 2 to 82 (Linux swap)
|
|
Command (m for help): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>p</B
|
|
></TT
|
|
>
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
The end result:
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> Disk /dev/hdb: 64 heads, 63 sectors, 621 cylinders
|
|
Units = cylinders of 4032 * 512 bytes
|
|
|
|
Device Boot Start End Blocks Id System
|
|
/dev/hdb1 * 1 196 395104+ 83 Linux
|
|
/dev/hdb2 197 262 133056 82 Linux swap
|
|
/dev/hdb3 263 458 395136 83 Linux
|
|
/dev/hdb4 459 621 328608 83 Linux
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
Finally, I issue the write command (w) to write the table on the disk.
|
|
</P
|
|
><P
|
|
> Side topics:
|
|
<P
|
|
></P
|
|
><UL
|
|
><LI
|
|
><P
|
|
><A
|
|
HREF="#swap"
|
|
>Section 10.2</A
|
|
></P
|
|
></LI
|
|
><LI
|
|
><P
|
|
><A
|
|
HREF="#formating"
|
|
>Section 10.1</A
|
|
></P
|
|
></LI
|
|
><LI
|
|
><P
|
|
><A
|
|
HREF="#mounting"
|
|
>Section 10.3</A
|
|
></P
|
|
></LI
|
|
></UL
|
|
>
|
|
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="mixed"
|
|
></A
|
|
>5.3. Mixed primary and logical partitions</H2
|
|
><P
|
|
> <EM
|
|
>The overview:</EM
|
|
> create one use one of the primary
|
|
partitions to house all the extra partitions. Then create logical
|
|
partitions within it. Create the other primary partitions before or
|
|
after creating the logical partitions.
|
|
</P
|
|
><P
|
|
> Example:
|
|
</P
|
|
><P
|
|
> I start fdisk from the shell prompt:
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> # fdisk /dev/sda
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
which indicates that I am using the first drive on my SCSI chain.
|
|
(See <A
|
|
HREF="#names"
|
|
>Section 2.1</A
|
|
>.)
|
|
</P
|
|
><P
|
|
> First I figure out how many partitions I want. I know my drive has a
|
|
183Gb capacity and I want 26Gb partitions (because I happen to have
|
|
back-up tapes that are about that size).
|
|
</P
|
|
><P
|
|
> <TT
|
|
CLASS="literal"
|
|
>183Gb / 26Gb = ~7</TT
|
|
>
|
|
</P
|
|
><P
|
|
> so I will need 7 partitions. Even though fdisk accepts partition sizes
|
|
expressed in Mb and Kb, I decide to calculate the number of cylinders
|
|
that will end up in each partition because fdisk reports start and
|
|
stop points in cylinders. I see when I enter fdisk that I have 22800
|
|
cylinders.
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> > The number of cylinders for this disk is set to 22800. There is
|
|
> nothing wrong with that, but this is larger than 1024, and could in
|
|
> certain setups cause problems with: 1) software that runs at boot
|
|
> time (e.g., LILO) 2) booting and partitioning software from other
|
|
> OSs (e.g., DOS FDISK, OS/2 FDISK)
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
So, 22800 total cylinders divided by seven partitions is 3258
|
|
cylinders. Each partition will be about 3258 cylinders long. I ignore
|
|
the warning msg because this is not my boot drive (<A
|
|
HREF="#requirements"
|
|
>Section 4</A
|
|
>).
|
|
</P
|
|
><P
|
|
> Since I have 4 primary partitions, 3 of them can be 3258
|
|
long. The extended partition will have to be (4 * 3258), or 13032,
|
|
cylinders long in order to contain the 4 logical partitions.
|
|
</P
|
|
><P
|
|
> I enter the following commands to set up the first of the 3 primary
|
|
partitions (stuff I type is bold ):
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> Command (m for help): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>n</B
|
|
></TT
|
|
>
|
|
Command action
|
|
e extended
|
|
p primary partition (1-4)
|
|
<TT
|
|
CLASS="userinput"
|
|
><B
|
|
>p</B
|
|
></TT
|
|
>
|
|
Partition number (1-4): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>1</B
|
|
></TT
|
|
>
|
|
First cylinder (1-22800, default 1): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
><RETURN></B
|
|
></TT
|
|
>
|
|
Using default value 1
|
|
Last cylinder or +size or +sizeM or +sizeK (1-22800, default 22800): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>3258</B
|
|
></TT
|
|
>
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
The last partition is the extended partition:
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> Partition number (1-4): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>4</B
|
|
></TT
|
|
>
|
|
First cylinder (9775-22800, default 9775): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
><RETURN></B
|
|
></TT
|
|
>
|
|
Using default value 9775
|
|
Last cylinder or +size or +sizeM or +sizeK (9775-22800, default 22800): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
><RETURN></B
|
|
></TT
|
|
>
|
|
Using default value 22800
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
The result, when I issue the print table command is:
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> /dev/sda1 1 3258 26169853+ 83 Linux
|
|
/dev/sda2 3259 6516 26169885 83 Linux
|
|
/dev/sda3 6517 9774 26169885 83 Linux
|
|
/dev/sda4 9775 22800 104631345 5 Extended
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
Next I segment the extended partition into 4 logical partitions,
|
|
starting with the first logical partition, into 3258-cylinder
|
|
segments. The logical partitions automatically start from /dev/sda5.
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> Command (m for help): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>n</B
|
|
></TT
|
|
>
|
|
First cylinder (9775-22800, default 9775): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
><RETURN></B
|
|
></TT
|
|
>
|
|
Using default value 9775
|
|
Last cylinder or +size or +sizeM or +sizeK (9775-22800, default 22800): 13032
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
The end result is:
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> Device Boot Start End Blocks Id System
|
|
/dev/sda1 1 3258 26169853+ 83 Linux
|
|
/dev/sda2 3259 6516 26169885 83 Linux
|
|
/dev/sda3 6517 9774 26169885 83 Linux
|
|
/dev/sda4 9775 22800 104631345 5 Extended
|
|
/dev/sda5 9775 13032 26169853+ 83 Linux
|
|
/dev/sda6 13033 16290 26169853+ 83 Linux
|
|
/dev/sda7 16291 19584 26459023+ 83 Linux
|
|
/dev/sda8 19585 22800 25832488+ 83 Linux
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
Finally, I issue the write command (w) to write the table on the disk.
|
|
To make the partitions usable, I will have to format (<A
|
|
HREF="#formating"
|
|
>Section 10.1</A
|
|
>)
|
|
each partition and then mount (<A
|
|
HREF="#mounting"
|
|
>Section 10.3</A
|
|
>) it.
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="submitted"
|
|
></A
|
|
>5.4. Submitted Examples</H2
|
|
><P
|
|
> I'd like to submit my partition layout, because it works well with
|
|
any distribution of Linux (even big RPM based ones).
|
|
|
|
I have one hard drive that ... is 10 gigs, exactly. Windows
|
|
can't see above 9.3 gigs of it, but Linux can see it all, and use it
|
|
all. It also has much more than 1024 cylenders.
|
|
|
|
<DIV
|
|
CLASS="table"
|
|
><A
|
|
NAME="AEN711"
|
|
></A
|
|
><P
|
|
><B
|
|
>Table 7. Partition layout example</B
|
|
></P
|
|
><TABLE
|
|
BORDER="1"
|
|
CLASS="CALSTABLE"
|
|
><THEAD
|
|
><TR
|
|
><TH
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>Partition</TH
|
|
><TH
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>Mount point</TH
|
|
><TH
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>Size</TH
|
|
></TR
|
|
></THEAD
|
|
><TBODY
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hda1</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>/boot</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>(15 megs)</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hda2</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>windows 98 partition</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>(2 gigs)</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hda3</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>extended</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>(N/A)</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hda5</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>swap space</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>(64 megs)</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hda6</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>/tmp</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>(50 megs)</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hda7</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>/</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>(150 megs)</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hda8</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>/usr</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>(1.5 gigs)</TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>/dev/hda9</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>/home</TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="LEFT"
|
|
VALIGN="MIDDLE"
|
|
>(rest of drive)</TD
|
|
></TR
|
|
></TBODY
|
|
></TABLE
|
|
></DIV
|
|
>
|
|
|
|
I test new kernels for the USB mass storage, so that explains the large
|
|
/boot partition. I install LILO into the MBR, and by default I boot
|
|
windows (I'm not the only one to use this computer).
|
|
</P
|
|
><P
|
|
> I also noticed that you don't have any REAL examples of partition
|
|
tables, and for newbies I HIGHLY suggest putting quite a few up. I'm
|
|
freshly out of the newbie stage, and partitioning was what messed me up
|
|
the most.
|
|
</P
|
|
><P
|
|
> <A
|
|
HREF="mailto:valkor@qx.net"
|
|
TARGET="_top"
|
|
>Valkor</A
|
|
>
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect1"
|
|
><HR><H1
|
|
CLASS="sect1"
|
|
><A
|
|
NAME="labels"
|
|
></A
|
|
>6. Labels</H1
|
|
><P
|
|
> In linux, hard drives are referred to as devices, and devices are
|
|
pseudo files in <TT
|
|
CLASS="filename"
|
|
>/dev</TT
|
|
>. For
|
|
example, the first partition of the second lowest numbered SCSI
|
|
drive is <TT
|
|
CLASS="filename"
|
|
>/dev/sdb1</TT
|
|
>. If the drive referred to as
|
|
<TT
|
|
CLASS="filename"
|
|
>/dev/sda</TT
|
|
> is removed from the chain, then the
|
|
latter partition is automatically renamed
|
|
<TT
|
|
CLASS="filename"
|
|
>/dev/sda1</TT
|
|
> at reboot.
|
|
</P
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="volumelabels"
|
|
></A
|
|
>6.1. Volume Labels</H2
|
|
><P
|
|
> Volume labels make it possible for partitions to retain a consistent
|
|
name regardless of where they are connected, and regardless of
|
|
whatever else is connected. Labels are not mandatory for a linux
|
|
volume. Each can be a maximum of 16 characters long.
|
|
</P
|
|
><P
|
|
> There are three tools to make volume labels: mke2fs, tune2fs and e2label.
|
|
</P
|
|
><DIV
|
|
CLASS="sect3"
|
|
><HR><H3
|
|
CLASS="sect3"
|
|
><A
|
|
NAME="labelinvocation"
|
|
></A
|
|
>6.1.1. Simple Invocation</H3
|
|
><P
|
|
> <B
|
|
CLASS="command"
|
|
>e2label</B
|
|
> <TT
|
|
CLASS="filename"
|
|
>/dev/hdb1</TT
|
|
> <TT
|
|
CLASS="filename"
|
|
>pubsw</TT
|
|
>
|
|
</P
|
|
><P
|
|
> <B
|
|
CLASS="command"
|
|
>tune2fs</B
|
|
> -L <TT
|
|
CLASS="filename"
|
|
>pubsw</TT
|
|
> <TT
|
|
CLASS="filename"
|
|
>/dev/hdb1</TT
|
|
>
|
|
</P
|
|
><P
|
|
> Either of thse two commands will label the first partition of the
|
|
second drive "pubsw". That label stays with that particular
|
|
partition, even if the drive is moved to another controller or even
|
|
another computer.
|
|
</P
|
|
><P
|
|
> <B
|
|
CLASS="command"
|
|
>mke2fs</B
|
|
> <TT
|
|
CLASS="filename"
|
|
>pubsw</TT
|
|
>
|
|
<TT
|
|
CLASS="filename"
|
|
>/dev/hdb1</TT
|
|
>
|
|
</P
|
|
><P
|
|
> <B
|
|
CLASS="command"
|
|
>mke2fs</B
|
|
> -L <TT
|
|
CLASS="filename"
|
|
>pubsw</TT
|
|
>
|
|
<TT
|
|
CLASS="filename"
|
|
>/dev/hdb1</TT
|
|
>
|
|
</P
|
|
><P
|
|
> will do the same thing as the first two commands - after they make
|
|
the file system. This means that either of these last two commands
|
|
will delete any existing data in the partition.
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect3"
|
|
><HR><H3
|
|
CLASS="sect3"
|
|
><A
|
|
NAME="howtousevolumelabels"
|
|
></A
|
|
>6.1.2. How to Use</H3
|
|
><P
|
|
> Here is a sample fstab. This is a text file located in /etc, which
|
|
is usually set up during the installation of the operating system.
|
|
it describes where each partition wil be mounted, and how it will be
|
|
mounted. It can be modified by you, either through a utility or
|
|
manually, when you add/remove devices.
|
|
</P
|
|
><P
|
|
> <TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> LABEL=/ / ext3 defaults 1 1
|
|
LABEL=/boot /boot ext2 defaults 1 2
|
|
none /dev/pts devpts gid=5,mode=620 0 0
|
|
none /dev/shm tmpfs defaults 0 0
|
|
LABEL=HOME /home ext3 defaults 1 2
|
|
none /proc proc defaults 0 0
|
|
none /sys sysfs defaults 0 0
|
|
LABEL=/usr /usr ext3 defaults 1 2
|
|
/dev/hdc1 /k-space ext3 defaults 1 2
|
|
/dev/hda6 swap swap defaults 0 0
|
|
/dev/hdd /media/cdrecorder auto pamconsole,ro,exec,noauto,managed 0 0
|
|
/dev/fd0 /media/floppy auto pamconsole,exec,noauto,managed 0 0
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
</P
|
|
><P
|
|
> The leftmost column lists devices and the second column lists mount
|
|
points. This example contains a mixture of devices and labels. The
|
|
master drive of the second controller is always mounted on <TT
|
|
CLASS="filename"
|
|
>/k-space</TT
|
|
>.
|
|
The partition labeled "HOME" is always mounted on <TT
|
|
CLASS="filename"
|
|
>/home</TT
|
|
>, regardless
|
|
of which drive it is on or which partition number it has. Notice
|
|
that it is permissible to use mount points as labels, such as "/usr"
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="devicelabels"
|
|
></A
|
|
>6.2. Device Labels</H2
|
|
><P
|
|
> <B
|
|
CLASS="command"
|
|
>devlabel</B
|
|
> is a script which creates symbolic links to devices. For
|
|
example,
|
|
</P
|
|
><P
|
|
> <B
|
|
CLASS="command"
|
|
>devlabel</B
|
|
> -d <TT
|
|
CLASS="filename"
|
|
>/dev/hdb1</TT
|
|
>
|
|
-s <TT
|
|
CLASS="filename"
|
|
>/dev/home</TT
|
|
>
|
|
</P
|
|
><P
|
|
> will create a link from <TT
|
|
CLASS="filename"
|
|
>/dev/hdb1</TT
|
|
> to <TT
|
|
CLASS="filename"
|
|
>/dev/home</TT
|
|
>. Crucially, it stores a
|
|
unique identifier for the hardware that was on <TT
|
|
CLASS="filename"
|
|
>/dev/hdb1</TT
|
|
> and stores that identifier along with
|
|
the link name that you specified in /etc/sysconfig/devlabel. If the
|
|
hardware is later moved to <TT
|
|
CLASS="filename"
|
|
>/dev/hdc1</TT
|
|
>,
|
|
its unique identifier will be queried (using
|
|
/usr/bin/partition_uuid), matched to its entry in
|
|
/etc/sysconfig/devlabel, and again linked to <TT
|
|
CLASS="filename"
|
|
>/dev/home</TT
|
|
>.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect1"
|
|
><HR><H1
|
|
CLASS="sect1"
|
|
><A
|
|
NAME="formatting"
|
|
></A
|
|
>7. Formatting an ext2/3 partition</H1
|
|
><P
|
|
> When a hard drive is partitioned, it is mapped into sections, but
|
|
the sections are empty. It is like a newly constructed library;
|
|
shelves, signs, and a card catalogue system must be put in place
|
|
before the books are put away.</P
|
|
><P
|
|
> The organizational structure inside a partition is called a file
|
|
system. With Linux, the standard file system is ext2 and ext3. The
|
|
ext3 file system is ext2, plus a log of disk writes called a
|
|
journal. The journal allows the system to recover quickly from
|
|
accidental power outages, among other things.
|
|
</P
|
|
><P
|
|
> The principal tool for making an ext2/3 file system in a partition
|
|
is <B
|
|
CLASS="command"
|
|
>mke2fs</B
|
|
>. It is usually found in <TT
|
|
CLASS="filename"
|
|
>/sbin</TT
|
|
>. <B
|
|
CLASS="command"
|
|
>mkfs.ext2</B
|
|
> and
|
|
<B
|
|
CLASS="command"
|
|
>mkfs.ext3</B
|
|
> are frontends which pass specific
|
|
options to <B
|
|
CLASS="command"
|
|
>mke2fs</B
|
|
>.
|
|
</P
|
|
><DIV
|
|
CLASS="sect3"
|
|
><HR><H3
|
|
CLASS="sect3"
|
|
><A
|
|
NAME="formatting-invocation"
|
|
></A
|
|
>.1. Simple Invocation</H3
|
|
><P
|
|
> <B
|
|
CLASS="command"
|
|
>mke2fs</B
|
|
> <TT
|
|
CLASS="filename"
|
|
>/dev/hdb1</TT
|
|
>
|
|
</P
|
|
><P
|
|
> <B
|
|
CLASS="command"
|
|
>mkfs.ext2</B
|
|
> <TT
|
|
CLASS="filename"
|
|
>/dev/hdb1</TT
|
|
>
|
|
</P
|
|
><P
|
|
> both of which make an ext2 file system on the first partition of the second drive, and
|
|
</P
|
|
><P
|
|
> <B
|
|
CLASS="command"
|
|
>mke2fs</B
|
|
> -j <TT
|
|
CLASS="filename"
|
|
>/dev/hdb1</TT
|
|
>
|
|
</P
|
|
><P
|
|
> <B
|
|
CLASS="command"
|
|
>mkfs.ext3</B
|
|
> <TT
|
|
CLASS="filename"
|
|
>/dev/hdb1</TT
|
|
>
|
|
</P
|
|
><P
|
|
> make an ext3 file system.
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect3"
|
|
><HR><H3
|
|
CLASS="sect3"
|
|
><A
|
|
NAME="reservedblocks"
|
|
></A
|
|
>.2. Reserved blocks</H3
|
|
><P
|
|
> The -m option is probably the one of most use to non-experts. If the
|
|
file system becomes filled and there is no more space to write, it
|
|
is basically unusable because the operating system is constantly
|
|
writing to disk. By default, five percent of the partition is
|
|
reserved for use by the root user. This allows root to conduct
|
|
administrative activities on the partition and perhaps move some
|
|
data off. However, this is most critical when the partition contains
|
|
/ or home directories. For pure data partitions, this is just lost
|
|
space. Five percent of a 250Gb partition is 12.5 Gb. Especially in
|
|
the case of large partitions, it is safe to set the reserved space
|
|
to the minimum, which is one percent.
|
|
</P
|
|
><P
|
|
> <B
|
|
CLASS="command"
|
|
>mkfs.ext3</B
|
|
> -m 1<TT
|
|
CLASS="filename"
|
|
>/dev/hdb1</TT
|
|
>
|
|
</P
|
|
><P
|
|
> creates a file system with only 1% of its space reserved for the
|
|
root user. tune2fs -m can be used to adjust the reserved blocks
|
|
after data is loaded on the partition.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect1"
|
|
><HR><H1
|
|
CLASS="sect1"
|
|
><A
|
|
NAME="recovering"
|
|
></A
|
|
>8. Recovering a Deleted Partition Table</H1
|
|
><P
|
|
> Below are instructions for manually recovering a deleted partition
|
|
table. There are utilities such as <A
|
|
HREF="http://www.stud.uni-hannover.de/user/76201/gpart"
|
|
TARGET="_top"
|
|
>gpart</A
|
|
>
|
|
or <A
|
|
HREF="http://www.cgsecurity.org/index.html?testdisk.html"
|
|
TARGET="_top"
|
|
>TestDisk
|
|
</A
|
|
> which can make this task considerably easier. If you are
|
|
reading this, however, because you have run out of luck, this is
|
|
what you will have to do:
|
|
</P
|
|
><P
|
|
>
|
|
<P
|
|
></P
|
|
><OL
|
|
TYPE="1"
|
|
><LI
|
|
><P
|
|
>Make a partition that is at least as big as your first partition
|
|
was. You can make it larger than the original partition by any
|
|
amount. If you underestimate, there will be much wailing and
|
|
gnashing of teeth.
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> Command (m for help): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>n</B
|
|
></TT
|
|
>
|
|
Command action
|
|
e extended
|
|
p primary partition (1-4)
|
|
<TT
|
|
CLASS="userinput"
|
|
><B
|
|
>p</B
|
|
></TT
|
|
>
|
|
Partition number (1-4): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>1</B
|
|
></TT
|
|
>
|
|
First cylinder (1-23361, default 1): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
><RETURN></B
|
|
></TT
|
|
>
|
|
Using default value 1
|
|
Last cylinder or +size or +sizeM or +sizeK (1-22800, default 22800): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>13032</B
|
|
></TT
|
|
>
|
|
|
|
Command (m for help): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>w</B
|
|
></TT
|
|
>
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
> Run <B
|
|
CLASS="command"
|
|
>dumpe2fs</B
|
|
> on the first partition and grep out the block count.
|
|
</P
|
|
><P
|
|
> Example:
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> % dumpe2fs /dev/sda1 | grep "Block count:"
|
|
Block count: 41270953
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
If you are uncertain about this value, repeat Step 1 with a
|
|
bigger partition size. If the block count changes, then you
|
|
underestimated the size of the original partition. Repeat Step
|
|
1 until you get a stable block count.
|
|
</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
> Remove the partition you just created
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> Command (m for help): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>d</B
|
|
></TT
|
|
>
|
|
Partition number (1-4): <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>1</B
|
|
></TT
|
|
>
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
</P
|
|
></LI
|
|
><LI
|
|
><A
|
|
NAME="BlockSize"
|
|
></A
|
|
><P
|
|
>Make a new partition with the exact size you got from the block
|
|
count. Since you cannot enter block size in fdisk, you need to
|
|
figure out how many cylinders to request. Here is the formula:
|
|
</P
|
|
><P
|
|
> <TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> (number of needed cylinders) = (number of blocks) / (block size)
|
|
|
|
(block size) = (unit size) / 1024
|
|
|
|
(unit size) = (number of heads) * (number of sectors/cylinder) * (number of bytes/sector)
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
</P
|
|
><P
|
|
> Consider the following example, where a hard drive has been partitioned into four primary
|
|
partitions of 1, 2, 4, and 8 cylinders.
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> disk /dev/sda: 16 heads, 63 sectors, 23361 cylinders
|
|
Units = cylinders of 1008 * 512 bytes
|
|
|
|
Device Boot Start End Blocks Id System
|
|
/dev/sda1 1 2 976+ 83 Linux
|
|
/dev/sda2 3 5 1512 83 Linux
|
|
/dev/sda3 6 10 2520 83 Linux
|
|
/dev/sda4 11 19 4536 83 Linux
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
<B
|
|
CLASS="command"
|
|
>fdisk</B
|
|
> provides the configuration information I need in the head of the output.
|
|
|
|
The unit size is <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>516096</B
|
|
></TT
|
|
> ( <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>16</B
|
|
></TT
|
|
> heads * <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>63</B
|
|
></TT
|
|
> sectors/cyl * <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>512</B
|
|
></TT
|
|
> bytes/sector ).
|
|
|
|
The block size is <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>504</B
|
|
></TT
|
|
> ( <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>516096 / 1024</B
|
|
></TT
|
|
> ).
|
|
|
|
The number of needed cylinders for the second partition is therefore <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>3</B
|
|
></TT
|
|
> ( <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>1512</B
|
|
></TT
|
|
> blocks <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>/
|
|
504</B
|
|
></TT
|
|
> ).
|
|
|
|
The partition table shows that this is indeed the case: the first cylinder is <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>3</B
|
|
></TT
|
|
>, the second <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>4</B
|
|
></TT
|
|
>, and
|
|
the last is <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>5</B
|
|
></TT
|
|
>, for a total of three cylinders.
|
|
|
|
The number of needed cylinders for the third partition is calculated similarly: <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>2520</B
|
|
></TT
|
|
> blocks
|
|
<TT
|
|
CLASS="userinput"
|
|
><B
|
|
>/ 504 = 5</B
|
|
></TT
|
|
>, which corresponds to blocks <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>6,7,8,9,10</B
|
|
></TT
|
|
>
|
|
.
|
|
|
|
Notice that this calculation does not work for the first partition because the block count is
|
|
wrong ( <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>976</B
|
|
></TT
|
|
> instead of <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>1008</B
|
|
></TT
|
|
> ). The plus sign indicates that not all the blocks are included in
|
|
the fdisk value. When you try the calculation ( <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>976 / 504</B
|
|
></TT
|
|
> ) you get <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>1.937</B
|
|
></TT
|
|
>. Knowing that
|
|
the number of cylinders must be an integer, you can simply round up.
|
|
</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>Run <B
|
|
CLASS="command"
|
|
>e2fsck</B
|
|
> on it to verify that you can read the new partition.
|
|
</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
> Repeat Steps 1-5 on remaining partitions.
|
|
</P
|
|
></LI
|
|
></OL
|
|
>
|
|
|
|
Remount your partitions. Amazingly, all of your data will be there.
|
|
</P
|
|
><P
|
|
> Credit goes to: Mike Vevea, jedi sys admin, for providing the basic strategy.
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect1"
|
|
><HR><H1
|
|
CLASS="sect1"
|
|
><A
|
|
NAME="setting_up_swap"
|
|
></A
|
|
>9. Setting Up Swap Space</H1
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="swap_partitions"
|
|
></A
|
|
>9.1. Swap Files</H2
|
|
><P
|
|
> Normally, there are only two steps to setting up swap space,
|
|
creating the partition and adding it to /etc/fstab. A typical fstab
|
|
entry for a swap partition at /dev/hda6 would look like this:
|
|
</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> /dev/hda6 swap swap defaults 0 0
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
> The next time you reboot, the initialization scripts will activate
|
|
it automatically and there's nothing more to be done.
|
|
</P
|
|
><P
|
|
> However, if you want to make use of it right away, you'll need to
|
|
activate it maually. As root, type:
|
|
</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> <TT
|
|
CLASS="userinput"
|
|
><B
|
|
><B
|
|
CLASS="command"
|
|
>mkswap</B
|
|
> -f <TT
|
|
CLASS="filename"
|
|
>/dev/hda6</TT
|
|
></B
|
|
></TT
|
|
>
|
|
<TT
|
|
CLASS="userinput"
|
|
><B
|
|
><B
|
|
CLASS="command"
|
|
>swapon</B
|
|
> <TT
|
|
CLASS="filename"
|
|
>/dev/hda6</TT
|
|
></B
|
|
></TT
|
|
>
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="swapfiles"
|
|
></A
|
|
>9.2. Swap Files</H2
|
|
><P
|
|
> There might be times when you've run out of swap space and it is not
|
|
practical to repartition a drive or add a new one. In this case, you
|
|
can use a regular file in an ordinary partition. All you have to do
|
|
is create a file of the size you want
|
|
</P
|
|
><P
|
|
>
|
|
<TT
|
|
CLASS="userinput"
|
|
><B
|
|
><B
|
|
CLASS="command"
|
|
>dd</B
|
|
> if=/dev/zero of=/var/my_swap bs=1024 count=131072</B
|
|
></TT
|
|
>
|
|
</P
|
|
><P
|
|
> and activate it
|
|
</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> <TT
|
|
CLASS="userinput"
|
|
><B
|
|
><B
|
|
CLASS="command"
|
|
>mkswap</B
|
|
> -f /var/my_swap</B
|
|
></TT
|
|
>
|
|
<TT
|
|
CLASS="userinput"
|
|
><B
|
|
><B
|
|
CLASS="command"
|
|
>swapon</B
|
|
> /var/my_swap</B
|
|
></TT
|
|
>
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
> This invocation creates a file called <TT
|
|
CLASS="filename"
|
|
>my_swap</TT
|
|
>
|
|
in <TT
|
|
CLASS="filename"
|
|
>/var</TT
|
|
>. It is 128 Mb long
|
|
(128 x 1024 = 131072). Initially, it is filled with zeros. However,
|
|
<B
|
|
CLASS="command"
|
|
>mkswap</B
|
|
> marks it as swap space and <B
|
|
CLASS="command"
|
|
>swapon</B
|
|
> tells
|
|
the kernel to start using it as swap space. When you are done with
|
|
it,
|
|
</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> <TT
|
|
CLASS="userinput"
|
|
><B
|
|
><B
|
|
CLASS="command"
|
|
>swapoff</B
|
|
> /var/my_swap</B
|
|
></TT
|
|
>
|
|
<TT
|
|
CLASS="userinput"
|
|
><B
|
|
><B
|
|
CLASS="command"
|
|
>rm</B
|
|
> /var/my_swap</B
|
|
></TT
|
|
>
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="multiple_swap_areas"
|
|
></A
|
|
>9.3. Multiple Swap Areas</H2
|
|
><P
|
|
> More than one swap partition can be used on the same system.
|
|
Consider an example fstab where there is a single swap partition:
|
|
</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> /dev/hda5 / ext3 defaults 1 1
|
|
/dev/hda1 /boot ext2 defaults 1 2
|
|
none /dev/pts devpts gid=5,mode=620 0 0
|
|
none /proc proc defaults 0 0
|
|
/dev/hda7 /usr ext3 defaults 1 2
|
|
/dev/hda6 swap swap defaults 0 0
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
> Imagine replacing the entry for the swap partition with these three lines:
|
|
</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> /dev/hda6 none swap sw,pri=3 0 0
|
|
/dev/hdb2 none swap sw,pri=2 0 0
|
|
/dev/hdc2 none swap sw,pri=1 0 0
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
> This configuration would cause the kernel to use /dev/hda6 first. it
|
|
has the highest priority assigned to it (pri=3). The maximum
|
|
priority can be 32767 and the lowest 0. If that space were to max
|
|
out, the kernel would start using /dev/hdb2, and on to /dev/hdc2
|
|
after that. Why such a configuration? Imagine that the newest
|
|
(fastest) drives are given the highest priority. This will minimize
|
|
speed loss as swap space usage grows.
|
|
</P
|
|
><P
|
|
> It is possible to write to all three simulataneously. If each has
|
|
the same priority, the kernel will write to them much like a RAID,
|
|
with commensurate speed increases.
|
|
</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> /dev/hda6 none swap sw,pri=3 0 0
|
|
/dev/hdb2 none swap sw,pri=3 0 0
|
|
/dev/hdc2 none swap sw,pri=3 0 0
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
> Notice that these three partitions are on separate drives, which is
|
|
ideal in terms of speed enhancement.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect1"
|
|
><HR><H1
|
|
CLASS="sect1"
|
|
><A
|
|
NAME="appendix"
|
|
></A
|
|
>10. Appendix</H1
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="formating"
|
|
></A
|
|
>10.1. Formating Partitions</H2
|
|
><P
|
|
> At the shell prompt, I begin making the file systems on my
|
|
partitions. Continuing with the example in (see <A
|
|
HREF="#mixed"
|
|
>Section 5.3</A
|
|
>),
|
|
this is:
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> # mke2fs /dev/sda1
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
</P
|
|
><P
|
|
> I need to do this for each of my partitions, but not for <TT
|
|
CLASS="filename"
|
|
>/dev/sda4</TT
|
|
> (my extended partition).
|
|
|
|
Linux supports types of file systems other than ext2. You can find out
|
|
what kinds your kernel supports by looking in:
|
|
<TT
|
|
CLASS="filename"
|
|
>/usr/src/linux/include/linux/fs.h</TT
|
|
>
|
|
</P
|
|
><P
|
|
> The most common file systems can be made with programs in <TT
|
|
CLASS="filename"
|
|
>/sbin</TT
|
|
> that start with "mk" like
|
|
<B
|
|
CLASS="command"
|
|
>mkfs.msdos</B
|
|
> and <B
|
|
CLASS="command"
|
|
>mke2fs</B
|
|
>.
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="swap"
|
|
></A
|
|
>10.2. Activating Swap Space</H2
|
|
><P
|
|
>
|
|
To set up a swap partition:
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> # mkswap -f /dev/hda5
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
To activate the swap area:
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> # swapon /dev/hda5
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
Normally, the swap area is activated by the initialization scripts at
|
|
boot time.
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="mounting"
|
|
></A
|
|
>10.3. Mounting Partitions</H2
|
|
><P
|
|
>
|
|
Mounting a partition means attaching it to the linux file system. To
|
|
mount a linux partition:
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> # mount -t ext2 /dev/sda1 /opt
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
<P
|
|
></P
|
|
><DIV
|
|
CLASS="variablelist"
|
|
><DL
|
|
><DT
|
|
>-t ext2</DT
|
|
><DD
|
|
><P
|
|
> File system type. Other types you are likely to use are:
|
|
<P
|
|
></P
|
|
><UL
|
|
><LI
|
|
><P
|
|
>ext3 (journaling sile system based on ext2)</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>msdos (DOS)</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>hfs (mac)</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>iso9660 (CDROM)</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>nfs (network file system)</P
|
|
></LI
|
|
></UL
|
|
>
|
|
</P
|
|
></DD
|
|
><DT
|
|
>/dev/sda1</DT
|
|
><DD
|
|
><P
|
|
> Device name. Other device names you are likely to use:
|
|
<P
|
|
></P
|
|
><UL
|
|
><LI
|
|
><P
|
|
><TT
|
|
CLASS="filename"
|
|
>/dev/hdb2</TT
|
|
> (second partition in second IDE drive)</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
><TT
|
|
CLASS="filename"
|
|
>/dev/fd0</TT
|
|
> (floppy drive A)</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
><TT
|
|
CLASS="filename"
|
|
>/dev/cdrom</TT
|
|
> (CDROM)</P
|
|
></LI
|
|
></UL
|
|
>
|
|
</P
|
|
></DD
|
|
><DT
|
|
>/opt</DT
|
|
><DD
|
|
><P
|
|
> mount point. This is where you want to "see" your partition.
|
|
When you type <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>ls /opt</B
|
|
></TT
|
|
>, you can see what
|
|
is in <TT
|
|
CLASS="filename"
|
|
>/dev/sda1</TT
|
|
>. If there
|
|
are already some directories and/or files under <TT
|
|
CLASS="filename"
|
|
>/opt</TT
|
|
>, they will be invisible after
|
|
this mount command.
|
|
</P
|
|
></DD
|
|
></DL
|
|
></DIV
|
|
>
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><HR><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="fragmentation"
|
|
></A
|
|
>10.4. Some facts about file systems and fragmentation</H2
|
|
><P
|
|
> Disk space is administered by the operating system in units of
|
|
blocks and fragments of blocks. In ext2, fragments and blocks
|
|
have to be of the same size, so we can limit our discussion to
|
|
blocks.
|
|
</P
|
|
><P
|
|
> Files come in any size. They don't end on block boundaries. So
|
|
with every file a part of the last block of every file is
|
|
wasted. Assuming that file sizes are random, there is
|
|
approximately a half block of waste for each file on your disk.
|
|
Tanenbaum calls this "internal fragmentation" in his book
|
|
"Operating Systems".
|
|
</P
|
|
><P
|
|
> You can guess the number of files on your disk by the number of
|
|
allocated inodes on a disk. On my disk
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> # df -i
|
|
Filesystem Inodes IUsed IFree %IUsed Mounted on
|
|
/dev/hda3 64256 12234 52022 19% /
|
|
/dev/hda5 96000 43058 52942 45% /var
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
there are about 12000 files on <TT
|
|
CLASS="filename"
|
|
>/</TT
|
|
> and about 44000 files on <TT
|
|
CLASS="filename"
|
|
>/var</TT
|
|
>. At a block size of 1 KB, about
|
|
6+22 = 28 MB of disk space are lost in the tail blocks of files. Had
|
|
I chosen a block size of 4 KB, I had lost 4 times this space.
|
|
</P
|
|
><P
|
|
> Data transfer is faster for large contiguous chunks of data, though.
|
|
That's why ext2 tries to preallocate space in units of 8 contigous
|
|
blocks for growing files. Unused preallocation is released when the
|
|
file is closed, so no space is wasted.
|
|
</P
|
|
><P
|
|
> Noncontiguous placement of blocks in a file is bad for performance,
|
|
since files are often accessed in a sequential manner. It forces the
|
|
operating system to split a disk access and the disk to move the
|
|
head. This is called "external fragmentation" or simply
|
|
"fragmentation" and is a common problem with MS-DOS file systems. In
|
|
conjunction with the abysmal buffer cache used by MS-DOS, the
|
|
effects of file fragmentation on performance are very noticeable.
|
|
DOS users are accustomed to defragging their disks every few weeks
|
|
and some have even developed some ritualistic beliefs regarding
|
|
defragmentation.
|
|
</P
|
|
><P
|
|
> None of these habits should be carried over to Linux and ext2. Linux
|
|
native file systems do not need defragmentation under normal use and
|
|
this includes any condition with at least 5% of free space on a
|
|
disk. There is a defragmentation tool for ext2 called defrag, but
|
|
users are cautioned against casual use. A power outage during such
|
|
an operation can trash your file system. Since you need to back up
|
|
your data anyway, simply writing back from your copy will do the
|
|
job.
|
|
</P
|
|
><P
|
|
> The MS-DOS file system is also known to lose large amounts of disk
|
|
space due to internal fragmentation. For partitions larger than 256
|
|
MB, DOS block sizes grow so large that they are no longer useful
|
|
(This has been corrected to some extent with FAT32). Ext2 does not
|
|
force you to choose large blocks for large file systems, except for
|
|
very large file systems in the 0.5 TB range (that's terabytes with 1
|
|
TB equaling 1024 GB) and above, where small block sizes become
|
|
inefficient. So unlike DOS there is no need to split up large disks
|
|
into multiple partitions to keep block size down.
|
|
</P
|
|
><P
|
|
> Use a 1Kb block size if you have many small files. For large
|
|
partitions, 4Kb blocks are fine.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |