==============================================================================
			      GNU Parted
==============================================================================

      Copyright (C) 1999-2000 Andrew Clausen

      Permission is granted to copy, distribute and/or modify this document
      under the terms of the GNU Free Documentation License, Version 1.1
      or any later version published by the Free Software Foundation;
      with the no Invariant Sections, with the no Front-Cover Texts, and
      with no Back-Cover Texts.  A copy of the license is included in the
      file, COPYING.DOC.


CONTENTS
--------

1	Introduction
1.1	Software Required
1.2	Platforms Supported
1.3	License
1.4	Compiling

2	Before you start
2.1	Unmounting file systems
2.2	The boot-load process
2.3	BIOS geometry

3	Notes on file systems
3.1	Ext2
3.2	FAT16 and FAT32

4	Using Parted
4.1	Commands

5	Disk Imaging

6	Further Information and Related Software


------------------------------------------------------------------------------
1	INTRODUCTION
------------------------------------------------------------------------------

GNU parted is a program for creating, destroying, resizing, checking and
copying partitions, and the filesystems on them.

This is useful for creating space for new operating systems, reorganising
disk usage, copying data between hard disks, and "disk imaging" - replicating
installations over many computers.

GNU parted was designed to minimize the chance of data loss.  For example, it
was designed to avoid data loss during interruptions (like power failure) and
performs many safety checks.  However there could be bugs in Parted, so you
should back up your important files.

The GNU parted homepage is www.gnu.org/software/parted.  It can be downloaded
from ftp.gnu.org/gnu/parted.

The parted mailing list is parted@gnu.org.  To subscribe, write to
bug-parted-request@gnu.org with "subscribe" in the subject.

Please send bug reports to bug-parted@gnu.org.  When sending bug reports,
please include the version of GNU Parted.  If the bug is related to
partition tables, then please include the output from these commands:

	# fdisk /dev/hda -l
	# fdisk /dev/hda
	Command (m for help): p
	Command (m for help): x
	Extended command (m for help): p

Feel free to ask for help on this list - just check that your question isn't
answered here first.  If you don't understand the documentation, please tell
us, so we can explain it better.  General philosophy is: if you need to ask for
help, then something needs to be fixed so you (and others) don't need to ask
for help.


1.1	Software Required
------------------------------------------------------------------------------
  * libuuid, part of the e2fsprogs package.  If you don't have this, you can
get it from   http://web.mit.edu/tytso/www/linux/e2fsprogs.html
  * GNU Readline, available from   ftp://ftp.gnu.org/gnu/readline


1.2	Platforms Supported
------------------------------------------------------------------------------
Hopefully, this list will grow a lot...
  * Linux >= 2.2.x / i386
  * Linux >= 2.2.x / Alpha	(only ext2 has been tested, but the others
				 should work, in theory)
Note: GNU libc 2.1 or higher is required.  You can probably use older versions
by using the --disable-nls option.


1.3	License
------------------------------------------------------------------------------
GNU Parted is free software, covered by the GNU General Public License Version
2.  This should have been included with the Parted distribution, in the COPYING
file.  If not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA.


1.4	Compiling
------------------------------------------------------------------------------
If you want to compile GNU Parted, this is generally done with:

	$ ./configure
	$ make

However, there are a few options for ./configure:

  --without-readline		turns off use of readline.  This is useful for
  				making rescue disks, etc., where few libraries
				are available.

  --disable-nls			turns off native language support.  This is
  				useful for use with old versions of glibc,
				or a trimmed down version of glibc suitable
				for rescue disks.


------------------------------------------------------------------------------
2	BEFORE YOU START
------------------------------------------------------------------------------

Read all of this before you use Parted.


2.1	Unmounting file systems
-------------------------------------------------------------------------------
When you want to resize a file-system, make sure it is not mounted.

If you want to resize your root device, create a boot disk, and copy Parted
onto the boot disk.  The only file you should need is the "parted" binary
(usually /usr/sbin/parted or /usr/local/sbin/parted).  Another option is to
use Andreas Dilger's online ext2 resizer, included in the ext2resize package
(see Section 6 for details)


2.2	The boot-load process
-------------------------------------------------------------------------------
If you resized partition(s), you should re-run your bootstrap installers.  In
some cases, you will need to run the boot strap loader on more than one
operating system.

