Table of Contents
GNU Parted Can create, resize, copy and delete ext2, fat and linux-swap partitions. It automatically moves blocks and updates the file system and partition table.
It can resize both the start and end of FAT partitions, but only the end of ext2 partitions.
Download: ftp://ftp.gnu.org/gnu/parted/ (25390 hits) Red Hat Packages: ftp://ftp.freshmeat.net/pub/rpms/parted/[] (7727 hits) Debian Packages: http://packages.debian.org/unstable/admin/parted.html Mirror List: http://www.gnu.org/prep/ftp.html (1007 hits) Homepage: http://www.gnu.org/software/parted/ (45993 hits) Changelog: ftp://ftp.gnu.org/gnu/parted/ChangeLog (3140 hits)
# parted /dev/hda print Disk geometry for /dev/hda: 0-19547.2 megabytes Minor Start End Type Filesystem Flags 1 0.0 502.0 primary ext2 2 502.0 2502.3 primary ext2 3 2502.3 8291.4 primary FAT boot 4 8291.4 19540.0 extended 5 8291.4 16347.4 logical ext2 6 16347.4 19540.0 logical FAT boot
In the fourth column, we have the partition type. There are three types of partitions: primary, extended and logical. Primary partitions are normal partitions that contain file systems. In an ideal world, there would only be primary partitions. Unfortunately, there can only be up to four primary partitions.
The first column, with the heading "Minor" is the partition number. Since there are up to 4 primary partitions, Primary partitions are numbered 1-4, and logical partitions are numbered 5 onwards.
The second and third column give the start and end of the partitions. The unit is in cylinders (more on this later). The size of each cylinder is given above as
The last column is the flags. There are 2 flags: hidden - useful for hiding partitions from Windows - and boot. Boot is used by the DOS boot code to determine which partition to boot off. More on this later.
Because the boot-loaders don't have hard disk drivers, they have to use the BIOS's drivers. Unfortuantely, the BIOS drivers are seriously broken. The BIOS requires that everyone that speaks about regions on a disk talk in terms of "geometry". This geometry system uses three numbers: cylinder, head, sector (CHS for short), that don't bear any resemblance to reality in any way at all. For example, a disk with geometry 784/255/63 has 784 cylinders, with 255 heads per cylinder, and 63 sectors per head. This means each cylinder has 255*63 sectors
Anyway, this geometry system requires that each disk have a size, given in CHS. There is no (reliable) way for the operating system to find out this size, but the operating system, and the BIOS must agree on what it is, none the less.
umount /export.old/ # !!
(parted) print Disk geometry for /dev/hda: 0-19547.2 megabytes Minor Start End Type Filesystem Flags 1 0.0 502.0 primary ext2 2 502.0 2502.3 primary ext2 3 2502.3 8291.4 primary FAT boot 4 8291.4 19540.0 extended 5 8291.4 16347.4 logical ext2 6 16347.4 19540.0 logical FAT boot
(parted) mkfs 5 ext2 -- Erhh... no confirming question asked!
(parted) resize 5 8291.4 16347 (parted) print Disk geometry for /dev/hda: 0-19547.2 megabytes Minor Start End Type Filesystem Flags 1 0.0 502.0 primary ext2 2 502.0 2502.3 primary ext2 3 2502.3 8291.4 primary FAT boot 4 8291.4 19540.0 extended 5 8291.4 16347.4 logical ext2 6 16347.4 19540.0 logical FAT boot
Warning: The kernel was unable to re-read your partition table, so you need to reboot before mounting any modified partitions. You also need to reinstall your boot loader before you reboot (which may require mounting modified partitions). It is impossible do both things! So you'll need to boot off a rescue disk, and reinstall your boot loader from the rescue disk. Read section 2.2 of the Parted User documentation for more information.
The following show the info when I resized my ext3 partition. Note that the result is not good though. My resized Linux (RH7.3) was unable to boot any more.
# fdisk -l
Disk /dev/hda: 255 heads, 63 sectors, 3736 cylinders Units = cylinders of 16065 * 512 bytes
Device Boot Start End Blocks Id System /dev/hda1 1 2550 20482843+ 1c Hidden Win95 FAT32 (LBA) /dev/hda2 2551 2678 1028160 82 Linux swap /dev/hda3 * 2679 3736 8498385 83 Linux
(parted) print Disk geometry for /dev/hda: 0.000-29311.734 megabytes Disk label type: msdos Minor Start End Type Filesystem Flags 1 0.031 20002.807 primary FAT hidden, lba 2 20002.808 21006.870 primary linux-swap 3 21006.870 29306.074 primary ext3 boot
(parted) check 2 (parted) check 3 Information: The ext2 filesystem passed a basic check. For a more comprehensive check, use the e2fsck program.
(parted) resize 3 21006.870 23000
(parted) print Disk geometry for /dev/hda: 0.000-29311.734 megabytes Disk label type: msdos Minor Start End Type Filesystem Flags 1 0.031 20002.807 primary FAT hidden, lba 2 20002.808 21006.870 primary linux-swap 3 21006.870 22999.306 primary ext3 boot
# fdisk -l
Disk /dev/hda: 255 heads, 63 sectors, 3736 cylinders Units = cylinders of 16065 * 512 bytes
Device Boot Start End Blocks Id System /dev/hda1 1 2550 20482843+ 1c Hidden Win95 FAT32 (LBA) /dev/hda2 2551 2678 1028160 82 Linux swap /dev/hda3 * 2679 2932 2040255 83 Linux
(parted) mkpartfs primary ext3 22999.307 29306.074 No Implementation: Support for creating ext3 file systems is not implemented yet. (parted) mkpart primary 22999.307 29306.074 Error: Unknown file system type. (parted) mkpart primary ext2 22999.307 29306.074 (parted)
# fdisk -l
Disk /dev/hda: 255 heads, 63 sectors, 3736 cylinders Units = cylinders of 16065 * 512 bytes
Device Boot Start End Blocks Id System /dev/hda1 1 2550 20482843+ 1c Hidden Win95 FAT32 (LBA) /dev/hda2 2551 2678 1028160 82 Linux swap /dev/hda3 * 2679 2932 2040255 83 Linux /dev/hda4 2933 3736 6458130 83 Linux
(parted) h check MINOR do a simple check on the filesystem cp [FROM-DEVICE] FROM-MINOR TO-MINOR copy filesystem to another partition help [COMMAND] prints general help, or help on COMMAND mklabel LABEL-TYPE create a new disklabel (partition table) mkfs MINOR FS-TYPE make a filesystem FS-TYPE on partititon MINOR mkpart PART-TYPE [FS-TYPE] START END make a partition mkpartfs PART-TYPE FS-TYPE START END make a partition with a filesystem 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 filesystem 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