Tuesday, May 29, 2007

Partitioning hard disk

Sometimes, you want to have a new partition, but your system is already configured and you do not have anymore space.

To partition your hard disk again, you will need a live cd and boot on it.

You can use two methods

  • Use gparted: gparted is a gnome tool that allow to resize partitions. I have tried this version on the Feisty Fawn live cd but there are some bugs: partition are automatically mounted and it is impossible to partition a disk while its partitions are mounted. To umount them, you need to start the terminal and run the command:

    df

    You will see that a partition is mounted like /mnt/disk or /mnt/disk-?, you will need to unmount it: to do this:

    umount /mnt/disk

    After that you will be able to modify your partitions

  • Use command-line: To do this, you have some useful commands:

    • resize2fs can resize an ext2 filesystem, if you do not set the size, it will fill the partition to the available space. If you set a size it will reallocate the filesystem to the size specified.

    • fdisk creates, removes or resize partitions.


    To change your partitions, you will need to

    1. resize your filesystem with resize2fs

    2. resize your partition with fdisk and create new partitions.

    3. resize your original filesystem to fill the available partition with resize2fs

How to partition?



A disk contains 4 partitions that can be of type primary or of type extended.

  • A primary partition is a partition that contains a filesystem
  • An extended partition is a partition that contains other partitions, that allows to have more than 4 partitions
To create more than 4 partitions, you will need to
  1. create at least one extended partition
  2. define its size
  3. create logical partitions that will be in this new extended partition.