Difference between revisions of "Resizing you Virtual Disk"

From Klaus' wiki
Jump to: navigation, search
(Clean up)
Line 33: Line 33:
 
[[File:VirtualBox3.png|500px]]
 
[[File:VirtualBox3.png|500px]]
  
====Booting using another Linux====
+
===Booting using another Linux===
 
* Boot the system, but use the Live DVD as boot medium or  
 
* Boot the system, but use the Live DVD as boot medium or  
 
* if you have choosen the lighter CD version boot that and then you have to select the '''Graphical Programs''' near the bottom of the text mode menu this CD boots with. Select '''Startlxde''' and after a few seconds the graphical environment is up running.
 
* if you have choosen the lighter CD version boot that and then you have to select the '''Graphical Programs''' near the bottom of the text mode menu this CD boots with. Select '''Startlxde''' and after a few seconds the graphical environment is up running.
Line 49: Line 49:
 
Eventually take a look at this [https://www.youtube.com/watch?v=b5mdnzQ0nuw video] if you need to move your swap partition.
 
Eventually take a look at this [https://www.youtube.com/watch?v=b5mdnzQ0nuw video] if you need to move your swap partition.
  
====Resizing the Logical File System====
+
===Resizing the Logical File System===
  
 
Nex you'll boot the Centos again.
 
Nex you'll boot the Centos again.
Line 72: Line 72:
 
</source>
 
</source>
  
====Check====
+
===Check===
 
Boot the PC and see that everything works.
 
Boot the PC and see that everything works.
  
====Clean up====
+
===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.
 
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.

Revision as of 09:25, 15 January 2017

This is a short description of how you can resize your harddisk to the virtual PC.

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 "d03428v1-disk1.vmdk" "clone.vdi" --format vdi

here put in your diskname, eg. "Centos.vmdk"

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.

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 a Live DVD - pick one of the newest down the page.

If your Internet connection is slow choose or you local disk space is limited download this, which is a CD and considerably smaller than the DVD.

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.

VirtualBox3.png

Booting using another Linux

  • Boot the system, but use the Live DVD as boot medium or
  • if you have choosen the lighter CD version boot that and then you have to select the Graphical Programs near the bottom of the text mode menu this CD boots with. Select Startlxde and after a few seconds the graphical environment is up running.

When Knoppix is up running start a console and in the console type

$ sudo gparted

and resize the main partition to the new size.

Shut down the Knoppix.

Be sure to unmount the CD or DVD after shut down to prevent booting from it once again.

Eventually take a look at this video if you need to move your swap partition.

Resizing the Logical File System

Nex you'll boot the Centos again.

]$ 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% /
......

Check

Boot the PC and see that everything works.

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.