During the resize process, lots of data gets moved around the partition.  Many
bootstrap loaders don't understand the filesystem.  They just remember where on
the disk the required bootstrap files lie.  They need to be told where the
files have been moved to.

2.2.1	Linux (LILO)
--------------------
LILO's boot-strap loader is installed with:

	# /sbin/lilo

If you used a boot disk, you may want to do this instead: (where /dev/hda1
should be replace with your root device)

	# mount /dev/hda1 /mnt
	# chroot /mnt /mnt/sbin/lilo
	# umount /mnt

LILO requires that all boot partitions start before cylinder 1024.

2.2.2	GNU GRUB (GRand Unified Bootloader)
-------------------------------------------
Depending on how GRUB is installed, it may understand the file system, or
simply remember where the boot files are stored.  It understands the
file system if it's using "Stage1.5".  If it's not using Stage1.5, then
you need to reinstall Stage2 (please see the GRUB documentation).
Otherwise, you don't need to do anything.

2.2.3	MS DOS, MS Windows 9x
-----------------------------
You shouldn't need to do anything special for DOS or Windows 9x.  However,
there are a few restrictions:
  * the MS DOS and MS Windows 9x can only boot of the first FAT partition.
That is, the FAT partition with the smallest MINOR number, that isn't hidden.
  * if you are using CHS addressing (you probably are), then the boot
partition start must be less than cylinder 1024.
  * the "real" MS-DOS (i.e. up to version 6.22) and MS-DOS 7.0 (i.e.  Windows
95/95a) don't know about FAT32.  It's therefore possible to boot them from the
SECOND FAT (FAT16 only, of course) partition, when the FIRST FAT partition is
FAT32.  Both have to be primary partitions, so you'll have to set the one you
want to boot from as active partition.

2.2.4	MS Windows NT, MS Windows 2000
--------------------------------------
The NT boot loader needs
  * it's own boot sector code in a PRIMARY FAT16 or NTFS partition (FAT32
possible with Windows 2000), which is called the "system partition".  This
partition should be marked with the "boot" flag in Parted.
  * the files NTLDR, BOOT.INI and NTDETECT.COM within the system partition.
BOOT.INI holds the information about the physical location of the primary
partition or logical drive where Windows NT was installed to, called the "boot
partition".  The boot partition and system partition may be located together in
one primary partition.
  * optionally, the file NTBOOTDD.SYS within the system partition, which is the
renamed disk driver for your SCSI or IDE controller, when this has no own BIOS
(or it's BIOS can't access large disks).
  * the system partition should end before cylinder 1024, and MUST start
before cylinder 1024.
  * both the boot and system partition may be resized, without the need for
any other changes.
  * if the boot partition's number changes (i.e. it's MINOR number), then the
BOOT.INI has to be updated.


2.3	BIOS Geometry
------------------------------------------------------------------------------
BIOS (Basic Input/Output System) is a piece of software that is built into
your computer (on a special ROM chip).  It is the first thing that runs
when you switch your computer on.  BIOS does the following:
  * prepares your computer to load your operating system - doing things
like checking memory, etc.
  * provides a mechanism for hard disk access to programs - particularly
boot loaders like LILO.
  * has a program for configuring various parts of your computer.  This is
usually accessed by pressing the DEL key after you turn on your computer.

The BIOS geometry of a hard disk is a triplet of 3 numbers: cylinders,
heads and sectors.  These numbers don't really mean much to anyone, except
the BIOS, the boot-loader and the operating system must agree on what these
numbers are.  This causes several problems:
  * once you create a filesystem or disk label (i.e. partition table) on your
hard disk, you should not change BIOS geometry numbers in the BIOS setup
program, unless you really know what you're doing.
  * Linux usually detects the BIOS geometry automatically.  However, sometimes
it gets it wrong.  In this case, you should tell it yourself, by passing
a parameter to Linux.  For example, if Linux thinks your hard drive /dev/hda
has geometry 256/64/63, but the BIOS setup program says the geometry is
512/32/63, then you would pass this parameter to Linux:

	hda=512,32,63

Parameters are passed in different ways, depending what boot-loader you're
using.  You are probably using LILO.  In this case, you add this line to
/etc/lilo.conf:  (You then need to run /sbin/lilo, for the change to take
effect)

	append="hda=512,32,63"

 * GNU parted can usually detect if Linux has detected the incorrect geometry.
