LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Virtualization and Cloud (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/)
-   -   Resizing partition in VHD file - root partition first, swap second (*Advanced*) (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/resizing-partition-in-vhd-file-root-partition-first-swap-second-%2Aadvanced%2A-945513/)

dpesios 05-17-2012 08:03 AM

Resizing partition in VHD file - root partition first, swap second (*Advanced*)
 
Hello,

Well, let me state the situation hoping that some of you, more experienced than me, will help me.

I have a virtual machine (the so-called guest) that in fact is a GNU/Linux and doesn't have X server. The host machine is a Windows Server 2003 that runs Microsoft Virtual PC 2007.

Everything was going smoothly until one day when we decided (in my lab) to upload a large file on the guest machine (using ssh, anyway ...). The file didn't fit because the VHD file had reached its space limit, so the only solution was to resize it.

To carry this through, by doing a little search, I decided to read the instructions here. Okay, these instructions are for Windows guest machines but we can still use the link to VHD resizer that will, as its name suggests, resize the .vhd file.

Now what ? The swap partition (/dev/hda6) is second and and the root one (/dev/hda5) is first . Can I somehow toggle them without loosing data ? I also want to take advantage of the free unpartitioned space VHD Resize tool will create. And then how can I extend the partition in Linux ?

Thank you in advance.
(If there are disambiguations please let me know.)

zhjim 05-18-2012 01:27 AM

All right, so you already increased the size of the harddisk inside the hypervisor so the guest should have a bigger harddisk now. So the next step would be to resize first the underlying partition and second the filesystem on the partition. If you used lvm (logical volume manager) inside the guest then it's easy if not we have some more work to do.

For the lvm route check out the man page of lvresize or just get the overall picture of lvm. Heres a nice link with all nedded information http://www.markus-gattol.name/ws/lvm.html.

For the non lvm route we need to boot the machine from a live disk to make sure no data is lost. BACKUP before is highly recommended anyways.
So boot up the live disk.
Kill the swap partition (You have free space at the end of the harddisk and the swap partition is in our way). Use fdisk or gparted for the partition handling
Resize the root partition and make it as big as you need.
Create a swap partition.
Resize the filesystem on the root partition with resize2fs or the appropiate tool for the used filesystem. Check out the man page to now about the needed options.
make the swap file system on the new swap partition with mkswap.
Reboot and enjoy.

dpesios 05-18-2012 05:50 AM

By mistake I re-posted the thread. I apologize.
Please provide your answers here.


Anyway, I see what I have to do and will try it as soon as I get the permission to stop the services run on the machine (by my boss).

Regarding lvresize, it is not included in my system. So that means my system was not set to use LVM, right ?

However you both seem to agree on what has to be done.

Thanks again.


All times are GMT -5. The time now is 10:59 PM.