Category Archives: VMware

Elegantly resizing a Linux LVM volume in a virtual machine…

I’ve seen many articles on how to resize a LVM volume after increasing a virtual disk capacity. Most write-ups call for adding partitions and simply adding them to the volume group. While it is simple, it’s not future proof since the number of partitions is limited.

Here’s the way I do it. I hope you enjoy!

  1. Resize your virtual disk (this depends on your hypervisor, I use VMware so YMMV)
  2. Shut down the VM, find an ISO that has GParted. I use PartedMagic but the GParted Live ISO works too.
  3. Boot from the ISO, start GParted.
    1 GParted
  4. Select the LVM physical volume, right click on it then click on deactivate.
    2 Deactivate
  5. Then right click on Resize/Move
    3 Resize
  6. Resize the partition (here, sda2, yours might be different)
    4 Resize
  7. Apply the changes by clicking the green checkmark in the toolbar at the top. Click Apply in the popup.
    5 Apply
  8. Don’t forget to reactivate the LVM physical volume.
    6 Activate
  9. In the terminal, enter the following commands (volume group names may vary) do an ls /dev/ if you’re not sure.
    #extend the volume
    lvm lvextend /dev/lv_hostname/lv_root /dev/sda2
    #check the filesystem for inconsistencies
    e2fsck -f /dev/lv_hostname/lv_root
    #resize the filesystem
    resize2fs /dev/lv_hostname/lv_root
  10. Shut down the VM, unmount the iso.
  11. You’re done.

Namaste.

Resizing an OSX partition on a VM hosted on ESXi.

Update 11/2/2014: We are successfully virtualizing Mavericks (10.9) and it is possible to resize disks online without having to go through the following guide. It still applies to Mountain Lion (10.8) and earlier versions.

One of the great things in vSphere 5.1 is that the Mac Pro is a fully supported server for ESXi. That means you can virtualize OSX on supported and recent hardware.

While the templating and integration is not as great as with Windows and Linux, you can deploy VMs in a reasonably short amount of time. Just make sure you don’t check the “Edit virtual hardware (Experimental)” box as it may blow your template up.

If you attempt to grow the disk, you will get a “Partition failed” error message in OSX “MediaKit reports partition (map) too small.”. No matter how many times you try it won’t work…

At this point you have 4 options:

Since I didn’t have time to place a purchase request and didn’t have much time, I used a PartedMagic iso I already had in one of my Datastores. Only to notice that the iso wouldn’t boot. This is due to the fact that OSX VMs are running in EFI boot mode only.

Fear not, there is a way to get it to boot:

  1. Shut your VM down.
  2. Right click > Edit Settings.
  3. Increase the disk space to the capacity you want.
  4. Go to the options tab, change the “Guest Operating System” to Windows and select any flavor of Windows in the drop down menu.
    From this:
    changeguest1
    To this:
    changeguest2
  5. Then, still in the Options screen, under “Advanced > Boot Options”, change the boot firmware from EFI to BIOS.
    efibios
  6. Your VM should now be able to boot from the ISO.
  7. In PartedMagic, start Partition Editor, you should see an error message similar to this:
    fixgpt
    Click Fix. If another dialog prompts you to fix something else, click Fix again.
  8. Add a FAT32 partition in the empty space.
    newpart
  9. Click Apply.
  10. Shut down and revert the Guest OS and Boot Firmware options.
  11. Boot into OSX, delete the FAT32 partition and resize your main partition.
  12. You’re done.

Namaste.