Monday, November 5, 2012

Check Linux partitions and free space using terminal

To check list of partitions in partition table:

# fdisk -lu
Disk /dev/sda: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders, total 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63      208844      104391   83  Linux
/dev/sda2          208845    10474379     5132767+  8e  Linux LVM

To check free space and usage details:

# df -h
Filesystem            Size  Used Avail Use% Mounted on
                      3.8G  884M  2.7G  25% /
/dev/sda1              99M   13M   82M  13% /boot
tmpfs                 252M     0  252M   0% /dev/shm

Sunday, November 4, 2012

How to remove old kernels from Ubuntu 12.04?

You might have upgraded from a previous Ubuntu release or may be your kernal is new and old ones still residing in your system. Some times we need to free space. Do the following to remove old kernels:

Open terminal and check your current kernel in use:
$ uname -r
NOTE: You must not remove this one.

To list all installed kernels on your system:
$ dpkg –list | grep linux-image

Identify all kernels that are lower than your current kernel and you want to remove. Now issue the following command to remove:
$ sudo apt-get purge linux-image-x.x.x-xx-generic-pae
NOTE: Replace all 'x' acording to your kernel version which you want to remove.

Finally, run grub2:
$ sudo update-grub2

Now reboot your system and you are all done.