However, it cannot do this if there are no partitions on the disk.  In this
case, you should check yourself.  It is very important that you do this.


------------------------------------------------------------------------------
3	NOTES ON FILE SYSTEMS
------------------------------------------------------------------------------

GNU Parted has support for these operations:

Filesystem	detect	create	resize	copy	check
ext2		*	*	*1		*2
fat		*	*	*3	*3	*
linux-swap	*	*	*	*	*

NOTES:
(1) The start of the partition must stay fixed for ext2.

(2) Limited checking is done when the filesystem is opened.  This is the
only checking at the moment.  All commands (including resize) will gracefully
fail, leaving the filesystem in tact, if there are any errors in the file
system (and the vast majority of errors in general).

(3) The size of the new partition, after resizing or copying, is restricted
by the cluster size for fat (mainly affects fat16).  This is worse than you
think, because you don't get to choose your cluster size (it's a bug in
Windows, but you want compatibility, right?).


3.1	Ext2
------------------------------------------------------------------------------
GNU Parted doesn't directly support for copying ext2 file systems (yet).
There are a few ways of achieving this, however:
  * use GNU Parted's mkfs command (or mkfs.ext2), and then run at the shell:

	# mount -t ext2 /dev/hda2 /mnt/dst
	# find /mnt/src -depth | cpio -pm /mnt/dst

  * if the duplicate partition is going to bigger than the original, this can
also be done:  first, create the new ext2 partition.  Then:

	# dd if=/dev/src-device of=/dev/dst-device bs=1024 count=(OLD SIZE)
	# parted /dev/hda resize 2 (START) (END)

Where: (OLD SIZE) is the size of the original partition in kilobytes.
(START) and (END) are the new start and end for the duplicate partition.


3.2	FAT16 and FAT32
------------------------------------------------------------------------------
GNU Parted can not change the cluster size of FAT file systems (yet).  This
places restrictions on resizing and copying partitions.  This is often quite
bizarre, because GNU Parted can convert file systems between FAT16 and FAT32,
which have different restrictions on what the cluster size can be.

For example, lets say have a 100Mb partition with a cluster size 4k.  This
partition can't be resized to 400Mb, because the cluster size would need to
be changed to 16k.  However, it can be resized to 600Mb if you use FAT32.  The
reverse is true for 600Mb FAT32 file systems.

3.2.1	MS DriveSpace partitions
--------------------------------
MS DriveSpace is a program that comes with MS Windows 95, that can be used
to compress FAT filesystems.  I believe this works the same way as DoubleSpace,
so everything said here applies should apply to DoubleSpace as well.

It is possible to use GNU Parted to resize and copy these partitions, but you
have to do a few extra things...

3.2.1.1	Growing a DriveSpace partition
--------------------------------------
(1) Use GNU parted's resize command to grow the partition to the desired
size.

(2) Use MS DriveSpace to shift the free space from the host drive to the
compressed drive.

3.2.1.2	Shrinking a DriveSpace partition
----------------------------------------
(1) Use MS DriveSpace to shift the free space from the compressed drive to
the host drive.  The amount of free space shifted corresponds to the desired
amount by which to shrink the partition.

(2) Use GNU parted's resize command to shrink the partition to the desired
size.  NOTE: GNU Parted doesn't give good feedback on what the numbers, to
know how much to shrink the partition by.  This is on the TODO list.

3.2.1.3	Copying a DriveSpace partition
--------------------------------------
If you want to copy a DriveSpace partition to a partition that is bigger,
then you can follow the instructions for growing a DriveSpace partition,
except you copy rather than resize the desired partition, and make sure
you use the new partition in DriveSpace.

However, if you want to copy a DriveSpace partition to a partition that is
smaller, things get a bit more complicated:

(1) Use MS DriveSpace to shift free space from the compressed drive to the
source host drive.  The amount of space shifted should be more than difference
between the source partition, and the desired size of the duplicate partition.

(2) Use GNU Parted to copy the source partition to the duplicate partition.

(3) Use MS DriveSpace to shift the free space from the source host drive back to
the compressed drive.

(4) Use MS DriveSpace to shift the free space from the duplicate host drive
back to the compressed drive.


------------------------------------------------------------------------------
4	USING PARTED
------------------------------------------------------------------------------

