1

I am trying to expand my primary partition to use the extra disk space I have added in my VMWare virtual machine. I have been able to add the disk space, partition the extra space into an LVM partition but I am unable to add it to the Volume Group because I am unable to find its name using 'vgdisplay'.

nsadmin@mpmongodb02:~$ sudo vgdisplay
No volume groups found

Here is the output from 'fdisk'

nsadmin@mpmongodb02:~$ sudo fdisk -l
Disk /dev/sda: 343.6 GB, 343597383680 bytes
255 heads, 63 sectors/track, 41773 cylinders, total 671088640 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0002ef60

Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048   209717247   104857600   83  Linux
/dev/sda2       209717248   251658239    20970496    5  Extended
/dev/sda3       251658240   671088639   209715200   8e  Linux LVM
/dev/sda5       209719296   251658239    20969472   82  Linux swap / Solaris

/dev/sda3 is the newly added partition. I also tried running 'pvscan' but that also returned 'no volume groups found'. What do I do in this situation? How do I extend my primary partition to use /dev/sda3 ?

  • 1
    Have you verified that it was configured with LVM in the first place? – kasperd Mar 23 '15 at 7:08
  • Did you pvcreate and vgcreate the /dev/sda3 ? – Sree Mar 23 '15 at 7:33
2

I'm a fan of LVM but I don't think it is required in this case - if all you want to do is to expand your sda1 filesystem to use the rest of the space on this drive. Assuming you don't at the moment have any data on your sda3, a better strategy is:

  • with fdisk it is hard to work out the actual sizes of the partitions, use swapon -s to show the size of your swap partition in K - and write this down
  • Reboot the virtual system with SystemRescueCD (or GParted Live) as a virtual CD, booting from the CD - press ESC at the very start of the boot process to select the boot device
  • if using SystemRescueCD then type startx at the end of the boot process to load the GUI and find GParted under the menu at System (GParted Live however will boot straight into GUI)
  • use GParted to remove logical partitions sda5 and sda3, and then the extended partition sda2
  • expand sda1 to fill most of the disk, leaving enough space at the end for your new swap partition which should be at least as big as your previous swap partition
  • after expanding sda1, create a new 'extended partition' in the rest of the drive, and after this is created, reselect it, and inside it create a new logical partition, and mark this partition as type 'linux-swap'
  • after you've selected these operations you then have to apply them (green check button), which is when they actually happen - this may take some time (but probably not)
  • reboot into Ubuntu and your root partition (/dev/sda1) now contains most of the drive and your swap partition is still at /dev/sda5 (albeit in a different location on the disk)
  • this doesn't use LVM at all. Did you need it?
  • @Arjun since it is a vmware host, be sure to snapshot before doing all this, just in case ... – Archemar Mar 23 '15 at 7:41
1

First, you can't extend /dev/sda1 to include /dev/sda3 as their space allocations are NOT contiguous. You'd have to dump everything, re-layout the partitioning, and restore.

Second, /dev/sda1 does not to appear to be an LVM partition. Even if you wanted to add the apparently unclaimed physical volume created in /dev/sda3, this would not be possible. Again, in this case, dump everything in /dev/sda1, recreate /dev/sda1 as physical LVM volume, create the VG, create the LV, format the filesystem, restore stuff previously dumped. THEN add /dev/sda3 to the volume group, extend the PV, extend the LV, extend the filesystem.

Either way one could interpret this, you have a bit of work (and some planning) to do.

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.