Saturday, February 5, 2011

Resizing/Increasing Root space at Ubuntu

I have been using Ubuntu for past couple of months and my experience has been great. Till now I have not done much of the experiment with it but I have encountered few problems and resolved few as well.

As I am a Novice in Linux I understand the severity of the problem faced by us. They might seem simple to people who are already in business for years but for people like us those issues are pain in A**.

Today I am gonna discuss one problem which is faced by people who start Linux as experiment and later start loving it.

Problem
My current laptop was equipped with Windows Vista. I wanted to experiment with some flavor of Linux but I was not sure of removing Windows, so windows survived primarily as a backup plan. At the time of installation my HDD dint have much space, But as I was experimenting so I did not think of it as an Issue. I installed Ubuntu on my system and as per the availability of the resources It assigned 6.1 GB of disk space to it. With the time my data increased in Home directory and suddenly I found myself without even I MB space to do my day to day activities. Horrible, is not it? But I solved issue by removing few files here and there and got it working for next couple more days. What next? Hmmm, Now I have to solve this problem.

So problem is to either add size in my Ubuntu partition or reinstall it again with little extra space?

Solution
Oops, second option is scary. I asked one kid(I am still a kid :) :) ) and he said, Uncle gone mad, resize it :). So did I. First of all I removed some movies from my collection.

As I was still having windows, so I created raw disk using windows.
- RAW Disk is something which is not even recognized to windows.

Create EXT4 partition using Unix GUI utility.
Now resizing Ubuntu there were two option. Increase my bootable partition or assign new partition to one folder. Increasing bootable partition need live CD and I wanted some fast recovery. So I used another option.

Steps to be followed:

1. Create a EXT4 partition and LABEL it, e.g. SAMPLE.

2. Go to Root using terminal.
cd /

3. Create a New Directory, e.g home_new
mkdir home_new

4. Modify fstab( /etc/fstab) such that new partition will point to /home_new. Add following entry.
sudo vi /etc/fstab
Pass the root password and add the entry in the file.
LABEL=SAMPLE  /home_new ext4 defaults,nodev,nosuid,relatime 0 2
If you want to read more about fstab entry, then click here .

5. Move whole data from /home to /home_new. It is better to cross verify if the data has been moved or not. If the data is copied to /home_new and still exist in /home then remove this data.
sudo mv /home/* /home_new



5. After coping and removing data exist in /home, Modify fstab( /etc/fstab) such that new partition will point to /home. Modify previous entry to look like this
sudo vi /etc/fstab
Pass the root password and add the entry in the file.
LABEL=SAMPLE  /home ext4 defaults,nodev,nosuid,relatime 0 2



Now you can restart your computer. Now your home is pointing to a different disk and you have more space in your system.

In between I have asked to recheck if data is removed or not. I have specified that because if you are not deleting the data in old home directory then after making all changes this data will not free required space and you will not be able to delete it later. As I did not delete the data, so currently I am not able to use 1.5GB of my hard disk.

I have to figure out a way to retrieve or delete this data and currently it is an open problem for me. Hope this article will help you to add size to your ubuntu version without making much efforts.