Difference between revisions of "Resizing you Virtual Disk"
(→Booting using another Linux) |
(→Booting using another Linux) |
||
Line 47: | Line 47: | ||
</source> | </source> | ||
and resize by extending the main partition to the new size. | and resize by extending the main partition to the new size. | ||
+ | |||
+ | [[File:Settings2.png|500px]] | ||
+ | |||
+ | '''Remember to commit by clicking on the green check mark button''' | ||
Shut down the Knoppix. | Shut down the Knoppix. |
Revision as of 17:14, 20 January 2017
This is a short description of how you can resize your harddisk to the virtual PC.
Contents
Make a Clone
First shut down the guest operating system - the Centos.
The free and open version of VirtualBox does not - yet - have the capability to resize the .vmdk disk's. Therefore you have to convert the present harddisk to another format, vdi.
$ vboxmanage clonehd "Centos-disk2.vmdk" "clone.vdi" --format vdi
here put in your diskname if different from above.
Resizing
Now, after a short waiting time, we are ready to perform the actual resizing.
$ vboxmanage modifyhd "clone.vdi" --resize 80000
Here the disk is resized to 80 GB ~ 80000MB
Mount the Resized Disk
One could think that we now need to clone the disk back to the vmdk-format. But that is not necessary. Just delete the present disk in the VirtualBox Manager - click Settings for the particular machine and move down to Storage. Delete the attached disk, e.g. Centos.vmdk and insert the "clone.vdi" instead.
Before deleting the disk
After the newly cloned disk has been attached
Resizing inside Linux
The next step is to resize the partition within the virtual machine. This can only be done, when the Linux that is using the disk is not running. How can one change something when it is not running? Think of you virtual PC as an ordinary PC. You know that you can use a CD or DVD or even a USB memory stick to boot your ordinary PC in order to manipulate the hard disk. The same goes for your virtual PC. Therefore you have to boot the virtual machine using a LiveDVD. I downloaded the "Swiss knife" from Knoppix a Live DVD - pick one of the newest down the page. You need a new image in order to resize the LogicalVolume - LVM, that the Centos resides in.
In the VirtualBox manager attach the Live DVD to the Optical disk controller using the CD/DVD button to the right of the Storage settings.
Booting using another Linux
Boot the system, but use the Live DVD as boot medium - strat the virtual machine and wait a few seconds. It will boot automagically.
When Knoppix is up running start a console and in the console type
$ sudo gparted
and resize by extending the main partition to the new size.
Remember to commit by clicking on the green check mark button
Shut down the Knoppix.
Be sure to unmount the DVD after shut down to prevent booting from it once again.
If needed, take a look at this video if you need to move your swap partition, but it should not be necessary in the standard "Software-in-a-Box" solution.
Resizing the Logical Volume File System
Next you'll boot the Centos again and star a shell. Issue these two commands in order to resize the logical volume file system.
]$ sudo lvextend -L+80G /dev/mapper/cl_jdoe-root ]$ sudo xfs_growfs /dev/mapper/cl_jdoe-root
The -L+80G can be the size you have chosen to extend the disk.
Finally check that your disk and logical volume has been resize correctly issue
]$ df -h
Look for the size of the root partition
$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/cl_jdoe-root 13G 11G 2.3G 83% / ......
here is the size 13G, but shall be approximately the size you have chosen above.
Check that everything work as it did prior to the resizing.
Clean up
The very last thing to do is to delete the original vmdk file, that housed the original disk for the virtual machine and, of course, if you don't need the Swiss knife any more delte the Knoppix iso.