How To Resize and Create LVM Partitions on Ubuntu?

Too frequent BSODs and ‘display driver not detected’ messages were turning me insane. I decided to install Ubuntu via WUBI, but although the pain slightly decreased, the true potential of linux was still shrouded by Windows. I had been contemplating on completely formatting and installing Linux, and about a week ago, I finally did it. With just 1 Gb of RAM and a P4 processor, I thought Xubuntu would be the way to go – and it seems that I was right.

Anyway, while installing Xubuntu I put a tick mark on “Use LVM with the new Xubuntu Installation” without even knowing what LVM was. It just seemed fancy, I guess. I have a knack for doing stupid things. Now what happened was, the entire Harddisk got formatted, like I wanted. But, there was only one partition for root (obviously).

GParted does not seem to work with resizing LVM partitions because you need to have some unallocated space on your volume group. Since all the space was assigned to the same volume group and there were no free space, I could not make use of it.

Being sort of a newbie to Linux, I was looking for an easy way out (i.e. a GUI based solution) and I did find one – an utility called KVPM. It seems to work better than GParted because it does not require any free space on the volume group in order to partition it (I haven’t used it though, use at your own risk.) But, with my Internet Speed it would have taken me almost 2 hours just to download it.

Resize an LVM partition and create a new one the dirty way (Just kidding; it’s easy.):

  • Boot with a live CD of the Linux distro. Click on Try Ubuntu (or whatever unity based distro you’ve got.)
  • Go to terminal (Ctrl+Alt+T) and change to root by entering the command : sudo su.
  • We need to find the volume group name of your partition and its corresponding device folder.lvdisplay
  • Enter lvdisplay. The results you see are your logical volumes. You should find at least two of them: /dev/vg-name/root and /dev/vg-name/swap_1. Disregard the swap partition, it’s the root that needs resizing.
  • As you can see on the picture, the device folder in my case is /dev/xubuntu-vg/root. Suppose, I wanted to resize my 230 Gb partition to just 80 Gb and create a new volume on the free space. Here’s what I would do. Note that I’m entering /vg-name/root because that is what I am going to resize. If you are going to resize some other volume, you have to enter its name instead of root. (Enter these commands one after another. Remember to put your actual volume group in place of ‘vg-name’.)

    Resize LVM
  • Now, to create new volume (example: ent) of size 60GB on the volume group vg-name. Enter:

That’s it. Enter lvdisplay and you will see details of the new volume ‘ent’.

Restart the computer and boot with your harddisk. Although you can see the new volume, you won’t be able to use it because the write access for it will only be available to the root user by default. So, now you need to change the read/write access of the drive. To do this, open up terminal.

Enter:

Keep note of the UUID of the lvm volume whose access you are going to change.

UUID of volume

Enter:

Replace username above with your own user-name. You should see the UUID of the earlier volume listed there.

In order to give yourself the necessary permission enter:

Changing volume permissions

You do not need to type the UUID of the volume manually, just enter up to the letters that distinguish the UUID from others and then hit tab key, and the UUID will automatically be selected.

You have successfully re-sized the lvm volume ‘root’ to 80 GB and created a new volume ‘ent’ of 60 GB with read/write access.

References:

Leave a Reply

Your email address will not be published. Required fields are marked *