International * Contact  * Sitemap  * Links  * Register Software
Search  
 SUSE - simply change

Home Users

 Novell
  | Home  |  | Overview  |  | Products  |  | Support  |  | Downloads  |  | Distributors & Resellers  |
  SUSE LINUX Support   Online Help   License information   Security   Feedback
  Printable page

Easy Partitioning: GNU Parted

Tino Tanner

LEGAL DISCLAIMER: Please note that partitioning represents a serious manipulation of your system, and should never be performed without an up-to-date backup of your data. Use GNU Parted only if you are fully aware of its function. If that is the case, adhere closely to the instructions provided below. SUSE GmbH, the author, and the Portal editors will not accept liability for any damages that may occur to your system as a result of the information presented in this article.

Why and How?

Ever wondered about a simple way of resizing existing partitions? The need for additional partitions may arise due to a variety of reasons. For example, you may decide to place your home directory on a separate partition. In this way, your data will not be affected adversely even if you reinstall your entire system. Or you may want to have an additional partition for an extra OS.

Whatever your objective may be, GNU Parted is a simple tool for resizing ext2 and FAT (subject to some limitations, see detailed documentation) partitions.

Let's Get Going ...

Let's take a look at a simple example. The command df reveals that your system has the following partitions:

linux:~# df
Filesystem   1k-blocks	Used	Available   Use%	Mounted on
/dev/hda3    4003048    1684332 2318716     42%         /
/dev/hda1      21927       2672   18123     13%         /boot
usbdevfs       21927      21927       0     100%        /proc/bus/usb

You want to resize /dev/hda3 in order to make room for another partition, /dev/hda4, which you intend to mount to /home. Thus, all user data will be stored on a separate partition. Before you start messing with the partitions, make sure you have up-to-date backups of your important data.

GNU Parted is included in SUSE LINUX 7.2 (package parted, series ap). However, if I were you I wouldn't bother with installing GNU Parted on the system (if you want to modify your root partition you need a boot disk anyway); simply download the image file (e.g. partboot-1.4.15.img) from ftp://ftp.gnu.org/gnu/parted/bootdisk/ and create a boot disk with the command:

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

Next, reboot your system with the boot disk. Start Parted with

parted DEVICE

DEVICE is the hard disk you want to edit, e.g. /dev/hda. Parted will start in interactive mode.

To view the partition table, type

(parted) print

This is what the result looks like:

Disk geometry for /dev/hda: 0.000-4126.992 megabytes
Disk label type: msdos
Minor    Start       End      Type       Filesystem  Flags
1          0.031     22.148   primary    ext2        boot
2         22.148    155.039   primary    linux-swap
3        155.039   4126.992   primary    ext2

Next, enter the command resize MINOR START END to downsize /dev/hda3 according to your requirements, e.g.

(parted) resize 3 155.039 3499.453

Then, use the remaining space (about 618 MB) to create a new primary partition with the command mkpartfs TYPE FILESYSTEM START END, e.g.

(parted) mkpartfs primary ext2 3499.453 4126.992

Quit Parted with

(parted) quit

Now reboot the system (don't forget to remove the boot floppy). Log in to a console as root. Mount the new partition /dev/hda4 to a mount point of your choice, e.g.

mount /dev/hda4 /mnt

Copy the contents of the /home directory to the new partition - and don't forget to verify this action has been successful before you continue ...

cp -dpR /home/* /mnt

Delete the contents of the /home directory. Well, you have a backup, don't you?

rm -R /home/*

Unmount the partition /dev/hda4:

umount /mnt

Mount the partition to /home:

mount /dev/hda4 /home

Use an editor (vi, pico, etc.) to add the following entry to /etc/fstab so that the new partition is automatically mounted the next time you start your system:

/dev/hda4   /home   ext2   defaults   1	  2

Done.

In the above example a partition is downsized. By simply entering the respective start/end values, the command resize can also be used for upsizing partitions.

Concluding Remarks

As you can well imagine, GNU Parted has a lot of features and characteristics which are not covered in this minimalist howto. This includes subjects such as the peculiarities of various file systems, boot loaders (important if you want to edit the partition containing the boot loader, e.g. /dev/hda1), and different operating systems.

For more information, read the entire documentation provided at http://www.gnu.org/software/parted/USER. Provided GNU Parted is installed on your machine, you can also browse the documentation under /usr/share/doc/packages/parted.

Further Information

* Reseller
* Reviews
* Support Database
* Hardware Database
* Education Program

Quick Links

* Security
* Support Portal
* Mailing Lists
* Feedback
* SUSE LINUX eNewsletter

Subscribe now!

Get the Live DVD and Run Linux in Seconds!

SUSE LINUX 9.1 Personal Live CD

Want a hassle-free way to try Linux? Download SUSE LINUX Professional 9.2 Live DVD. It runs completely from your DVD drive. No need to install anything.

 This server is powered by NPS.
Linux is a registered trademark of Linus Torvalds.
Last changed: 18.09.2003 14:54 MET DST by webmaster@suse.de