Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.


  Search this Thread
Old 05-17-2012, 08:03 AM   #1
LQ Newbie
Registered: May 2012
Location: Greece
Posts: 6

Rep: Reputation: Disabled
Lightbulb Resizing partition in VHD file - root partition first, swap second (*Advanced*)


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.)
Old 05-18-2012, 01:27 AM   #2
Senior Member
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
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

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.
Old 05-18-2012, 05:50 AM   #3
LQ Newbie
Registered: May 2012
Location: Greece
Posts: 6

Original Poster
Rep: Reputation: Disabled
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Resizing partition in VHD file - root partition first, swap second (*Advanced*) dpesios Linux - Virtualization and Cloud 3 05-17-2012 11:53 AM
Hard Drive Partition Management - Mandriva Double Partition with Swap File partition moshebagelfresser Linux - Hardware 2 05-23-2008 10:46 AM
Resizing the swap partition R N Ghosh Fedora 5 04-07-2006 02:39 AM
Resizing swap partition shujja Linux - Newbie 3 09-30-2005 02:20 AM
Resizing swap partition... PapaLewA Linux - Newbie 4 11-17-2001 01:59 PM > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 05:28 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration