Sometimes you may need to expand or shrink Linux disk partitions, without any loss of data. There are many third-party tools to manage your Linux disk partitions. For example, you can easily do this using Gparted tool. In this article, we will look at how to resize Linux partition without data loss.
How to Resize Linux Partition without Data Loss
Here are the steps to resize Linux partition without Data loss.
1. Install GParted
Open terminal and run the following command to install GParted utility.
$ sudo apt-get install gparted
2. Resize Linux Disk Partition
Start GParted. You can do so from the Ubuntu dashboard
You will see a window that lists all the partitions on your system.
Please note, you cannot resize a partition that is in use. So if your partition is in use, then open file manager, right click on this partition, and select Unmount option from dropdown menu to unmount it. If it is a swap partition, then select Swap off option instead.
Right-click the one you want to resize and click ‘Resize/Move’ from dropdown menu.
You will see the following window, that allows you to resize partition either by dragging the bar handles, or entering exact partition size numbers. Click Resize/Move to save changes.
Please note, your changes will be enqueued in GParted and not applied immediately.
3. Apply changes
Click the green tick mark to apply changes in Gparted. This will take a while. Don’t switch off your system or cancel the changes midway when the operations are being applied. In case of any errors/conflicts, it will show you an error message.
That’s it. In this article, we have learnt how to resize Linux partitions without loss of data.
The key thing is to remember to unmount partition before resizing it.
If your Linux system does not have GUI/Desktop, then you can use the CLI version of Gparted called parted instead but it is slightly complicated to use, so we recommend using GParted instead.
Also read:
How to List Directories & Subdirectories in Linux
How to Prevent Cross-Site Scripting in Apache/PHP
Shell Scripting to Replace Text in File
NGINX Block File Extension
How to Deploy React App in NGINX