howto resize / expand a vdi disk (linux guest)
Posted: 8. May 2009, 20:41
in order to resize a vdi disk of a linux guest you need a bootable linux live cd (iso image).
further, the linux live cd should include a terminal an gparted.
in my case i choose ubuntu-8.04.2-desktop-i386.iso.
But first of all: BACKUP the linux guest you want to resize!!
use this howto at your own risk.
forgive me, my imperfect language skills
steps to take:
create a new vdi disk with the required size:
a) start virtualbox; go to menu -> file -> virtual disk manager -> hard diks -> new -> follow the assistant
b) attach the new vdi disk to the guest (old vdi disk) you want to resize: go to settings -> hard disks -> add the new vdi disk as primary slave
mount the live cd (iso image)
c) attach a live cd iso image to the linux guest you want to resize: go to settings -> cd/dvd-rom -> highlight cd/dvd drive mount checkbox -> select iso image -> choose a iso image
d) modify the boot order: go to settings -> general -> advanced -> boot order -> disable floppy / move cd/dvd to the top
e) boot the live cd; choose the first option of the ubuntu install menu (if you use the ubuntu 8.04 live cd iso image)
clone the old vdi disk to the new (terminal live cd desktop)
f) start a terminal from the linux guest desktop (ubuntu desktop go to the menu application -> accessories -> terminal)
g) get root privileges; therefore type into the terminal type: sudo -s
h) find ou the devices of the new and old vdi disk; type into the terminal: fdisk -l
i) write down the output of fdisk -l (look for something like /dev/sda and /dev/sdb or /dev/hda and /dev/hdb)
j) clone the old vdi disk to the new; type into the terminal: dd if=/dev/old of=/dev/new (replace old/new according to your needs)
k) wait (cloning the old vdi disk can take some hours)
verify the clone (terminal live cd desktop
l) verify the partition tables; type into the terminal: fdisk -l (the partition table oft the new and old vdi disk should be similar)
m) verify if the clone vdi disk boots and runs fine:
-> shut down the live cd
-> change the cd/dvd drive mount from iso image to cd/dvd drive
-> make the clone vdi disk to the primary master disk and the old vdi disk to a primary slave disk
-> start the clone vdi disk
n) if the clone works fine you are ready to resize the partition so that the clone can use the whole size of the new vdi disk
resize the clone vdi disk (gparted live cd desktop)
o) shut down the clone vdi disk and modify the cd/dvd-rom settings in order to boot into the live cd
p) start gparted on the live cd desktop (ubuntu desktop: menu -> system -> administration -> partition editor)
q) remove the swap partition (this is only necessary if the swap partition split the clone vdi disk):
-> in gparted all the partition are listed below the graphical illustration
-> right-click on to the linux-swap-partiton and switch it of
-> right-click on to the linux-swap-partiton and delete it.
-> after that delete the expanded-partition too (if the swap is in an expanded-partition)
r) expand the data-partition (in my case ext3):
-> right-click the data-partition choose resize/move and expand the partition to the maximum size
-> right-click the data-partition and reduce the size of data-partition by 500MB-1GB (a new empty-grey part should be created)
s) create a new linux-swap-partition:
-> right-click the new empty-grey part -> new -> option expanded partition (creates an expanded)
-> right-click into the new expanded-partition -> new -> option logical partition / filesystem linux-swap (creates a linux-swap)
t) write down the modifications to the partition table:
-> go to the gparted menu -> edit -> apply all operations
u) close gparted
make the clone vdi disk default and verify it
v) shutdown the live cd
w) make clone vdi disk default:
-> modify the cd/dvd-rom mount settings, so that the guest boots from the clone vdi disk
-> modify the hard disk settings: set the clone vdi disk to primary master and the old vdi disk to primary slave (don't delete it yet)
-> boot into the clone vdi disk, check if everthing works fine
delete the old vdi disk
x) shut down the clone vdi disk
y) delete the old vdi disk:
-> do to hard disk settings
-> highlight the old vdi disk and remove it
-> go to the virtualbox menu -> file -> virtual disk manager -> highlight the old vdi disk and delete it
You have it made.
I have to say thank you to all the unknowns out there in the www. I only assembled their ideas. Thank you!
further, the linux live cd should include a terminal an gparted.
in my case i choose ubuntu-8.04.2-desktop-i386.iso.
But first of all: BACKUP the linux guest you want to resize!!
use this howto at your own risk.
forgive me, my imperfect language skills
steps to take:
create a new vdi disk with the required size:
a) start virtualbox; go to menu -> file -> virtual disk manager -> hard diks -> new -> follow the assistant
b) attach the new vdi disk to the guest (old vdi disk) you want to resize: go to settings -> hard disks -> add the new vdi disk as primary slave
mount the live cd (iso image)
c) attach a live cd iso image to the linux guest you want to resize: go to settings -> cd/dvd-rom -> highlight cd/dvd drive mount checkbox -> select iso image -> choose a iso image
d) modify the boot order: go to settings -> general -> advanced -> boot order -> disable floppy / move cd/dvd to the top
e) boot the live cd; choose the first option of the ubuntu install menu (if you use the ubuntu 8.04 live cd iso image)
clone the old vdi disk to the new (terminal live cd desktop)
f) start a terminal from the linux guest desktop (ubuntu desktop go to the menu application -> accessories -> terminal)
g) get root privileges; therefore type into the terminal type: sudo -s
h) find ou the devices of the new and old vdi disk; type into the terminal: fdisk -l
i) write down the output of fdisk -l (look for something like /dev/sda and /dev/sdb or /dev/hda and /dev/hdb)
j) clone the old vdi disk to the new; type into the terminal: dd if=/dev/old of=/dev/new (replace old/new according to your needs)
k) wait (cloning the old vdi disk can take some hours)
verify the clone (terminal live cd desktop
l) verify the partition tables; type into the terminal: fdisk -l (the partition table oft the new and old vdi disk should be similar)
m) verify if the clone vdi disk boots and runs fine:
-> shut down the live cd
-> change the cd/dvd drive mount from iso image to cd/dvd drive
-> make the clone vdi disk to the primary master disk and the old vdi disk to a primary slave disk
-> start the clone vdi disk
n) if the clone works fine you are ready to resize the partition so that the clone can use the whole size of the new vdi disk
resize the clone vdi disk (gparted live cd desktop)
o) shut down the clone vdi disk and modify the cd/dvd-rom settings in order to boot into the live cd
p) start gparted on the live cd desktop (ubuntu desktop: menu -> system -> administration -> partition editor)
q) remove the swap partition (this is only necessary if the swap partition split the clone vdi disk):
-> in gparted all the partition are listed below the graphical illustration
-> right-click on to the linux-swap-partiton and switch it of
-> right-click on to the linux-swap-partiton and delete it.
-> after that delete the expanded-partition too (if the swap is in an expanded-partition)
r) expand the data-partition (in my case ext3):
-> right-click the data-partition choose resize/move and expand the partition to the maximum size
-> right-click the data-partition and reduce the size of data-partition by 500MB-1GB (a new empty-grey part should be created)
s) create a new linux-swap-partition:
-> right-click the new empty-grey part -> new -> option expanded partition (creates an expanded)
-> right-click into the new expanded-partition -> new -> option logical partition / filesystem linux-swap (creates a linux-swap)
t) write down the modifications to the partition table:
-> go to the gparted menu -> edit -> apply all operations
u) close gparted
make the clone vdi disk default and verify it
v) shutdown the live cd
w) make clone vdi disk default:
-> modify the cd/dvd-rom mount settings, so that the guest boots from the clone vdi disk
-> modify the hard disk settings: set the clone vdi disk to primary master and the old vdi disk to primary slave (don't delete it yet)
-> boot into the clone vdi disk, check if everthing works fine
delete the old vdi disk
x) shut down the clone vdi disk
y) delete the old vdi disk:
-> do to hard disk settings
-> highlight the old vdi disk and remove it
-> go to the virtualbox menu -> file -> virtual disk manager -> highlight the old vdi disk and delete it
You have it made.
I have to say thank you to all the unknowns out there in the www. I only assembled their ideas. Thank you!