Parted has two modes: command line and interactive.  Parted should always be
started with:

	# parted DEVICE

where DEVICE is the hard disk device to edit.  (If you're lazy, parted will
attempt to guess which device you want).

In command line mode, this is followed by one or more commands.  For example:

	# parted /dev/sda resize 1 52 104 mkfs 2 fat

In interactive mode, commands are entered one at a time at a prompt.  For
example:

	(parted) resize 1 52 104
	(parted) mkfs 2 fat

Unambiguous abbreviations are allowed.


4.1	COMMANDS
------------------------------------------------------------------------------
boot MINOR                    set the boot partition to be MINOR
check MINOR                   do a simple check on the filesystem
cp MINOR [DEVICE] MINOR       copy filesystem to another partition
help [COMMAND]                prints general help, or help on COMMAND
hide MINOR                    hides partition MINOR
mklabel LABEL-TYPE            create a new disklabel (partition table)
mkfs MINOR FS-TYPE            make a filesystem FS-TYPE on partition MINOR
mkpart PART-TYPE [FS-TYPE] START END      make a partition without a (new)
			      filesystem.  FS-TYPE required for data partitions
mkpartfs PART-TYPE FS-TYPE START END      make a partition with a filesystem
print                         display the partition table
resize MINOR START END        resize filesystem on partition MINOR
rm MINOR                      delete partition MINOR
quit                          exit program
unhide MINOR                  hides partition MINOR

PART-TYPE is one of: primary, logical, extended
A primary partition is a normal, vanilla partition.  An extended partition is
a partition that merely contains other partitions - logical partitions to
be precise.  There must be at most one extended partition, which takes up
the space of one primary partition.

FS-TYPE is one of: fat, ext2, linux-swap

START and END are measured in cylinders.  The print command will help you
figure out these values.


------------------------------------------------------------------------------
5	DISK IMAGING
------------------------------------------------------------------------------

Disk imaging is a method for avoiding the tedious Windows install process.
For example, if you want to install Windows and Office on 1000 machines,
it'll probably take you about 5 times 1000 hours.  Things aren't so bad
with GNU/Linux, because there are programs like Red Hat's kickstart, which
allow you to automate the install of other programs, or practically anything
you need to do.  Therefore, disk imaging is really only used for Windows
machines.   Obviously, we urge you to not use Windows (or any non-free
software) at all, but we realise that most organisations would find it
impossible switch from Windows to GNU/Linux (or other free software)
without a transition period, where both systems are available.

With disk imaging, you can burn a CD with a disk image of a partition
containing Windows and Office, and copy the partition directly onto the hard
disks of all the computers, by sticking in a boot disk and the CD, and
letting it fly.  But the partition on the Windows disk is probably going to be
bigger, so the partition will also have to be resized.  I've had several
people say that they've managed to automate this process with Linux boot
floppies and parted.  It is possible to use the CD ROM only, by using the
floppy as the boot image on the CD.  Read the CD writing HOWTO for more
information.  There are a few weird things you have to do to get this whole
thing to work (which will be fixed in the next stable series).  Anyway, this
is the general process: 

(1) Install Windows on a machine, with the setup you want. You can have the
partition as big as you want, so long as you don't use more than 640 Mb, and
you leave enough room for a complete Linux install, and another 1300 Mb
for two copies of the CD image.

(2) Install Linux on the machine.

(3) Make a directory for the CD image (eg: /root/cdimage/)

(4) Create a 640Mb disk image file (eg: /root/cdimage/diskimage) in the CD
image directory: 

        # dd if=/dev/zero of=/root/cdimage/diskimage bs=$[1024 * 1024]
        count=640 

(5) Use Parted to copy the Windows partition to the disk image: 

        # parted /root/cdimage/diskimage mklabel msdos mkpart primary fat 1
        $[1024 * 1024]
        # parted /dev/hda cp 1 /root/cdimage/diskimage 1 

(6) Create the CD image from the CD image directory, and burn it to CD with
your favourite CD writing tools. 

(7) Compile a special version of Parted without native language support and
readline support (or download the special RPM from Freshmeat): 

        localhost:~/parted-1.0.10# ./configure --disable-nls
        --without-readline --disable-shared; make 

(8) Create a Linux boot disk (see the Bootdisk HOWTO).

(9) Put the cut-down version of parted on the boot disk (or a supplementary
root disk).

