Saturday, 1 December 2012

Increase size of root partition in Linux

Your root partition is out of juice and you cant afford to redo the installation procedure? Well today i am going to teach you how to solve this problem.
There are two ways of solving this problem.

1. Extend partition using gparted

Install gparted.
In ubuntu:
$ sudo apt-get install gparted
In fedora
# yum install gparted
Then resize your root partition to get more space for it using gparted.

Note: This is risky and will not work on certain kind of partitions. If the above didn't work use second method.

2. Using soft (symbolic) links

Soft links are equivalent shortcuts in windows but these are more powerful. Here we can move files to other partition and create soft links of the files to their original places. However make sure that the other partition is always mounted. See this if you want to know how to auto mount devices.

There are certain files which are not very crucial but are necessary for some application to perform
for example ~/.cache folder has all the cache of applications including browsers..etc. Music,Video, Downloads, Documents are other such folders.
  1. Move all the folders to another partition, say it is /media/Ambusher/.
  2. Open terminal and create soft links
    $ ln -s /media/Ambusher/cache ~/.cache
    $ ln -s /media/Ambusher/music/* ~/Music/
    $ ln -s /media/Ambusher/videos/* ~/Video/
    $ ln -s /media/Ambusher/documents/* ~/Documents
    $ ln -s /media/Ambusher/downloads/* ~/Downloads
  3. Similarly create soft links for other folders also.
Now you would have freed up a lot of space for your root partition.

Sometime you may have to delete all the soft links in a folder. To remove all soft links in a folder do this:
find FOLDER -maxdepth 1 -type l -exec rm -f {} \;
For example:
find ~/Pictures -maxdepth 1 -type l -exec rm -f {} \;
Note: Soft links won't work if the disk partition type is FAT 16/32 or WIN 16/32 but works perfectly fine on NTFS
Have a nice day!!