I’m in the process of resizing a virtual machines hard drive to get some updates on it (hasn’t been updated in oh… several months), the issue is when I set many virtual machines up, I used to enter a limit for its dynamically expanding disk.
Not considering the consequences of doing so, I figure it’ll be able to be resized at a later date (or, dynamically expand), but unless you leave the maximum size at some huge amount (even if you dont have it), you do have to create another disk and migrate your data over to it.
Luckily, dd is our friend, and can migrate bit by bit, byte by byte from one virtual disk to another.
I tried to find a way to resize the volume so that the drive is able to be dynamically expanded using LVM (the installation was done a long time ago, I think with a CentOS server CD), the installation chose LVM by default, which I figure is OK – so long as I get a command line, what do I care.
Unfortuantely, that’s a bad move, LVM is great for managing volumes (like Windows’ Disk Manager), but when faced with something such as a resize task, you make the job exponentially more difficult by using LVM.
Simply, unless LVM has already told Linux about the disks, you can’t execute resize2fs to resize the drive to the new size!
So, the task that remains is to figure out how we can get that LVM drive in a rescue type mode, so we can execute resize2fs, and get moving on with the original task, updating the server and then installing more software.
Note to self: Never, never setup a VM with a hard drive limit. It’s a pain in the butt.
Anyway, I refer to it as “Lucky” volume management, because LVM has many features, including expanding over two partitions (yep), so whilst I was trying to find a way to simply resize the /dev/hda2 partition, it made it all so much easier by simply adding /dev/hda3 to the volume group, and then expanding the logical volume over the top of it as well (feels good having an imaginary 100GB drive).
If only the resize process was a little easier.
It should be fine, tomorrow, outside of the ‘uncounted period’ we should be able to source a CentOS ISO, boot that into rescue mode and the latest versions should have support for the LVM, otherwise, we are going to have to find another way.
Yes, I realise it might have been easier to simply move the larger folders onto a second virtual hard drive and worked with that, but that runs counter to my plans, eventually I’m going to migrate that server, so don’t want to be finding myself missing a second virtual disk or something else.
Enjoy!