(10) Write a shell script to do the following: 

        mount /dev/cdrom /mnt/cdrom
        parted /dev/hda mklabel msdos mkparts primary fat 1 SOME-SIZE << EOF
	Yes
	EOF
        parted /mnt/cdrom/diskimage cp 1 /dev/hda 1
        /sbin/halt 

(11) Start installing! Stick the floppy + CD into each computer, and let it
roll... 

Obviously, I can and will make this process a lot easier. We're considering
making a mini-distribution to do this.  I wouldn't have time to maintain such
a thing - any volunteers? 


------------------------------------------------------------------------------
6	FURTHER INFORMATION AND RELATED SOFTWARE
------------------------------------------------------------------------------

If you want to find out more information, feel free to send questions
to parted@gnu.org.  (!) indicates the information/software is probably included
in your distribution.

These files in the GNU parted distribution contain further information:
  * ABOUT-NLS - information about using Native Language Support, and the
Free Translation Project
  * API - the documentation for the libparted API
  * AUTHORS - who wrote what
  * BUGS - unfixed bugs
  * ChangeLog - record of changes made to GNU parted
  * COPYING - the GNU General Public License, the terms under which GNU
parted may be distributed
  * FAT - information on how the FAT resizer works (for programmers)
  * INSTALL - how to compile and install GNU Parted, and most other free
software
  * TODO - planned features that are not yet implemented

These documents are not distributed with GNU Parted, but you may find them
useful.  Most of these will probably be in your distribution.  Eg: on Red Hat
Linux, look on the CD in /doc/HOWTO and /doc/FAQ.
  * Filesystems HOWTO   http://penguin.cz/~mhi/fs/
  * Hard Disk Upgrade mini-HOWTO (!):   http://sunsite.unc.edu/LDP/HOWTO
  * Large Disk HOWTO   http://www.win.tue.nl/~aeb/linux/Large-Disk.html
  * LILO mini-HOWTO (!)   http://sunsite.unc.edu/LDP/HOWTO
  * MILO HOWTO (!)   http://sunsite.unc.edu/LDP/HOWTO
  * Linux+OS mini-HOWTOs (!): Linux+DOS+Win95+OS2, Linux+FreeBSD-mini-HOWTO,
Linux+Win95, Linux+FreeBSD, Linux+NT-Loader.  You can get these from:
      http://sunsite.unc.edu/LDP/HOWTO
  * Partition mini-HOWTO (!):   http://sunsite.unc.edu/LDP/HOWTO
  * Partition Table HOWTO
      http://www.win.tue.nl/~aeb/partitions/partition_tables.html
  * Partition Types list
      http://www.win.tue.nl/~aeb/partitions/partition_types.html

Other related programs are listed here.  Some of these also have useful
documentation:
  * Disk Drake.  www.linux-mandrake.com/diskdrake.  This is similar in
functionality to GNU Parted.  The FAT code in Disk Drake is based on our
GNU Parted code.  Here's how Disk Drake compares to GNU Parted: (which we both
agree to :-)  Disk Drake is:

	- easier to use, protects you from making mistakes
	- more complete solution (handles /etc/fstab, lilo, etc.)
	- less support for FAT (can't convert FAT16<->FAT32, can't copy
	partitions)
	- less support for ext2 (at the moment)
	- less attention to compatibility between (older) DOS/Windows systems

  * dosfsck
  * e2fsck and e2fsprogs (!)   http://web.mit.edu/tytso/www/linux/e2fsprogs.html
  * ext2resize - uses the same code as GNU Parted, but includes some other
goodies as well, such as an online ext2 resizer, that doesn't require
unmounting.   http://ext2resize.sourceforge.net
  * fdisk (!)
  * FIPS (!) (First Interactive Partition Splitter)
      http://www.igd.fhg.de/~aschaefe/fips/
  * GPart - recovers broken partition tables.
      http://www.stud.uni-hannover.de/user/76201/gpart
  * GNU GRUB - GRand Unified Boot-loader
      http://www.gnu.org/software/grub/grub.html
  * LILO (!) (LInux LOader)   ftp://tsx-11.mit.edu/pub/linux/packages/lilo/
  * mkdosfs (!)  (sometimes called mkfs.msdos)
  * mke2fs (!)  (sometimes called mkfs.ext2)
  * mkfs (!)
  * mkswap (!)


