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

      by Andrew Clausen <clausen@gnu.org>

      Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.

      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
2	Using Parted
3	BIOSes and firmware
4	Boot loaders
5	Operating systems
6	File systems
7	LVM, software RAID and raw file system access
8	Disk Imaging
9	Further Information and Related Software


1	Introduction
1.1	Software Required
1.2	Platforms Supported
1.3	License
1.4	Compiling
1.5	GNU Parted boot disks

2	Using Parted
2.1	Running Parted
2.2	Options
2.3	Command summary
2.4	Detailed command descriptions
2.5	Examples

3	BIOSes and firmware
3.1	PC BIOSes
3.2	Macintosh OpenFirmware
3.3	PC98 BIOS

4	Boot loaders
4.1	LILO (Linux Loader)
4.2	GNU GRUB (GRand Unified Bootloader)
4.3	MS DOS, MS Windows 9x, MS Windows ME
4.4	MS Windows NT
4.5	MS Windows 2000
4.6	Quik
4.7	Yaboot

5	Operating systems
5.1	GNU/Linux and FreeBSD
5.2	MS Windows and OS/2
5.3	MacOS

6	File systems
6.1	Ext2
6.2	FAT16 and FAT32
6.3	Reiserfs

7	LVM, software RAID and raw file system access
7.1	Creating a software RAID or LVM partition
7.2	Manipulating a file system on a software RAID or LVM logical volume

8	Disk Imaging

9	Further Information and Related Software


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

GNU Parted is a program for creating, destroying, resizing, checking and
copying partitions, and the file systems 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.

This documentation assumes knowledge of partitions and file systems.  If you
want to learn more about these, the Partition mini-HOWTO is recommended reading.
It is probably included with your distribution, or it is available at

	http://www.linuxdoc.org/HOWTO/mini/Partition.html

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.  Subscription
information and archives are available at:

	http://mail.gnu.org/mailman/listinfo/bug-parted

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.

Also, we'd love to hear your ideas :-)


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

If you want to compile Parted, and e2fsprogs, note that you will need to
"make install" and "make install-libs" e2fsprogs.

  * GNU Readline (optional), available from

	ftp://ftp.gnu.org/gnu/readline

If you are compiling Parted, and you don't have readline, you can disable
Parted's readline support with the --disable-readline option for ./configure.

  * GNU gettext (or compatible software) for compilation, if
internationalisation support is desired.

	ftp://ftp.gnu.org/gnu/gettext


1.2	Platforms supported
------------------------------------------------------------------------------
Hopefully, this list will grow a lot.  If you do not have one of these
platforms (Linux at the moment!), then you can use a boot disk (see
section 1.5)

  * Linux >= 2.0.x, 2.2.x (Alpha, x86 PCs, PC98, Macintosh PowerPC, Sun)

Note: GNU libc 2.1 or higher is required.  You can probably use older versions
by using the --disable-nls option.  (Note: I think we have now dropped this
requirement.  TODO: check if libc 2.0 works!)


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.

NOTE: libparted is considered part of GNU Parted.  It is covered by the GNU
General Public License.  It is NOT released under the GNU Lesser General
Public License (LGPL).


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.

  --disable-shared		turns off shared libraries.  This may be
  				necessary for use with old versions of GNU
				libc, if you get a compile error about a
				"spilled register".  Also useful for boot/rescue
				disks.

  --enable-all-static		builds the Parted binariey as a fully static
				binary.  This is convienient for boot disks,
				because you don't need to install any libraries
				on the boot disk (although, other programs may
				require them...)  Note: you will also want to
				run strip(1)


1.5	GNU Parted boot disks
------------------------------------------------------------------------------
If you want run Parted on a machine without GNU/Linux installed, or you
want to resize a root or boot partition, you will need to use a boot disk.


A boot disk image is available from:

	ftp://ftp.gnu.org/gnu/parted/bootdisk/partboot.img

To actually create the boot disk, type (in GNU/Linux):

	# dd if=partboot.img of=/dev/fd0 bs=1440k

Or use RAWRITE.EXE under DOS.

