First of all, let me share my experience for why It was needed to Extend Ubuntu Partition for me?
One day I decided to start using Ubuntu for the purpose of development so I installed Ubuntu 14.04 LTS on my system. While installing it, I created two partitions. First, for Ubuntu 14.04 LTS OS and Second to keep rest of the stuff. I mounted my first partition on / and another partition on /media.
To share movies with my friends I created a folder in the second partition and shared it on the network but no one was able to access it. I again tried to share it by installing Samba but also it did not work. If I share a folder from First/Root Partition (Where I installed Ubuntu) then all can access but not the folder from the second partition. So finally I decided to remove my second partition and extend First/Root Partition.
Extend Ubuntu Partition without Losing OS
Ubuntu partition can be extended without losing OS/data available in root partition but it is always recommended to keep important data at a safe place. Take a backup of your important data on your hard disk or somewhere else.
To extend partition install GParted Partition Editor from Ubuntu Software Center. You can also install GParted by executing below command in terminal.
sudo apt-get update
sudo apt-get install gparted
After successful installation open GParted which will show all the partition which was created while installing OS.
Here I have total two active partition sda1 (Root Partition with OS) and sda6 (Non-Primary). Here I want to delete partition sda6 and extend sda1 partition. Since sda2 is extended partition, we can not delete it directly. So first we have to delete Partition sda6 and sda5.
Partition sda6 (ext4) is already mounted on /media so first we have unmount it. Right click on sda6 and click on Unmount to unmount it. Now again right-click on it and click on delete. It will delete the partition sda6 and release the allocated space.
Partition sda5 (linux-swap) is the Linux-swap partition so first, we have to Swap Off it. Right click on sda5 and click on Swapoff to swap it off. Now again right-click on it and click on delete. It will delete the partition sda5 and release the allocated space. Now partition will look like below.
We deleted both sda6 and sda5 partition so now we can delete sda2 partition. Right click on sda2 and click on delete. It will delete the partition sda2 and release the allocated space.
After deleting partition sda2, we have one sda1 (ext4) partition and other unallocated space.
Right click on sda1 (ext4) partition and click on Resize/Move. It will show a dialog box with existing space allocation and available free space.
Write a new size for sda1 partition and keep 8500 MB (8.30GB) for Linux-swap.
Click on Resize and It will extend/resize sda1 partition and keep 8.30 GB as unallocated.
Now right click on unallocated space and click on New. It will open dialog box to create a new partition. Select file system as Linux-swap and click on add. It will add New Partition #1 (Linux-swap)
Click on “Apply All Operation”. GParted will warn a message for merging partition and after that, it will show a dialog box for Completed Operations. It will automatically allocate partition sda2 to the New Partition #1.
It is important to Swap On the partition sda2 because it’s Linux-swap partition. Right click on sda2 partition and click on swapon.
To check space is increased on or not, Go to Files > Computer. Right click anywhere and select Properties and check Total Capacity.
That’s how we can Extend Ubuntu Partition without losing OS or deleting Root Partition. Let me know if you need any help.
Enjoy Partition Extending 🙂