How to Partition Linux System Using GParted?

GParted is a very useful tool for disk partitioning on Linux systems. So, how does GParted partition a Linux system? Today, in our computer tutorial, we will share the solution to this question. In this tutorial, we will learn how to use a Linux emergency boot disk to implement your changes. Once the disk is booted, you can run GParted just like you would from a regular system, using point-and-click operations to inform the software what actions you want to take.

GParted

Running an Emergency Disk

There are many Linux emergency disks, such as PartedMagic and SystemRescueCd (see references). You can also use your Linux installation media; many versions include a rescue mode that supports access to GParted or similar utilities. To illustrate the issue, I will introduce the use of PartedMagic 4.11; however, generally speaking, other tools work similarly. However, GParted needs to be booted in different ways.

Most emergency disks are available in x86 (32-bit) format, but these disks also work well on x86-64 (64-bit) computers, even if the system runs a 64-bit version of Linux. The file system data structure is not affected by the central processing unit (CPU) architecture. If you want to run on other machines besides standard personal computers (PCs), such as Macintosh, you need to check if your emergency disk is compatible with your hardware.

Generally, you must boot an emergency disk as you would boot a Linux installation disk. On some systems, you can insert the disk and then reboot the computer to perform this task. On others, you may need to press a function key to select the boot device or adjust a basic input/output system (BIOS) option to boot from the optical drive instead of the hard drive. The specific details on how to perform this action depend on the system, and you need to consult the manual pages for detailed information.

When you boot PartedMagic, a boot menu appears. Select Default settings (ns from RAM) to boot into the standard system. As the system boots, you will see a desktop with icons for common tools, including an icon to launch GParted, the Partition Editor. Double-click this icon to start resizing your partitions.

Informing GParted About Your Changes

To resize a partition, right-click on it and select Resize/Move from the dropdown menu. This will bring up a dialog box as shown in Figure 2. You can use the graphical slider or the text input field to adjust the size and position of the partition.

GParted Provides a Point-and-Click Interface for Resizing Partitions

The first image shows the resizing of /dev/sdb7. Move its starting point to the right to create space for the expansion of /dev/sdb5. To complete the resizing of the partition shown in the image, you also need to move the swap partition (/dev/sdb6) to the right before resizing /dev/sdb5. Alternatively, you could delete and recreate the swap partition; however, this may require modifying the UUID reference for swap in /etc/fstab. After the swap space is moved, you can expand /dev/sdb5.

Note the Align to field. This is a new feature in the recent versions of GParted that allows you to align partitions to cylinder boundaries, or align to mebibyte (MiB) boundaries, or neither. Older disks are usually partitioned to align with cylinder boundaries, but MiB alignment is typically used for disks partitioned for Windows Vista or later. Linux supports both alignment modes. If your system dual-boots Windows XP, cylinder alignment is essential. If your system dual-boots Windows Vista or later, or if your system uses new 4096-byte sectors, MiB alignment is essential.

If you want to free up space from a logical partition for a primary partition, you must explicitly adjust the extended partition surrounding the logical partition, and vice versa. You can do this just like you would with any other partition; however, you will find it easier to click on its list entry than to click on the entry in the chart of the above partition list.

GParted does not allow you to resize partitions that are in use. For example, there is a lock icon next to the entry of the partition. You can right-click on the partition and select Unmount to free it. Note that if any partition contained within the extended partition (including swap space) is in use, it is locked in this way.

Implementing Your Changes in GParted

After you have notified GParted of your changes, you must implement them by selecting Edit > Apply All Operations from the menu or clicking the Apply icon. This will bring up a progress dialog that outlines everything the program is doing. If you decide to undo the operation, you can use GParted’s undo feature or exit the program without applying your changes, and your disk will remain unchanged.

Partition resizing operations can take time to complete, ranging from a second to several hours, depending on the nature of the changes and the amount of data being moved. Under no circumstances should you interrupt a running operation! Doing so will corrupt the file system and result in data loss.

Modifying Disk References

If you want to add or delete partitions, you may need to modify your /etc/fstab file or your bootloader configuration, as mentioned above. To do this, you must mount your root (/) partition and edit that file. In Figure 1, the root partition is /dev/sdb1, and GParted can mount it at /media/sdb1, so you should edit /media/sdb1/etc/fstab. If the system uses a separate /boot partition, you may need to mount it separately and edit the bootloader configuration in the grub/menu.lst, grub/boot.conf, or grub/boot.cfg files.

Check these files and replace old partition numbers with the new ones. If you need to make some modifications, be sure to back up the old configuration before saving the new one.

Moving Forward

At this point, you may need to reboot your system. In PartedMagic, click the icon at the bottom left of the screen and select Logout, which provides you with options including rebooting. If you have not removed the emergency disk, be sure to do so. If all goes well, your computer should reboot into the regular Linux operating system, but you will find that your disk space has changed.

This article covers the basic partition resizing operations, and the second part of this series will cover more advanced operations and other options, including resizing Logical Volume Management (LVM), troubleshooting, and other operations to consider when resizing operations are insufficient.

Leave a Comment