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 an 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.) |
You've increased the size of /dev/hda, which means there's free space at the end of the device. Assuming you're using the MBR partitioning scheme, each partition can only occupy a contiguous area of the disk.
To extend /dev/hda5, you must: - Delete or move any partitions occupying the space immediately following /dev/hda5 - Modify the partition entry for /dev/hda5 As /dev/hda6 is a swap partition, it doesn't actually contain any useful data and can safely be deleted and recreated. The following procedure should work:
|
Okay,
machine_name:~# df -T -h --all Filesystem Type Size Used Avail Use% Mounted on /dev/hda5 ext3 16G 13G 2.2G 86% / proc proc 0 0 0 - /proc sysfs sysfs 0 0 0 - /sys devpts devpts 0 0 0 - /dev/pts tmpfs tmpfs 189M 0 189M 0% /dev/shm machine_name:~# fdisk -l Disk /dev/hda: 17.1 GB, 17179803648 bytes 255 heads, 63 sectors/track, 2088 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 1 2088 16771828+ 5 Extended /dev/hda5 * 1 2018 16209522 83 Linux /dev/hda6 2019 2088 562243+ 82 Linux swap / Solaris It seems that I do use the MBR partitioning scheme, right ? (where the one partition ends, the next begins ...) I have never used System Rescue CD (I have used UBCD many times however) and my "dummy" question is as follows. Should I boot the host machine with a bootable CD (System Rescue CD) and load the VHD file with a program included in the environment of the CD and then perform the steps you suggested ? As I said, the guest machine doesn't have a graphical interface environment (startx not included ...). Please clear these things up before I do anything irreversible (although i kept a back-up image). Thanks again. |
Quote:
Once you've resized the vhd file, you'll notice that the output from fdisk -l /dev/hda still shows the partitions as having the same size as before, but the second line should show a higher number of cylinders dor the disk itself. The procedure will have to be modified slightly to account for the extended partition (I should have seen that from the partition numbers): You'll actually have to resize two partitions; the extended partition (hda1) and the bootable root partition within it (hda5). Quote:
I would strongly recommend backing up the VM before doing any partition resizing, regardless of the tool and procedure being used. Does Virtual PC 2007 support taking snapshots of vhd files? If so, that is without a doubt the best way to make sure nothing gets broken no matter what you do to the partition table. The second best solution is to back up the partition table to a file. You can do that from within the VM with dd if=/dev/hda of=backup_of_partition_table.bin bs=512 count=1 (which means "read 1 512-byte block from the start of /dev/hda and write it to a file"). Copy the file to another system for safekeeping, and you're all set. System Rescue CD boots to the command line by default, although X may be started manually. The command line is all you need here:
|
All times are GMT -5. The time now is 05:44 PM. |