Resize /dev/sda1 disk of your Vagrant / VirtualBox VM
[10:42:56] vagrant@server:~ > df
Sys. de fichiers 1K-blocs Utilisé Dispo. Uti% Monté sur
/dev/sda1 1925072 1719144 108136 95% /
tmpfs 1030592 0 1030592 0% /lib/init/rw
udev 1025752 144 1025608 1% /dev
tmpfs 1030592 0 1030592 0% /dev/shm
v-root 244277768 216144688 28133080 89% /vagrant
Wanna add some free space on your Virtual Machine ?
It can be done easily (5-10 minutes) following these 3 steps :
1. Add free space to the virtual disk
# Go to the VM folder on your Host computer.
cd ~/VirtualBox VMs/VM-NAME
# Since resize can't be applied to .vmdk, we'll convert the disk to .vdi format
VBoxManage clonehd box-disk1.vmdk box-disk1.vdi --format vdi
# Output example : # 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% # Clone hard disk created in format 'vdi'. UUID: 49474a0a-c48c-4b15-8df0-0b9687b4bbaf
# Now, let's resize the disk to add free space (from 2GB to 10GB => 1024*10)
VBoxManage modifyhd box-disk1.vdi --resize 10240
# Output example :
# 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Now, step 2 !
2. Modify your VM to use the new VDI disk
Download GParted ISO on your Host computer.
Now, follow these steps :
Open VirtualBox and select your stopped VM
Click Storage, and you will see you VDMK disk and its current Virtual Size (here, 2GB)
Click “-” to unattach this disk, which should disappear
Click “+” and select “choose existing disk”
Select your VDI disk
In “IDE Controller” section you should have a CD/DVD reader.
Click on the icon on the right and select “choose a virtual CD/DVD disk file…”
Select the GParted ISO you downloaded
Click “OK” ands now, you’re ready for the latest step.
3. Change partitions to use the free space
Start your virtual machine in VirtualBox GUI, it should boot GParted.
You can change the Keymap if needed, but it’s optional
You can change language, but it’s optional too
Start GParted with default option “0″
GParted displays your VM disks / partition. You can see that 8GB are free / unallocated.
You will have to remove /dev/sda2
(extented partition) to resize /dev/sda1
Resize your partition
Don’t forget to recreate your linux-swap partition at the end of the disk (I forgot this screenshot)
And apply changes to the filesystem !
You’re done ! You can shutdown the VM.
Now remove GParted ISO to let your VDI disk boot
As you can see, size changed from 2GB to 10GB
You can now boot you VM with vagrant up
command.
[11:33:18] vagrant@server:~ > df
Sys. de fichiers 1K-blocs Utilisé Dispo. Uti% Monté sur
/dev/sda1 8256440 1720684 6116380 22% /
tmpfs 1030592 0 1030592 0% /lib/init/rw
udev 1025752 140 1025612 1% /dev
tmpfs 1030592 0 1030592 0% /dev/shm
v-root 244277768 218211680 26066088 90% /vagrant