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/index.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 [email protected]. To subscribe, write to [email protected] 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 [email protected]. 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 :-)
GNU Parted depends on the following packages to build correctly:
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.6 Using a Parted Boot Disk.
GNU libc 2.1 or higher is required. You can probably use older versions by using the `--disable-nls' option. See section 1.5 Building GNU Parted. (Note: I think we have now dropped this requirement. TODO: check if libc 2.0 works!)
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.
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).
If you want to compile GNU Parted, this is generally done with:
$ ./configure $ make
However, there are a few options for @command{configure}:
--without-readline
--disable-debug
--disable-dynamic-loading
--disable-fs
--disable-nls
--disable-shared
--disable-Werror
--enable-all-static
--enable-discover-only
--enable-mtrace
--enable-read-only
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, the disk image must be written to a floppy disk. In GNU/Linux, this can be done with
# 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 you will need to make your own boot disk. You can copy the parted binary from the parted bootdisk onto another disk, or try other boot disks, or make your own. You may find mkparted useful, which is a shell script to make custom parted boot disks. It is available at:
ftp://ftp.tux.org/pub/people/kent-robotti/mkparted
To copy parted from the boot disk onto another disk:
$ parted /dev/fd0 mklabel loop mkpartfs primary ext2 0 1.4
$ mount -t ext2 /dev/fd0 /mnt/floppy
$ cp /sbin/parted /mnt/floppy
$ cp /lib/* /mnt/floppy
$ umount /mnt/floppy
# cd /mnt/floppy # LD_LIBRARY_PATH=. ./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:
Parted suppports many combinations of BIOS, boot loader, operating system, and file systems, and will support more in the future. To further understand the roles of each, please see section 3. BIOSes and Firmware, section 4. Boot Loaders, section 5. Operating Systems, and section 6. File Systems supported by Parted.
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 on BIOSes, boot loaders, operating systems, and file systems. 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 section 4.1 LILO: a bootloader for the Linux kernel.
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 fat16
Options (like --help) can only be specified on the command line.
In interactive mode, commands are entered one at a time at a prompt, and modify the disk immediately. For example:
(parted) resize 1 52.0005 104.5 (parted) mkfs 2 fat16
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 ambiguities.
Also note that you can specify decimal places in the numbers corresponding to partition locations (in megabytes). Negative numbers count from the end of the disk, with "-0" being the end of the disk.
If you don't give a parameter to a command, Parted will ask you for it. For example:
(parted) resize 1 Start? 0 End? 400
Parted will always warn you before doing something that is potentially dangerous, unless it's something that's obviosuly dangerous (i.e. rm, mklabel, mkfs) For example, if you attempt to shrink a partition "too much" (i.e. by more than the free space available), Parted will automatically resize to the minimum it can without losing data. If this minimum is significantly different, it will warn you that it's doing something significanlty different to what you asked. Since many partitioning systems have complicated constraints, Parted will usually do something slightly different to what you asked. (For example, create a partitiong starting at 10.352, not 10.4)
When invoked from the command line, parted supports the following syntax:
# parted [option] device [command [argument]]
Available options and commands follow. For detailed explanations of the use of parted commands, see section 2.4 Parted Session Commands. Options begin with a hyphen, commands do not:
Options:
GNU Parted provides the following commands:
Checks if the file system on partition minor has any errors.
Example:
(parted) check 1
Check the file system on partition 1.
Copies the file system on the partition from-minor to partition to-minor, deleting the original contents of the destination partition.
An optional device parameter, from-device can be given, which specifies which device the source partition is on.
Supported file systems:
Example:
(parted) cp /dev/hdb 2 3
Copy 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.
Prints general help, or help on command.
Example:
(parted) help resize
Print help for the resize command.
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 will make it basically unusable, and you will need to use the rescue command (see section 9. Related Software and Info) to recover any partitions. Gpart only works for msdos disk labels (AFAIK), but is much better than parted at recovering partitions. Parted works on all partition tables. (1)
label-type must be one of these supported disk labels:
Example:
(parted) mklabel msdos
Create an msdos style disklabel.
Makes a file system fs-type on partition minor, destroying all data that resides on that partition.
Supported file systems:
Example:
(parted) mkfs 2 fat32
Make a fat32 file system on partition 2.
Creates a new partition, without creating a new file system on that partition. This is useful for creating partitions for file systems (or LVM, etc.) that Parted doesn't support. You may specify a file system type, to set the appropriate partition code in the partition table for the new partition. fs-type is required for data partitions (i.e., non-extended partitions). start and end are the offset from the beginning of the disk, that is, the "distance" from the start of the disk.
part-type is one of: primary, extended, logical. Extended and logical are only used for msdos and mips disk labels.
fs-type must be on of these supported file systems:
Example:
(parted) mkpart logical 0.0 692.1
Create a logical partition that will contain an ext2 filesystem. The partition will start at the beginning of the disk, and end 692.1 megabytes into the disk.
Creates a new partition of type part-type with a new file system of type fs-type on it. The new partition will start start megabytes, and end end megabytes from the beginning of the disk. 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 and mips disk labels.
fs-type must be one of these supported file systems:
Example:
(parted) mkpartfs logical ext2 440 670
Make a logical partition and write an ext2 file system, starting 440 megabytes and ending 670 megabytes from the beginning of the disk.
Moves partition on the disk, by moving its beginning to start. Note: move never changes the minor number.
If no end is given, the partition's size remains the same.
Supported file systems:
Example:
(parted) move 2 150
Move partition with minor number 2 so that it begins 150 megabytes from the start of the disk.
Sets the name for the partition minor (Mac and PC98 only). The name can be placed in quotes.
Example:
(parted) name 2 'Secret Documents'
Set the name of partition 2 to `Secret Documents'.
Displays the partition table on the device parted is editing.
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
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.
Looks for file system signatures around start and end. If one is found, it will ask you if you want to create a partition for it. This is useful if you accidently deleted a partition with parted's rm command, for example.
Example:
(parted) print Disk geometry for /dev/hdc: 0.000-8063.507 megabytes Disk label type: msdos Minor Start End Type Filesystem Flags 1 0.031 8056.032 primary ext3 (parted) rm Partition number? 1 (parted) print Disk geometry for /dev/hdc: 0.000-8063.507 megabytes Disk label type: msdos Minor Start End Type Filesystem Flags
OUCH! We deleted our ext3 partition!!! Parted comes to the rescue...
(parted) rescue Start? 0 End? 8056 Information: A ext3 primary partition was found at 0.031Mb -> 8056.030Mb. Do you want to add it to the partition table? Yes/No/Cancel? y (parted) print Disk geometry for /dev/hdc: 0.000-8063.507 megabytes Disk label type: msdos Minor Start End Type Filesystem Flags 1 0.031 8056.032 primary ext3
It's back! :)
Resizes the partition with number minor. The partition will start start from the beginning of the disk, and end end from the beginning of the disk. resize never changes the minor number. 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:
Example:
(parted) resize 3 200 850
Resize partition 3, so that it begins 200 megabytes and ends 850 megabytes from the beginning of the disk.
Removes the partition with number minor. If you accidently delete a partition with this command, use mkpart (not mkpartfs) to recover it. Also, you can use the gpart program (see section 9. Related Software and Info) 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, for example, that you have to update `/etc/fstab' on GNU/Linux systems.
Example:
(parted) rm 3
Remove partition 3.
Selects the device, 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
Select `/dev/hdb' (the slave device on the first ide controller on Linux) as the device to edit.
Changes a flag on the partition with number minor. 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:
The print command displays all enabled flags for each partition.
Example:
(parted) set 1 boot on
Set the `boot' flag on partition 1.
These examples attempt to cover the most common circumstances, with the exception of disk imaging, which is covered in section 8. Disk Imaging.
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. You could do the following:
# parted /dev/hda
(parted) rm 2
(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
(parted) resize 1 0.063 874.9All 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
Suppose your disk layout looks like this:
(parted) print 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 $ df -h 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. (2)
# parted /dev/hda (parted) resize 6 3545.6 6200
(parted) mkpartfs logical ext2 6200 7067.7
(parted) cp 7 10
(parted) rm 7At this point: all logical partitions greater than 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.
(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.
/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 0A few lines need to be changed:
/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
"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.
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.
The following occurs when your computer boots up:
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 system.)
Steps (3) and (4), performed 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 section 2.4.16 set for information about 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 its IO through the BIOS. [We still don't know enough about the problems, but it seems Windows can have its own problems with CHS mode. People have told us about occassions where Windows corrupts its 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:
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 @command{/sbin/lilo}, and reboot 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 Legacy Microsoft Operating System Bootloaders) should solve any problems - but switching to LBA mode is preferrable (see see section 3.1.2 Converting from CHS to LBA mode BIOS).
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).
To make the Windows boot loader + operating system use LBA mode, just set the LBA flag on all FAT partitions section 2.4.16 set. You should have no problems. If you do have problems booting Windows, then reinstalling the Windows boot loader will fix it section 4.3 Legacy Microsoft Operating System Bootloaders.
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 @command{/sbin/lilo}, then everything's done! See section 4.1 LILO: a bootloader for the Linux kernel. (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...
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 if you are using LBA mode. (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 - unless you have switched from CHS to LBA.
There are two major version of the PowerMac's OpenFirmware - one used on "old world", and one on "new world" PowerMac. "New world" refers to coloured PowerPCs manufactured since 1999. They have significant differences. However, both understand partition maps.
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.
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 loudly enough...
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
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
The SGI / MIPS firmware allows booting from special boot files, which are managed by the partition table. In Parted, these boot files are treated as logical partitions inside an extended partition.
For example:
Disk label type: mips Minor Start End Type Filesystem Name Flags 9 0.000 2.732 extended 17 0.002 0.002 logical sgilabel 18 0.003 1.162 logical symmon 19 1.404 1.670 logical sash 1 2.732 8555.212 primary xfs root 2 8555.213 8682.270 primary swap
Partition 9 is the extended partition (volume header in SGI/MIPS terminology) where the boot files may lie. Partitions 17, 18 and 19 are the boot files. There names can be manipulated with parted's name command. Partitions 1 and 2 are normal partitions. They can't have names.
Note that Linux doesn't see the boot files as partitions (maybe it should?). So /dev/hda17 doesn't exist in Linux. You should use dvhtool(8) to manipulate boot files.
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.
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
Old versions of LILO don't support LBA mode (see section 3.1 The PC BIOS). 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 gigabytes), you should have a `/boot' partition near the start of your disk.
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).
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.
A:\>sys c:
A:\>c: C:\>cd \windows\command (might be \win98\command, or similar) C:\WINDOWS\COMMAND>sys c:That's all there is to it.
Also, DOS and Windows impose a few restrictions:
(parted) set 3 boot on
(parted) set 2 lba onNote: 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.
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.
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:
C:\>fixbootThe system should boot successfully now.
The NT/2000 boot loader also needs:
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
Yaboot is a popular boot loader for "new world" Macintosh PowerPCs. ("New-world" refers to coloured PowerPCs manufactured since 1999.)
Yaboot needs its 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 section 9. Related Software and Info.
Parted only runs under GNU/Linux and GNU/Hurd, 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 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.)
If you want to resize your root or boot partition, use a boot disk See section 1.6 Using a Parted Boot Disk, or use Andreas Dilger's online ext2 resizer, included in the ext2resize package section 6.2 GNU Parted and the Second Extended Filesystem.
Both GNU/Linux and FreeBSD systems are rather flexible about disk labels, supporting many different disk label types.
Because it is rather unusual for a machine to use hard disks with labels normally used on other architectures, standard distributions of the Linux kernel often only support the popular disk labels for the architecture for which the kernel was compiled. For example, a standard Linux kernel compiled for a PC will likely not have support for Mac or Sun disk labels. To access the file systems on disks with unsupported disk labels, the kernel will have to be recompiled.
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.
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
MacOS (and OpenFirmware) only understands the mac disk label. Therefore, if you create a new disk label, you should use:
(parted) mklabel mac
Note that 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
Parted has support for these operations:
Parted doesn't directly support for copying ext2 file systems (yet). There are a few ways of achieving this, however:
# mount -t ext2 /dev/hda2 /mnt/dst # find /mnt/src -depth | cpio -pm /mnt/dst
# dd if=/dev/src-device of=/dev/dst-device bs=1024 count=old_size # parted /dev/hda resize 2 start endwhere old_size is the size of the original partition in kilobytes. start and end are the new start and end for the duplicate partition.
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.
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...
To increase the size of a DriveSpace partition, do the following
To decrease the size of a DriveSpace partition, do the following:
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:
Parted supports reiserfs if libreiserfs is installed. Parted detects this at runtime, and automatically enables support. You can download libreiserfs from:
Note that libreiserfs is new software, and hasn't been tested widely yet.
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:
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.
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:
To create a RAID or LVM partition, you must:
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.
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 our example cases, `/dev/md0').
To create a file system on an LVM volume, use the following steps:
(parted) mklabel loop
(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
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
To copy a filesystem from an LVM or RAID virtual device, just use the cp command. For example:
(parted) select /dev/hda (parted) cp /dev/md0 1 3
To copy a file system from an LVM or RAID virtual device, use the following recipe:
(parted) select /dev/md0 (parted) mklabel loop
(parted) mkpartfs primary ext2 0 47.065
(parted) select /dev/hda (parted) cp /dev/md0 3 1
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:
# dd if=/dev/zero of=/root/cdimage/diskimage bs=1M count=640
# parted /root/cdimage/diskimage mklabel msdos # parted /root/cdimage/diskimage mkpart primary fat32 0 639 # parted /root/cdimage/diskimage cp /dev/hda 1 1
localhost:~/parted-1.0.0# ./configure --disable-nls --without-readline --disable-shared; make
mount /dev/cdrom /mnt/cdrom parted --script /dev/hda mklabel msdos parted --script /dev/hda 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/haltsome-size is the size you desire the first partition to use.
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?
If you want to find out more information, feel free to send questions to [email protected]. (!) indicates the information/software is probably included in your distribution.
These files in the Parted distribution contain further information:
These documents are not distributed with Parted, but you may find them useful. Most of these will probably be in your distribution. For example, on Red Hat Linux, look on the CD in `/doc/HOWTO' and `/doc/FAQ'.
Other related programs are listed here. Some of these also have useful documentation:
Copyright (C) 2000 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:
Copyright (C) year your name. 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 Invariant Sections being list their titles, with the Front-Cover Texts being list, and with the Back-Cover Texts being list. A copy of the license is included in the section entitled ``GNU Free Documentation License''.
If you have no Invariant Sections, write "with no Invariant Sections" instead of saying which ones are invariant. If you have no Front-Cover Texts, write "no Front-Cover Texts" instead of "Front-Cover Texts being list"; likewise for Back-Cover Texts.
If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.
This manual is based on the file, USER, included in GNU Parted version 1.4.22 source distribution. The GNU Parted source distribution is available at ftp.gnu.org/gnu/parted.
Texinfo formatting by Richard M. Kreuter, 2002.
This manual is distributed under the GNU Free Documentation License, version 1.1 or later, at your discretion, with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. See section A. Copying This Manual, for details.
Jump to: b - c - d - e - f - g - h - i - l - m - n - o - p - q - r - s - t - u - w
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).
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
This document was generated on 23 June 2002 using texi2html 1.56k.