-1

I´ve a Vm with Ubuntu 12.04 installed. Thus the hard disk is running out of disk space my plan was to increase the disk space and after that expand the existing root logical volume with a newly created partition. After reading lots of tutorials I´m stuck how to continue.

This is what df command gives me right now:

Filesystem                        1K-blocks    Used Available Use% Mounted on
/dev/mapper/sun--vg-root   3812876 3095764    520096  86% /
udev                                4078956       4   4078952   1% /dev
tmpfs                                817760   39616    778144   5% /run
none                                   5120       0      5120   0% /run/lock
none                                4088788       0   4088788   0% /run/shm
/dev/sda1                            233191   82814    137936  38% /boot

and this what sudo fdisk /dev/sda tells me about partitions:

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758     8386559     3942401    5  Extended
/dev/sda3         8386560    25165823     8389632   8e  Linux LVM
/dev/sda4        25165824    83886079    29360128   83  Linux
/dev/sda5          501760     8386559     3942400   8e  Linux LVM

What I did: After sudo fdisk /dev/sda I´ve created a new primary partition by choosing n and p in fdisk. After that I´ve chosen first sector after sda5. than changed the type of the new partition to Linux LVM. I´ve repeated this step twice because I was unsure if it worked. It seems not. Otherwise the Usage should not be 86%. Can one help me out?

1

These steps can be done while booted, to extend your volume group. I am assuming sda5 is the new LVM partition, not sda3.

pvcreate /dev/sda5
vgextend sun-vg /dev/sda5

Then you should fsck the file system. This can't be done online. You would need to boot a CD or something else. This is optional, but should be done to prevent damage during resize.

fsck /dev/sun-vg/root

Then you should resize the file system. This can possibly be done while mounted in newer kernels. It will probably complain if you didn't run fsck yet.

lvextend -r -l 100%FREE sun-vg/root

If that won't resize it online, then do it without -r, and then use resize2fs to resize the filesystem afterwards.

resize2fs /dev/sun-vg/root

Practice these steps in a virtual machine or something to prevent errors. Also make a backup of your disk before you begin.

  • thanks a million this worked perfectly, but I had to use sda4 ;) – t Book Jul 18 '14 at 9:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.