Yesterday had installed Ubuntu LINUX in virtual box for my production server. I had use bridged networking with static IP address which enable me to access my server from outside. After successful completion with Linux server, I realize that my virtual box HDD size is just 10 GB which can create issue is server data grows. I was looking for a solution like how to increase virtual box disk size, “how to extend virtual box disk in Ubuntu”. After spending three hours of time I didn’t find the solution which perfect works. I try to extend virtual box size via command prompt but use of that space under the same logical volume is a big challenge. Finally I succeed with extending my virtual box logical volume in the LINUX. So I plan to draft the steps here so I can use those in near future. Also other techie geek can use this information to increased space in virtual box.
How to extend Virtualbox Image Disk Size in Ubuntu/CentOs Linux
I highly recommend that you saved your virtual box image as a backup because these steps are perfectly worked for me but might be the case that it would result in loss of data. So taking backup is always best.
Steps required to execute from host OS(My case it is Windows 7)
Open your command prompt in administrative mode by simply clicking command prompt and run as administrator. Execute below, command to increase the size of virtual box.
First go to the location where your virtual boxes installed in my case it is: “C:/Program Files/Oracle/VirtualBox/”
C:/Program Files/Oracle/VirtualBox/ > VBoxManage.exe modifyhd –resize 29696 “F:\VirtualBoxHDD\CentOS\CentOS-6.6.vhd”
here my virtual box image location is in F: Drive and am going to make it 30 GB(Apx : 29696 MB)
Steps required to execute on guest OS(my case it is CentOs 6.6)
Before proceeding with this I suggest stay calm as the steps are very important and messing with the Wrong step can damage your data. Also make sure that the steps are executed on guest OS which is LINUX in our case.
After booting into Linux open your terminal with a root privileges
- listed devices type “FDISK – l” which gives information about the available drives like sda1,sda2
- type “fdisk /dev/sda”
- now you are in FDISK prompt where you can place ”m” for getting help for the available options
- Now you required to add a new primary partition by selecting “n” Command . On on asking for number enter 3 (which creates sda3 as a new primary drive)
- now you need to specify the file format of the newly created drive. Enter command “t” and on asking code type : 8e (Linux LVM)
- type command (p) for printing partition table
- type command(w) for writing partition table. Ignore the error on this step.
- Now reboot the system.
Add newly created partition as Physical volume
[email protected]~]# lvm
lvm> pvcreate /dev/sda3
Physical volume “/dev/sda3” successfully created
Add new drive to existing logical volume group
lvm> vgextend vg_wp-techie /dev/sda3
Volume group “vg_wp-techie” successfully extended
Note: Here my Volume Group name is “VG_wp-techie” replace it with your volume group name
Find out partition name
lvm> lvdisplay — Logical volume — LV Path /dev/vg_wp-techie/lv_root
Extend your logical volume size and resize the file system
lvm> lvextend -L+17.8G /dev/vg_wp-techie/lv_root Rounding size to boundary between physical extents: 17.8 GBExtending logical volume lv_root to 30.0 GBLogical volume lv_root successfully resized Now you need to exit FDISK manager by typing exit command resize2fs -F /dev/vg_ccloud12/lv_root
That’s it now you virtual box partition is increase to 30 GB which you can verify by executing
let me know how it works on your system and feel free if you have any difficulties in resizing virtual box hard disk . if you have any alternative way than please share with us by comment.