Ubuntu 12.04 LTS Precise Pangolin: Using GParted to Partition a Hard Disk
It may not be something you do very often but most Linux users would agree that being able to control the partitions on your storage devices is probably one of the most important aspects of mastering your operating system. So whether you want more space for your media files or you would simply like to reformat a pen drive in this article I will be introducing you to the power and simplicity of GParted in order to get the most out of Ubuntu 12.04 LTS Precise Pangolin.
So let’s begin …
GParted is one of the most popular partitioning tools available for Linux today. It is a very powerful and easy to use graphical tool and its strength lies in the fact that it not only avoids over-complication but it can be used by both new-comers and long standing professionals to full effect. It is common to all Linux distributions and you can even use it as a Live CD.
If it is not already installed, simply open Terminal and type:
sudo apt-get install gparted
The tool will require ‘root’ permissions to operate but from this point and onwards you can treat it like any other piece of software and launch GParted from the Dash.
The main interface will look something like this:
Typically the first disk GParted will read is your primary hard-disk, and from the example above you will notice that the primary hard disk shown:
- Has a total of usable storage space of up to 298.09GB (or 320GB as per the hard disk specification).
- Uses a 4.00GB Swap Partition
- Uses a 294.09GB ‘root’ partition formatted as EXT4. Identified as /dev/sda/ the root partition is flagged/marked as ‘bootable’ and is only using a mere 8.12GB of space.
Of course, it should be expected that your hard disk(s) will vary from the example and yes you can use GParted to modify existing partitions. However, as I am only using this to illustrate how to read the GParted interface I am now going to show you how to partition a new 500GB SATA-based internal drive.
Step 1. Choose the correct device
GParted will work with all types of storage devices but before doing anything it is vital that you select the correct device.
Remember, simply deleting partitions indiscriminately will cause the loss of important data.
In the top right-hand corner of the GParted interface use the drop-down list to select the relevant storage device:
Having already installed my new 500GB internal SATA-based hard disk (as you can see from the example above) it is identified as /dev/sdb and by changing to this device, the GParted interface may now report:
In GParted the typical notation for any hard disk is as follows:
- IDE-based drives are generally marked hdX, where X is one of the four letters a-d and hda is the primary master, hdb is the primary slave, hdc is the secondary master, and hdd is the secondary slave etc …
- SATA/SCSI based drives are marked by sdX. Where X is a letter of the alphabet and sda is typically recognised to be the primary system disk.
And having ensured we have selected the correct hard disk, we must now consider the task of initialising the device (also known as creating a new partition table).
Step 2. Initialise the device
The ‘partition table’ is located at the first sector of each hard disk. It’s purpose is to memorise information about the size and location of each partition on any hard disk and typically it is limited to a maximum of four entries (or four partitions) although many more can be created in the extended partition.
A recently purchased hard disks will not contain a partition table, whereas an older hard disks may contain an unwanted partition table that was used on a different system and is no longer required, so which ever way you look at it — we need to create a new partition table and by doing this we will be destroying any existing data and ‘wiping the entire drive clean’.
So to mix things-up a little, let’s say my internal drive was taken from an old Windows-based machine and for this reason it will contain existing NTFS partitions that are no longer useful to me.
To re-initialise the disk and wipe it clean, you would choose DEVICE > CREATE PARTITION TABLE like so:
You will be asked to confirm this action:
And when ready, choose APPLY to proceed.
GParted will now complete the disk initialisation process and when finished it will report on the amount of unallocated (or unformatted) space at your disposal:
Step 3. Format your device
As we have already mentioned, your hard disk can maintain a number of different partitions, but for the purpose of this article I will only need one — a single partition to hold my data.
To do this, simply right-click on the ‘unallocated space’ and choose NEW like so:
In the resulting ‘Create new Partition‘ dialogue box you will now be invited to define the relevant settings for the new partition:
In the example shown above GParted is showing that a maximum size of 476,939 MB (nearly 477GB) is available for use and as I am intending to make a single partition for data only I will want to make the following changes:
- Create as: Primary Partition.
- File system: EXT4.
- Label: (choose an appropriate name – i.e. my_new_drive, my_data, data-disk etc…)
The other areas can be left ‘as is’ unless you intend to create more than one partition. However you may be asking why I have changed the ‘Align To‘ from the default MiB value to Cylinder.
Without getting too technical using the Cylinder option is ‘old school’ and remains a great option if [a] your hard disks are what some would say ‘old’ or [b] you intend to keep using fdisk ‘as is’ without switching-off ‘DOS-compatiblity mode’. A full explanation for my reasoning does go beyond the scope of this article, but as a simple recommendation or ‘rule of thumb’: If you are using an SSD drive then you will want to remove any gaps between your partitions and squeeze every inch of space form your disk, so choose ‘Align To MiB‘, but if you are like me and still use a typical SATA disk (or older IDE-based disk), then to avoid confusion with fdisk at a later date – choose ‘Align To Cylinder‘.
When finished, by choosing Add you will be returned to the main interface:
GParted will not perform any actions until authorised. Therefore in order to proceed you should click the green ‘Tick’ icon to ‘Apply All Operations’.
Having done this GParted will now ask you to confirm the action like so:
Click Apply to proceed and GParted will now perform the operation to format your device:
When GParted has finished, simply choose CLOSE and the tool will report on the new partition layout:
Unlike a partition table, individual partitions are marked by a number after any three letter combination. For example, in this article I have just created ‘sdb1’ which is the first partition on the second SATA/SCSI drive. Where ‘SD’ indicates the disk is a SATA/SCSI device, the letter ‘B’ implies that it is the second drive of the system and ‘1’ confirms that it is the first partition.
And that’s it. My new 500GB hard disk is ready for action, but before I go, you should be aware that you can apply the same technique to any type of storage device (pen drives, external hard drives etc …) and for those of you who prefer to use graphical tools, I am sure GParted will quickly become an invaluable friend :-)
So have fun and until next time I hope that you continue to enjoy using Ubuntu 12.04 LTS Precise Pangolin.
If you enjoyed reading this post, you’ll love Learnable; the place to learn fresh skills and techniques from the masters. Members get instant access to all of SitePoint’s ebooks and interactive online courses, like Ubuntu Linux.