I am running Ubuntu as a guest on an iMac with VirtualBox version 4.1.8.
What is the easiest way to resize the virtual drive?
Please provide as much detail as possible including the correct format for any commands.
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityI am running Ubuntu as a guest on an iMac with VirtualBox version 4.1.8.
What is the easiest way to resize the virtual drive?
Please provide as much detail as possible including the correct format for any commands.
This answer is directed at a Windows host, but if you use bash in place of the PowerShell and replace '\' with '/' it should work just fine.
Enlarge virtual drive
Powershell
(not as an administrator):cd C:\Program Files\Oracle\VirtualBox
.\VBoxManage.exe internalcommands sethduuid "C:\Users\campbell\VirtualBox VMs\Ubuntu14\Ubuntu14.vdi"
PowerShell
(not as administrator)cd C:\Program Files\Oracle\VirtualBox
.\VBoxManage.exe modifyhd "C:\Users\campbell\VirtualBox VMs\Ubuntu14\Ubuntu14.vdi" --resize 40000
gparted
(install it if is is missing sudo apt-get install gparted
)Swapoff
Delete
linux-swap
in the File system field.swapon
If you are making the disk bigger, you would
To enlarge a disk you can use the VBoxManage modifyhd
command. Suppose you want to resize the disk to 20,000 megabytes (~20GB). First locate the disk file that you want to expand. Then, in terminal, give this command to resize the disk:
VBoxManage modifyhd "path-of-disk-file" --resize 20000
To enlarge the partition and file system, probably it's easiest to boot the virtual machine using a Ubuntu livecd and do the job with GParted, as it does both at the same time and gives you a graphical user interface for it.
Attach a livecd ISO image to the virtual machine and change the boot order to first boot from CD. If you don't have a Ubuntu livecd at hand you can use any livecd that comes with the appropriate tools. SliTAZ for example is only 35MB to download. Open GParted and choose the disk you want to resize. Then right-click on the partition that you want to expand and choose the option "resize-move." In the dialog box that opens, in the graphic that represents the partition, drag the triangle at the end of the partition all the way to the right to maximize it. Then close the dialog and choose "Apply" on the toolbar. Since no data has to be moved this should be a quick operation.
When done, don't forget to detach the livecd from the virtual machine and change the boot order.
You'll find a pretty good tutorial of the whole process with screenshots included here: http://trivialproof.blogspot.com/2011/01/resizing-virtualbox-virtual-hard-disk.html