Disk Partitioning in Ubuntu using GParted
Disk Partitioning is a process of separating disks into one (or) more logical areas so that user and system work on them independently. When a partition is created, the disk will store the information about the location and size of partitions in the partition table. With the partition table, each partition can appear on the operating system as a logical disk, and users can read and write data on those disks. Learn more about Disk Partitioning in Linux
What is GParted
Disk Partitioning in Linux is done using command line programs like fdisk. GParted(GNOME Partition Editor) is a Graphical user program based on GTK which allows Disk Partitioning with just a click of the buttons. GParted is the official GNOME partition-editing application. GParted is used for creating, deleting, resizing, moving, checking, and copying disk partitions and manipulating file systems such as exfat, fat32/64, ext2/3/4, Linux-swap and more.
You can install GParted in Ubuntu with a single command using APT
sudo apt install gparted
You can verify whether GParted is successfully installed or not using the below command which gives an output similar to below image
sudo apt policy gparted
Note: It’s recommended to backup your data in the partition before using GParted
To open GParted , go to Activities in Ubuntu and click on the gparted icon. It will prompt for password as GParted requires sudo privileges.
The above image shows the GParted menu, like many programs, it has a file menu(GParted), edit menu, view menu, device & partition menu, and help menu. The icons below the menu bar represent the common operations performed by gparted
- new – create a new partition
- delete – delete an existing partition
- resize/move – to resize a partition, either shrink(or)increase the size
- copy/paste – used to copy/paste the text(or) information
- undo – undo the previous action
- apply – to perform the operation chosen from above, you have to click the apply icon to commit any selected operation in gparted
You can see all the partitions on my hard disk. It has a total of 7 partitions from /dev/sda[1-4] being used for Microsoft Windows and /dev/sda[5-7] being used by my Linux Distro. The lock icon between partition and name shows that these partitions can’t be modified while running. The partitions can be modified by using a Live CD (or) using another OS which doesn’t use these partitions.
GParted clearly shows us
- Partition – the logical partition id in the partition table
- Name – name of the partition
- File System – type of the file system used by the partition which are like ntfs, fat32, ext4, linux-swap and more.
- Mount point – the point where the partition is being mounted by the OS which is similar to root(/), home(/home)
- Size(Used/Unused) – the size of the partition and used and free space in the partition
- Flags – It tells what the partition is being used for, which are like hidden partition, swap partition, windows partition
Resizing a partition to create a new Partition
Step 1: We will shrink /dev/sda4 by 10GB to create a new ext4 partition. Go on to /dev/sda4 and right-click on it and it opens an option menu like below.
The menu has options for
- create/delete partitions
- resize and move partitions
- format partitions
- name partitions and add flags
- Changing UUID and more
Partition properties: To show more information about a partition click on the information option in the menu shown in the above picture
Step 2: Click on Resize/Move. It will open new windows to select the size to resize partitions. As we have taken the new partition size as 10GB, add 10000(GB converted into MiB) Free Space following option. Now click on Resize/Move
Step 3: Now click “apply icon” in GParted menu( it will in the top with icons representing actions), It will ask for confirmation
After clicking on apply, the partition will be resized.
Step 4: If the resize is successful you will see a success message like below.
You will see an unallocated space in the GPartered list
Creating a New Partition
Click on the unallocated space and select new in GParted menu where we have selected in the apply icon. Select the options like size, name as file system and then click add
Now click on the apply icon like before to apply the changes, and accept the warning
If the operations are successful, you will see the message like before.
We have successfully created a new /dev/sda8 partition using GParted
Formatting a new partition
You can choose the format of the file system when creating a new partition, if you choose to format an existing partition, select the partition you want to format and right-click on it to open the partition menu. Then go to the format option and click on the type of filesystem you want. After selecting, apply the changes just by clicking on the apply icon in the top menu.
Deleting a Partition
Deleting a partition is simple. Select the partition you want to delete and click the delete icon on the top menu and then click apply icon. Deleting a partition will erase all the data in that partition, so be careful while using it.