Unfortunately, the boot disk doesn't support a very wide range of hardware.
If your hard disk isn't supported, then:
(1) Boot off the Parted boot disk.
(2) Insert another (ext2) floppy disk.  If it isn't formated, you can
create a file system with: "parted /dev/fd0 mklabel loop mkfs 1 ext2")
(3) Mount the floppy disk. ("mount -t ext2 /dev/fd0 /mnt/floppy")
(4) Copy /sbin/parted to the floppy.  ("cp /sbin/parted /mnt/floppy")
(5) Copy /lib/* to the floppy.  ("cp /lib/* /mnt/floppy)
(6) Unmount the floppy.  ("umount /mnt/floppy")
(7) Find a boot disk that DOES support your hard disk.  (Hint: try looking for
rescue disks from various distributions on big mirror sites)
(8) Boot off your rescue disk.  Mount the disk you copied Parted onto.
(9) Run Parted:
	# cd /mnt/floppy
	# LD_LIBRARY_PATH=. ./parted


------------------------------------------------------------------------------
2	USING PARTED
------------------------------------------------------------------------------

Unfortunately, partitioning your disk is rather complicated.  This is because
there are interactions between many different systems that need to be taken
into consideration:

  * the BIOS or firmware - the program that is built into a ROM chip inside your
computer, that does memory checks, etc.  You can not (easily) change programs
in this system.  Examples of BIOS or firmware programs: AmiBIOS, Award,
Phoenix, OpenFirmware.   You will only have one of these programs.

  * the boot loader - the program that allows you to select which operating
system you want to use, and loads that operating system.  Examples: LILO, GRUB,
Yaboot, Quik.  You may have more than one boot loader installed, especially if
you have more than one type of operating system installed.

  * the operating system (at the moment, this must be GNU/Linux) that runs
Parted, and the other operating systems that you use.

  * the file system types - the way the data stored on partitions.  Examples
of these are: ext2, fat, hfs, reiserfs.  You will often have partitions of
different file system types.

Parted supports many combinations of the above, and will support more in the
future.  Therefore, there chapter 3 is on BIOSes, chapter 4 is on boot loaders,
chapter 5 is on operating systems, and chapter 6 is on file systems.
	This chapter describes how to use Parted, which is largely the same,
no matter what systems you are using.  You should read this chapter, then each
of chapters 3, 4, 5 and 6.  However, you only need to read the sections that are
relevant to you.  For example, if you are only using LILO as your boot loader,
then you only need to read the introduction, and the section on LILO in
chapter 4.


2.1	Running 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

Options (like --help) can only be specified on the command line.

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

	(parted) resize 1 52.0005 104.5
	(parted) mkfs 2 fat

Unambiguous abbreviations are allowed.  For example, you can type "p" instead
of "print", and "re" instead of "resize".  Commands can be typed in, either in
English, or your native language (if your language has been translated).  This
may create ambiguouities.

Also: note that you can specify decimal places in the numbers corresponding
to partition locations (in megabytes).


2.2	Options
------------------------------------------------------------------------------
-h, --help                    display a help message
-i, --interactive             where necessary, prompt for user intervention
-s, --script                  never prompt for user intervention
-v, --version                 display the version


2.3	Command summary
------------------------------------------------------------------------------
check MINOR                   do a simple check on the file system
cp [FROM-DEVICE] FROM-MINOR TO-MINOR      copy file system to another partition
help [COMMAND]                prints general help, or help on COMMAND
mklabel LABEL-TYPE            create a new disk label (partition table)
mkfs MINOR FS-TYPE            make a file system FS-TYPE on partition MINOR
mkpart PART-TYPE [FS-TYPE] START END      make a partition
mkpartfs PART-TYPE FS-TYPE START END      make a partition with a file system
move MINOR START [END]        move partition MINOR
name MINOR NAME               name partition MINOR NAME
print                         display the partition table
quit                          exit program
resize MINOR START END        resize file system on partition MINOR
rm MINOR                      delete partition MINOR
select DEVICE                 choose the device to edit
set MINOR FLAG STATE          change a flag on partition MINOR

FLAG is one of: boot, root, swap, hidden, raid, lvm, lba

FS-TYPE is one of: ext2, FAT, hfs, linux-swap, ntfs, reiserfs

LABEL-TYPE is one of: sun, bsd, mac, loop, pc98, msdos

MINOR is the partition number used by Linux.

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.  To be even more precise: an extended partition is structured like
a disk drive, and holds a "primary" partition (the logical partition) and
optionally another "extended" partition, which again is sudivided ....
There must be at most one extended partition, which takes up
the space of one primary partition.  If you are not using an msdos disk label,
then you can only have primary partitions.

START and END are measured in megabytes, starting from 0.  You can use
decimal numbers (eg: 1258.9)


2.4	Detailed command descriptions
------------------------------------------------------------------------------

2.4.1	check
-------------
	check MINOR                   do a simple check on the file system

The check command checks if a file system has any errors.

Example:

	(parted) check 1


2.4.2	cp
----------
	cp [FROM-DEVICE] FROM-MINOR TO-MINOR      copy file system to another
        					  partition

Copies a partition to another partition, deleting the original contents of
the destination partition. The first MINOR number refers to the source
partition, and the second to the destination partition.

An optional parameter, a device can be given, which specifies which device
the source partition is on.

Supported file systems:
  * ext2 (provided the destination partition is larger than the source
partition)
  * FAT
  * linux-swap	(equivalent to mkfs on destination partition)

Example:

	(parted) cp /dev/hdb 2 3

	Copies partition 2 of /dev/hdb (i.e. /dev/hdb2) to partition on 3,
	on the device Parted was loaded with, destroying the original contents
	of partition 3.


2.4.3	help
------------
	help [COMMAND]                prints general help, or help on COMMAND

Example:

	(parted) help resize


2.4.4	mklabel
---------------
	mklabel LABEL-TYPE            create a new disk label (partition table)

Creates a new disk label, of type LABEL-TYPE.  The new disk label will have no
partitions.  This command (normally) won't technically destroy your data, but
it will make it basically unusable, and you will need to use a program like
gpart (see section 9) to recover any partitions.  Gpart only works for msdos
disk labels (AFAIK).  We could/should add this feature to Parted.

Note: everyone seems to have a different word for "disk label" - these are all
the same thing: partition table, partition map.  Also, the Master Boot Record on
x86 machines is stored in the same sector as Partition Tables (you don't need to
know this to use Parted).

Supported disk labels:
  * bsd
  * loop (raw disk access)
  * mac
  * msdos
  * pc98
  * sun

Example:

	(parted) mklabel msdos


2.4.5	mkfs
------------
	mkfs MINOR FS-TYPE            make a file system FS-TYPE on partition
				      MINOR

Makes a new file system on a partition, destroying all data that resides on
that partition.

Supported file systems:
  * ext2
  * FAT
  * linux-swap

Example:

	(parted) mkfs 2 fat


2.4.6	mkpart
--------------
	mkpart PART-TYPE [FS-TYPE] START END      make a partition without a
						  (new) file system.  FS-TYPE
						  required for data partitions

Creates a new partition, WITHOUT creating a new file system on that partition.
This is useful for recovering a partition that you accidently deleted.

PART-TYPE is one of: primary, extended, logical.  Extended and logical are
only used for msdos disk labels.

Supported file systems:
  * ext2
  * FAT
  * HFS
  * linux-swap
  * NTFS
  * reiserfs

Example:

	(parted) mkpart logical ext2 0.0 692.1


2.4.7	mkpartfs
----------------
	mkpartfs PART-TYPE FS-TYPE START END      make a partition with a file
						  system

Creates a new partition with a new file system on it.  Do not use this command
to recover a deleted partition (use mkpart instead).

PART-TYPE is one of: primary, extended, logical.  Extended and logical are
only used for msdos disk labels.

Supported file systems:
  * ext2
  * FAT
  * linux-swap

Example:

	(parted) mkpartfs logical ext2 440 670


2.4.8	move
------------
	move MINOR START [END]        move partition MINOR

Moves a partition.  Note: move never changes the minor number.

If no END is given, the partition's size remains the same.

Supported file systems:
  * ext2 (provided the destination partition is larger than the source
partition)
  * FAT
  * linux-swap


2.4.9	name
------------
	name MINOR NAME               name partition MINOR NAME

Sets the name for a partition (Mac and PC98 only).  The name can be placed in
quotes.  Example:

	(parted) name 2 'Secret Documents'


2.4.10	print
-------------
	print                         display the partition table

Displays the partition table.

Example:

	(parted) print
	Disk geometry for /dev/hda: 0.000-2445.679 megabytes
	Disk label type: msdos
	Minor    Start       End     Type      Filesystem  Flags
	1          0.031    945.000  primary   FAT         boot, lba
	2        945.000   2358.562  primary   ext2
	3       2358.562   2445.187  primary   linux-swap


2.4.11	resize
--------------
	resize MINOR START END        resize file system on partition MINOR

Resizes a partition.  Note: resize never changes the minor number.  Note also:
extended partitions can be resized, so long as the new extended partition
completely contains all logical partitions.

Note that Parted does not require a file system to be "defragged" (Parted
can safely move data around if necessary).  It's a waste of time defragging.
Don't bother!

Supported file systems:
  * ext2 - restriction: the new START must be the same as the old START
  * FAT
  * linux-swap

Example:

	(parted) resize 3 200 850


2.4.12	rm
----------
	rm MINOR                      delete partition MINOR

Removes a partition.  If you accidently delete a partition with this command,
use mkpart (NOT mkpartfs) to recover it.  Also, you can use the gpart program
(see chapter 6) to recover damaged disk labels.

Note for msdos disk labels: if you delete a logical partition, all logical
partitions with a larger minor number will be renumbered.  For example, if you
delete a logical partition with a minor number of 6, then logical partitions
that were number 7, 8 and 9 would be renumbered to 6, 7 and 8 respectively.
This means you have to update /etc/fstab.

Example:

	(parted) rm 3


2.4.13	select
--------------
	select DEVICE                 choose the device to edit

Selects the device for Parted to edit.  The device will usually be a Linux hard
disk device, or, if direct access to a file system is required - a partition,
software RAID device, or LVM logical volume.

Example:

	(parted) select /dev/hdb


2.4.14	set
-----------
	set MINOR FLAG STATE          change a flag on partition MINOR

Changes a flag on a partition.  A flag can be either "on" or "off".  Some or
all of these flags will be available, depending on what disk label you are
using:
  * boot (Mac, MSDOS, PC98) - should be enabled if you want to boot off the
partition.  The semantics vary between disk labels.  For MSDOS disk labels,
only one partition can be bootable.  If you are installing LILO on a partition,
then that partition must be bootable.  For PC98 disk labels, all ext2 partitions
must be bootable (this is enforced by Parted).
  * lba (MSDOS) - this flag can be enabled, to tell MS DOS, MS Windows 9x and
MS Windows ME based operating systems to use Linear (LBA) mode.
  * root (Mac) - this flag should be enabled if the partition is the root
device to be used by Linux.
  * swap (Mac) - this flag should be enabled if the partition is the swap
device to be used by Linux.
  * hidden (MSDOS, PC98) - this flag can be enabled to hide partitions from
Microsoft operating systems.
  * raid (MSDOS) - this flag can be enabled to tell linux the partition is a
software RAID partition.
  * LVM (MSDOS) - this flag can be enabled to tell linux the partition is a
physical volume.

The print command displays all enabled flags for each partition.

Example:

	(parted) set 1 boot on


2.4.15	quit
------------
	quit                          exit program

Quits Parted.  It is only after Parted exits that the Linux kernel knows about
the changes Parted has made to the disks.  However, the changes caused by
typing your commands will PROBABLY be made to the disk immediately after typing
a command.  However, Linux's cache, and the disk's hardware cache may delay
this.


2.5	Examples
------------------------------------------------------------------------------

These examples attempt to cover the most common circumstances, with the
exception of disk imaging, which is covered in the chapter 8.

2.5.1	Example 1
-----------------

SITUATION

Suppose your disk layout looks like this:

	(parted) print
	Disk geometry for /dev/hda: 0.000-1000.000 megabytes
	Disk label type: msdos
	Minor    Start       End     Type      Filesystem  Flags
	1          0.063    500.000  primary   ext2
	2        500.000    625.000  primary   linux-swap

There is 375 Mb of free space at the end of the disk (after partition 2).
Partition 1 has an ext2 file system, which is the root device.  Partition 2
is a swap device.

Suppose you wanted to use the free space at the end of the disk for the file
system on partition 1.

EXAMPLE PROCEDURE

(1) The following steps will modify both the root file system on partition 1,
and the swap device on partition 2.  Therefore, you shouldn't be using either
partitions.  You should probably use a Parted boot disk (see section 1.5).
From the boot disk, run Parted:

	# parted /dev/hda

(2) Remove partition 2 (the swap partition).  Normally, you wouldn't want to
delete a partition with data on it.  However, a swap partition doesn't contain
data when it isn't "swapped on" (mounted), so you can remove it, and create a
replacement swap partition later.

	(parted) rm 2

(3) Create the new swap partition at the end of the disk:

	(parted) mkpartfs primary linux-swap 875 999.9
	(parted) print
	Disk geometry for /dev/hda: 0.000-1000.000 megabytes
	Disk label type: msdos
	Minor    Start       End     Type      Filesystem  Flags
	1          0.063    500.000  primary   ext2
	2        875.000   1000.000  primary   linux-swap

(4) Grow partition 1, into the adjacent free space:

	(parted) resize 1 0.063 874.9

All done!

	(parted) print
	Disk geometry for /dev/hda: 0.000-1000.000 megabytes
	Disk label type: msdos
	Minor    Start       End     Type      Filesystem  Flags
	1          0.063    874.999  primary   ext2
	2        875.000   1000.000  primary   linux-swap


2.5.2	Example 2
-----------------

SITUATION

Suppose your disk layout looks like this:

	Disk geometry for /dev/hda: 0-8063.5 megabytes
	Disk label type: msdos
	Minor   Start     End    Type            Filesystem     Flags
	1          0.0     23.5  primary         ext2           boot
	2         23.5   8056.0  extended
	5         23.6   3545.6  logical         ext2
	6       3545.6   7067.7  logical         ext2
	7       7067.7   7326.5  logical         ext2
	8       7326.5   7585.4  logical         ext2
	9       7585.4   7844.2  logical         linux-swap

	Filesystem            Size  Used Avail Use% Mounted on
	/dev/hda8             251M   31M  207M  13% /
	/dev/hda1              23M  2.4M   19M  11% /boot
	/dev/hda5             3.4G  577M  2.7G  18% /usr
	/dev/hda6             3.4G  289M  2.9G   9% /home
	/dev/hda7             251M   12M  226M   5% /var

Suppose you wanted to increase the /var partition (/dev/hda7) to 1GB, using
some space from /home (/dev/hda6).

To resize a partition with Parted, you use the resize command:

	(parted) resize PARTITION_NUMBER NEW_START NEW_END

NEW_START must be the same as the old start for ext2 partitions
(unfortunately).  So this process is going to be rather complicated.  It IS
possible, though :-)

Note: if Parted supported moving the start of ext2 partitions (like it does
with FAT partitions), then it would be trivial:

	(parted) resize 6 3545.6 6200
	(parted) resize 7 6200 7326.5

EXAMPLE PROCEDURE:

(1) Shrink the /home partition (/dev/hda6) by 500MB:

	# parted /dev/hda
	(parted) resize 6 3545.6 6200

(2) Make a new partition in it's place.  This is where "/var" will be,
eventually.  This new partition will be numbered 10.

	(parted) mkpartfs logical ext2 6200 7067.7

(3) Copy the old /var partition (/dev/hda7) to the new one (/dev/hda10).

	(parted) cp 7 10

(4) Delete the old /var

        (parted) rm 7


At this point: all logical partitions > 7 just changed number.  So 8, 9 and 10
become 7, 8 and 9 respectively.

This renumbering won't take place while any partitions are mounted on that
disk (this will happen when you reboot).  That's what that warning message
is talking about.  So you should NEVER attempt to mount a file system touched
by Parted (resized or created by Parted), before rebooting, if you get this
message.

(5) Resize the new /var partition (now numbered 9), adding the space from
the old /var partition:

	(parted) resize 9 6200 7326.5
        (parted) quit
	Warning: The kernel was unable to re-read the partition table on
	/dev/hda (Device or resource busy).  This means Linux knows nothing
	about any modifications you made.  You should reboot your computer
	before doing anything with /dev/hda.

(6) Since the partition numbers have changed, /etc/fstab must be updated.
This can be done before rebooting, because the root device wasn't touched
by Parted.  (If you want to use Parted to do something to the root device,
you need to use the boot disk).

If the old /etc/fstab looks like this:

/dev/hda8               /                       ext2    defaults        1 1
/dev/hda1               /boot                   ext2    defaults        1 2
/dev/hda6  /home  ext2  grpquota,usrquota  0  2
/dev/cdrom              /mnt/cdrom              iso9660 noauto,owner,ro 0 0
/dev/hda5               /usr                    ext2    defaults        1 2
/dev/hda7  /var  ext2  grpquota,usrquota  0  2
/dev/fd0                /mnt/floppy             auto    noauto,owner    0 0
none                    /proc                   proc    defaults        0 0
none                    /dev/pts                devpts  gid=5,mode=620  0 0
/dev/hda9               swap                    swap    defaults        0 0

A few lines need to be changed:
  * /var is now /dev/hda9 (because we copied it to a new partition)
  * /dev/hda8 (the root device) has been renumbered to /dev/hda7
  * /dev/hda9 (the swap device) has been renumbered to /dev/hda8

The new /etc/fstab looks like this:

/dev/hda7               /                       ext2    defaults        1 1
/dev/hda1               /boot                   ext2    defaults        1 2
/dev/hda6  /home  ext2  grpquota,usrquota  0  2
/dev/cdrom              /mnt/cdrom              iso9660 noauto,owner,ro 0 0
/dev/hda5               /usr                    ext2    defaults        1 2
/dev/hda9  /var  ext2  grpquota,usrquota  0  2
/dev/fd0                /mnt/floppy             auto    noauto,owner    0 0
none                    /proc                   proc    defaults        0 0
none                    /dev/pts                devpts  gid=5,mode=620  0 0
/dev/hda8               swap                    swap    defaults        0 0

(7) Reboot.  That's it!


------------------------------------------------------------------------------
3	BIOSES AND FIRMWARE
------------------------------------------------------------------------------

"BIOS" (Basic Input/Output System) and "firmware" mean the same thing.  However,
on PC and PC98 based computers, the word BIOS is more common.  On Apple
Macintosh and Sun computers, the word "firmware" is more common.
	The BIOS or firmware program is built into a ROM chip inside your
computer, that does memory checks, etc.  You can not (easily) change this
program.  Since BIOSes today are generally compatible with BIOSes in use 20
years ago, these programs tend to have an antiquated design.  Features have been
added in counter-intuitive ways over the years, leading to overly complicated
systems that cause a lot of confusion today.


3.1	PC BIOSes
------------------------------------------------------------------------------
There are a few popular PC BIOSes: AmiBIOS, Award, Phoenix, and others.  They
all work in a similar way.  None of these BIOSes understand or know about
partition tables.  They affect partitioning indirectly.
	When your computer boots up:
(1) these BIOSes load the first bit of the boot loader program, stored on the
MBR (Master Boot Record) on the hard disk.
(2) the BIOS executes the first bit of the boot loader
(3) the boot loader program uses the BIOS to load the rest of itself.
(4) the boot loader uses the BIOS to load the operating system (or, perhaps
another boot loader, in which case you go to step 2 again)
(5) the operating system may or may not use the BIOS to do normal file system
access.  (Windows usually does, Linux or BSD do not)

	Steps (3) to (5) involve programs communicating with the BIOS, to
ask it to talk to the disks.  There are two ways of talking to the BIOS to do
this: by using CHS (Cylinders Heads and Sectors) or LBA (Linear Block
Addressing).  Older BIOSes will only support CHS.  New BIOSes usually support
both LBA and CHS, although CHS support may be phased out in the future.  (CHS
is generally considered to be a horrible legacy)
	Steps (3) and (4), done by the boot loader will always use the same
access method - either always LBA or always CHS.  In the case of the Windows
boot loader, this is determined by the LBA flag on the Windows boot partition.
(See 2.4.14 for information about flags).   In the case of Linux, you will
probably be using either LILO or GRUB as your boot loader.  GRUB uses LBA if it
is available, and CHS otherwise.  LILO requires that you choose, when you
install it (with the linear, or lba32 options).
	Step (5) - IO done by the operating system - only Windows does it's
IO through the BIOS.  [We still don't know enough about the
problems, but it seems Windows can have it's own problems with CHS mode.
People have told us about occassions where Windows corrupts it's own file
systems, etc.  It's really hard for us to know what's going on.  We strongly
recommend you use LBA, if you can!]
	So, there are 3 possible situations, which are all covered here:
(1) You are using CHS mode, and your BIOS only supports CHS mode.
(2) You are using CHS mode, and your BIOS supports both CHS and LBA.
So, you want to convert from CHS mode to LBA mode As Soon As Possible TM.
(3) You are using LBA mode already.

3.1.1	Using Parted with CHS mode
----------------------------------
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"

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.
	Sometimes, Parted will complain that the partitions aren't aligned to
cylinder boundaries.  Parted will give you the option to ignore.  If you
ignore, then Parted will do some tricks with your partition table.  Linux
will have no problems.  DOS and Windows will have no problems if they are
using LBA mode.  If DOS/Windows is using CHS mode, then reinstalling the
the boot loader (see section 4.3) should solve any problems.
	Partitions that are involved in the boot process must end before
cylinder 1024, if CHS mode is being used.  See the section on boot loaders to
determine if a partition is involved in the boot process.  The typical setup
is to have a small Linux /boot partition, a Windows partition and then the Linux
partition(s).

3.1.2	Converting from CHS to LBA
----------------------------------
To make the Windows boot loader + operating system use LBA mode, just set
the LBA flag on all FAT partitions (see section 2.4.14).  You should have
no problems.  If you do have problems booting Windows, then reinstalling the
Windows boot loader will fix it (see section 4.3)
	Linux doesn't use the BIOS for IO.  However, the boot loader (LILO
or GRUB) may.  GRUB automatically uses LBA, if it is available.  LILO requires
the "linear" or "lba32" option.  So, if LILO still boots after changing
/etc/lilo.conf reinstalling with /sbin/lilo (see section 4.1), then everything's
done!  (If you have problems, just revert back to CHS, by removing "linear"
or "lba32", and reinstalling lilo from a boot disk)

Now that you're using LBA, read on... 

3.1.2	LBA mode
----------------
LBA solves all of CHS's problems.  However, there is no reliable way for
Linux or Parted to know that you're using LBA, so Parted may give you
warnings about cylinders not being aligned, or the BIOS geometry being
inconsistent, etc.  You can ignore these messages.  (Old versions of Parted
had problems, which have all been solved)
	When your disk is in LBA mode, Parted (and most other programs) will
say your CHS geometry is X/255/63.

3.2	Macintosh OpenFirmware
------------------------------------------------------------------------------
There are two major version of the PowerMac's OpenFirmware - one used on
"old world", and one on "new world" PowerMac.  They have significant
differences.  However, both understand partition tables.
	Both require that the user choose exactly one partition to be the boot
partition (the partition with the boot loader).  However, they use different
mechanisms to do this.

3.2.1	Old world OpenFirmware
------------------------------
The partition chosen to boot is set by various boot loaders, like Quik.  So,
you shouldn't need to do anything.  We could add support for this in Parted, if
someone screams louldy enough....

3.2.2	New world OpenFirmware
------------------------------
New world OpenFirmware requires the boot partition to be HFS and marked as
a boot partition.  It uses a different mechanism to be marked as the boot
partition.  This is controlled with Parted's "boot" flag.  For example:

	(parted) set 2 boot on


3.3	PC98 BIOS
------------------------------------------------------------------------------
The PC98 BIOS allows you to mark any number of partitions as bootable.  You
can mark or unmark a partition as bootable with Parted's "boot" flag.  For
example:

	(parted) set 2 boot off


------------------------------------------------------------------------------
4	BOOT LOADERS
------------------------------------------------------------------------------

The boot loader is the program that allows you to select which operating
system you want to use, and loads that operating system.  You may have more
than one boot loader installed, especially if you have more than one type of
operating system installed.  It is common for boot loaders to be able to load
other boot loaders.

When resizing a partition, lots of data gets moved around.  Many boot loaders
don't understand the file system.  They just remember where on the disk the
required boot loader information lies.  If this information is moved, they
must be told where it has been moved.  This is done by reinstalling the boot
loader (i.e.  re-running the installer program for the boot loader, which
usually involves issuing a single command at the shell)  Not all boot loaders
require this.

4.1	LILO (Linux Loader)
---------------------------
LILO is a popular boot loader for x86.  LILO's boot loader is usually installed
with:

	# /sbin/lilo

If you are using a boot disk, then you should do this instead: (where /dev/hda1
should be replaced with your root device)

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

(Not so) old versions of LILO don't support LBA mode (see section 3.1).
LBA mode is enabled with the lba32 or linear option, in /etc/lilo.conf (see
the LILO documentation for more info).
	If you use LBA mode, you should have no problems, as long as your
BIOS supports LBA.
	If you use CHS mode, then the partition with your /boot directory must
finish before cylinder 1024.  So, if you have a large disk (say, over 8 gig),
you should have a /boot partition near the start of your disk.

4.2	GNU GRUB (GRand Unified Bootloader)
-------------------------------------------
GRUB is a relatively new boot loader, for x86.  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, or the partition number changes,
then you need to reinstall Stage2 (please see the GRUB documentation).
Otherwise, you don't need to do anything.
	GRUB automatically detects if LBA is available, and will use it if
it is available (equivalent to LILO's "lba32" option).

4.3	MS DOS, MS Windows 9x, MS Windows ME
--------------------------------------------
DOS and Windows require you to re-install the boot loader if you change the
FAT type (FAT16 or FAT32) of the boot partition.  Parted will warn you before
attempting to do this.  To re-install the boot loader, you can either create
a boot disk, or use the boot CDROM.  The boot disk method does not work
with Windows ME.

BOOT DISK METHOD:  (DOS/Windows 9x)

 (1) creating a Windows boot disk
	* boot Windows.  THIS IMPLIES YOU SHOULD MAKE THE BOOT DISK BEFORE
YOU USE PARTED.
	* right click on the floppy drive in Windows Explorer.
	* click on "Format".
	* mark "Copy system files".
	* click on "Format".
	* copy C:\WINDOWS\COMMAND\SYS.COM to A:\   Note: you might have called
	C:\WINDOWS something else, like C:\WIN98.
 (2) boot off the Windows boot disk, by leaving the boot disk in the floppy
drive when booting.  You may need to tell your BIOS to boot off the floppy.
 (3) type at the DOS prompt:
	A:\>sys c:

CDROM METHOD:  (Windows 9x/ME)

 (1) insert the Windows CDROM, and boot from it.  (Select "boot without
CDROM support").
 (2) Type:
	A:\>c:
	C:\>cd \windows\command		(might be \win98\command, or similar)
	C:\WINDOWS\COMMAND>sys c:


Also, DOS and Windows impose a few restrictions:

  * the boot partition should be selected with the "boot" flag.  Only one
boot partition can be selected (sometimes called the "active" partition).  For
example, to set partition 3 to be the boot partition, do:

	(parted) set 3 boot on

  * the MS DOS and MS Windows 9x/ME can only boot from the first FAT partition.
That is, the FAT partition with the smallest MINOR number, that isn't hidden.
Note that boot loaders like GRUB and LILO (and some BIOSes) can change this
behaviour...

  * if you are using CHS addressing (rather than LBA addressing), then the boot
partition start must be less than cylinder 1024.  You can tell MS DOS to use
(or not to use) LBA addressing, by enabling or disabling the LBA flag on the
boot partition.  For example, to enable the LBA flag on partition 2, do:

	(parted) set 2 lba on

Note: LBA addressing is not supported in MS-DOS 6.22 and lower, as well as all
versions of PC-DOS.

Warning: some BIOSes won't enable LBA addressing, unless you enable it in the
BIOS as well.  If for some reason, Windows doesn't boot after changing this
flag, this is probably the problem.

  * 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.

4.4	MS Windows NT
---------------------
Windows NT can't read or boot from FAT32 partitions.  Therefore, you should
never convert FAT16 partitions to FAT32 partitions, if you want to use them
with Windows NT.

4.5	MS Windows 2000
-----------------------
Windows 2000 require you to re-install the boot loader if you change the FAT
type (FAT16 or FAT32) of the system partition.  Parted will warn you before
attempting to do this.  To re-install the boot loader, do:
 (1) Boot off the Windows 2000 CD
 (2) It will ask if you want to proceed installing.  Hit Enter
 (3) It will then ask you if you want to install a new system, or
Repair an existing system.  Choose the later (by pressing "R")
 (4) It will ask you if you want to do an automatic repair, or if you want
to use the recovery console.  Choose to use the recovery console.
 (5) At the console, type:

	C:\>fixboot

The NT/2000 boot loader also needs:
  * it's own boot sector code in a PRIMARY FAT12, 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).
  * with MS Windows NT the system partition should end before cylinder 1024,
and MUST start before cylinder 1024.  If it ends after cylinder 1024 and the
files necessary to boot are moved past this border MS Windows NT won't start
anymore!
  * 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.

4.6	Quik
------------
Quik is a popular boot loader for "old world" Macintosh PowerPCs.  You need to
reinstall Quik if you resize an ext2 partition, with:

	# /sbin/quik

4.7	Yaboot
--------------
Yaboot is a popular boot loader for "new world" Macintosh PowerPCs.  (New-world
refers to coloured PowerPCs manufactured since 1999)
	Yaboot needs it's own boot strap partition, that must be at least 800k.
So, if you are installing GNU/Linux from scratch, you would do something like:

	(parted) mklabel mac
	(parted) print
	Disk geometry for /dev/sda: 0.000-6149.882 megabytes
	Disk label type: mac
	Minor    Start       End     Filesystem  Name                  Flags
	1          0.000      0.031              Apple
	(parted) mkpart primary hfs 0.032 1
	(parted) print
	Disk geometry for /dev/hdb: 0.000-6149.882 megabytes
	Disk label type: mac
	Minor    Start       End     Filesystem  Name                  Flags
	1          0.000      0.031              Apple
	2          0.031      1.000
	(parted) set 2 boot on
	(parted) print
	Disk geometry for /dev/hdb: 0.000-6149.882 megabytes
	Disk label type: mac
	Minor    Start       End     Filesystem  Name                  Flags
	1          0.000      0.031              Apple
	2          0.031      1.000                                    boot

	You don't need to reinstall Yaboot after resizing a partition.  Yaboot
is installed with ybin.


------------------------------------------------------------------------------
5	OPERATING SYSTEMS
------------------------------------------------------------------------------
Parted only runs under GNU/Linux, at the moment.  However, it can be used to
resize partitions used by, or shared with other operating systems.

When you want to resize a file system, make sure it is not mounted.  Parted
can't resize mounted partitions (this may change in the future...).

If you want to resize your root or boot partition, use a boot disk (see
section 1.5), or use Andreas Dilger's online ext2 resizer, included in the
ext2resize package (see chapter 6 for details).

If you modify the partition table on a disk with a partition mounted on it,
you should reboot immediately.  Linux won't know about the changes you made
the partition table.  (This will be fixed, with kernel 2.4, and when we add
support for it)


5.1	GNU/Linux and FreeBSD
------------------------------------------------------------------------------
Both systems are rather flexible about disk labels, supporting many different
disk label types.
	FreeBSD has a disk label system, that is incompatible with MSDOS
partition tables, and a partition slice system, that is compatible with MSDOS
partition tables.  Parted only supports the BSD disk label system.  It is
unlikely to support the partition slice system, because the semantics are
rather strange, and don't work like "normal" partition tables do.


5.2	MS Windows and OS/2
------------------------------------------------------------------------------
MS Windows and OS/2 only supports the msdos disk label.  Therefore, if you
create a new disk label, you should use:

	(parted) mklabel msdos


5.3	MacOS
------------------------------------------------------------------------------
MacOS (and OpenFirmware) only understands the mac disk label.  Therefore, if
you create a new disk label, you should use:

	(parted) mklabel mac

Note: for Mac partition maps, you should avoid leaving free space around,
because free space regions take up entries in the partition map (and Linux
doesn't like having more than 15 entries).  For example, if you do:

	(parted) print
	Disk geometry for /dev/sda: 0.000-6149.882 megabytes
	Disk label type: mac
	Minor    Start       End     Filesystem  Name                  Flags
	1          0.000      0.031              Apple
	2          0.031      1.000                                    boot
	3          1.000   1000.000  ext2        root                  root
	(parted) mkpartfs primary ext2 1001 2000
	(parted) print
	Disk geometry for /dev/sda: 0.000-6149.882 megabytes
	Disk label type: mac
	Minor    Start       End     Filesystem  Name                  Flags
	1          0.000      0.031              Apple
	2          0.031      1.000                                    boot
	3          1.000   1000.000  ext2        root                  root
	4       1001.000   2000.000  ext2

There is 1 megabyte of free space between partitions 3 and 4.  You can avoid
this, by creating partitions 0.1M apart (in which case, Parted automatically
"pushes" them together).  So, in the above example, you should do this instead:

	(parted) mkpartfs primary ext2 1000.1 2000
	(parted) print
	Disk geometry for /dev/sda: 0.000-6149.882 megabytes
	Disk label type: mac
	Minor    Start       End     Filesystem  Name                  Flags
	1          0.000      0.031              Apple
	2          0.031      1.000                                    boot
	3          1.000   1000.000  ext2        root                  root
	4       1000.000   2000.000  ext2


------------------------------------------------------------------------------
6	FILE SYSTEMS
------------------------------------------------------------------------------

Parted has support for these operations:

Filesystem	detect	create	resize	copy	check
ext2		*	*	*1	*2	*3
fat		*	*	*4	*4	*
hfs		*
linux-swap	*	*	*	*	*
ntfs		*
reiserfs	*
ufs		*

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

(2) The partition you copy to must be bigger (or exactly the same size)
as the partition you copy from.

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

(4) 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?).
	So, in practise, you can always shrink your partition (because Parted
can shrink the cluster size), but you may not be able to grow the partition
to the size you want.  If you don't have any problems with using FAT32, you
will always be able to grow the partition to the size you want.
	Summary: you can always shrink your partition.  If you can't use
FAT32 for some reason, you may not be able to grow your partition.


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

	FIXME!!! this doesn't work quite right - but it should be OK for
	most people...

	# 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.


6.2	FAT16 and FAT32
------------------------------------------------------------------------------
Parted can not grow the cluster size of FAT file systems (yet).  This
places restrictions on resizing and copying partitions.  This is often quite
bizarre, because 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.

Note: when you copy or resize a file system, Parted will ask you if you want to
convert between FAT16 and FAT32 (if it is possible).  Therefore, if you just
want to convert a partition to FAT32 (without resizing), you can just resize
the partition to the same size.

6.2.1	MS DriveSpace partitions
--------------------------------
MS DriveSpace is a program that comes with MS Windows 95, that can be used
to compress FAT file systems.  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 Parted to resize and copy these partitions, but you
have to do a few extra things...

6.2.1.1	Growing a DriveSpace partition
--------------------------------------
(1) Use 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.

6.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 Parted's resize command to shrink the partition to the desired
size.  NOTE: 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.

6.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 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.


6.3	Reiserfs
------------------------------------------------------------------------------
Parted does not support reiserfs.  However, reiserfs does come with it's own
resize tool, resize_reiserfs.  Just to let you know ;-)


------------------------------------------------------------------------------
7	LVM, RAID AND RAW FILE SYSTEM ACCESS
------------------------------------------------------------------------------

LVM (Logical Volume Manager) is an alternative system to partitioning.  It
allows logical volumes (i.e. "virtual partitions") to be spread over many
physical volumes (i.e. hard disks and/or partitions).  LVM is supported on Linux
version 2.4, and later.

RAID (Redundant Array of Inexpensive Disks) is a system for using many disks
and/or partitions together, as a "virtual partition".  There are a few different
modes of utilising software RAID, that are essentially:
  * using multiple (small) disks for a single file system, to improve
performance and to make the entire space available available on a single file
system.
  * using multiple disks to store redundant copies of information, to improve
reliability and performance.
Software RAID is supported on Linux version 2.0, and later.

Hardware RAID is supported normally by Parted - so you need not read this
section if you are using hardware RAID (as opposed to software RAID).

LVM, software RAID and partitions are often used simultaneously, but they can
all be used independently:
  * LVM and software RAID are often composed of partitions, rather than raw
hard disks.
  * !!!  FIXME (Note: RAID used on LVM isn't supported by Linux yet (?))

GNU Parted does not support LVM and software RAID in full, but it is still
useful when used in combination with their respective tools.  Parted is useful
for these tasks:
  * creating a software RAID or LVM partition
  * creating, resizing or copying a file system on a logical volume (or "virtual
partition")


7.1	Creating a RAID or LVM partition
-------------------------------------------------------------------------------

To create a RAID or LVM partition, you must:
(1) Create a partition with the mkpart command.
(2) Set the LVM or RAID flag on the partition.

For example:

	(parted) mkpart primary ext2 0 4000
	(parted) set 1 lvm on

Note: the LVM or RAID partition will not be ready for use yet.  You still need
to run mkraid(8) for RAID, or use the LVM tools to initialise the physical
volume, and create logical groups, etc.


7.2	Manipulating a file system on a Software RAID or LVM logical volume
-------------------------------------------------------------------------------

Parted can manipulate RAID and LVM logical volumes, even though it does not
understand RAID or LVM.  It utilises Linux's support for RAID and LVM.
Therefore, you can only use these methods if your Linux kernel supports RAID
and/or LVM.

To manipulate a file system on a RAID or LVM logical volume (or, a raw
partition, for that matter), you can start parted by selecting the logical
volume (partition) device.  For example:

	# parted /dev/md0

For the rest of this chapter, "virtual device" will refer to the device Parted
is editting (in the immediately example above: /dev/md0).


7.2.1	Creating a file system
------------------------------
(1) Create a loop disk label.  This is a fake disk label, that tells Parted
to treat the virtual device as a single file system.  With this fake disk label,
there is either zero or one partition.

	(parted) mklabel loop

(2) Create the file system, by using Parted's mkpartfs command.  You should
make the start of the file system 0.  The partition can end anywhere inside the
virtual device.  You can find out the size of the virtual device with the print
command.  Eg:

	(parted) print
	Disk geometry for /dev/md0: 0.000-47.065 megabytes
	Disk label type: loop
	Minor    Start       End     Filesystem  Flags
	(parted) mkpartfs primary ext2 0 47.065
	(parted) print
	Disk geometry for /dev/md0: 0.000-47.065 megabytes
	Disk label type: loop
	Minor    Start       End     Filesystem  Flags
	1          0.000     47.065  ext2

7.2.2	Resizing a file system
------------------------------
You usually resize the file system at the same times as you resize your virtual
device.  If you are growing the file system and virtual device, you should grow
the device first (with the RAID or LVM tools), and then grow the file system.
If you are shrinking the file system and virtual device, you should shrink the
file system first, and then the virtual device afterwards.

To resize the file system in Parted, use the resize command.  For example:

	(parted) select /dev/md0
	(parted) resize 1 0 20

7.2.3	Copying a file system from a virtual device to a partition
------------------------------------------------------------------
Just use the cp command.  For example:

	(parted) select /dev/hda
	(parted) cp /dev/md0 1 3

7.2.4	Copying a file system to a virtual device
-------------------------------------------------
(1) Create the loop disk label on the virtual device.  For example:

	(parted) select /dev/md0
	(parted) mklabel loop

(2) Create a file system on the virtual device, with the mkpartfs command.  For
example:

	(parted) mkpartfs primary ext2 0 47.065

(3) Copy the partition with the cp command:

	(parted) select /dev/hda
	(parted) cp /dev/md0 3 1


------------------------------------------------------------------------------
8	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 CDROM 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 640 disk image file (eg: /root/cdimage/diskimage) in the CD
image directory: 

        # dd if=/dev/zero of=/root/cdimage/diskimage bs=1M count=640

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

        # parted /root/cdimage/diskimage mklabel msdos mkpart primary fat 0 639
	# parted /root/cdimage/diskimage cp /dev/hda 1 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.0# ./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 --script /dev/hda mklabel msdos mkpartfs primary fat 0 SOME-SIZE
	parted --script /dev/hda cp /mnt/cdrom/diskimage 1 1
	parted --script /dev/hda set 1 boot on
        /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? 


------------------------------------------------------------------------------
9	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 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 Parted
  * COPYING - the GNU General Public License, the terms under which GNU
Parted may be distributed
  * COPYING.DOC - the GNU Free Documentation Licence, the term under which
Parted's documentation may be distributed.
  * FAT - information on how the FAT resizer works (for programmers)
  * INSTALL - how to compile and install Parted, and most other free
software
  * TODO - planned features that are not yet implemented

These documents are not distributed with 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://www.linuxdoc.org/HOWTO/mini/Partition.html
  * 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
  * Software RAID HOWTO
      http://linas.org/linux/Software-RAID/Software-RAID.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 Parted.  The FAT code in Disk Drake is based on our
Parted code.  Here's how Disk Drake compares to 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
	- no support for non-PC architectures

  * dosfsck
  * e2fsck, resize2fs e2fsprogs (!)
  	http://web.mit.edu/tytso/www/linux/e2fsprogs.html
  * ext2resize - uses the same code as 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/
  * LVM   http://linux.msede.com/lvm
  * mkdosfs (!)  (sometimes called mkfs.msdos)
  * mke2fs (!)  (sometimes called mkfs.ext2)
  * mkfs (!)
  * mkswap (!)
  * quik (!)
  * reiserfs: NOTE: a reiserfs resizer is included with normal reiserfs
distribution.  http://devlinux.com/projects/reiserfs
  * yaboot (!)  http://ppclinux.apple.com/~benh/
  * ybin (!)  http://www.alaska.net/~erbenson/ybin/

