Clone the disk
VBoxManage clonehd “path/WebServer.vmdk” “path/WebServer.vdi” –format vdi
resize 20*1024 = 20GB
VBoxManage modifyhd “path/WebServer.vdi” –resize 20480
reconvert into vmdk
VBoxManage clonehd “path/WebServer.vdi” “path/WebServer.vmdk” –format vmdk
File -> Virtual Media Manager -> Removed existing images (note, I removed them only from the registry).
1. Open the Oracle VM VirtuaBox Manager
Click on File -> Virtual Media Manager (or Ctrl+D)
2. Delete the hard disk entry in question (select and press “Del” on keyboard)
3. Open “Settings” of the Virtual Machine, go to “Storage”, click “Add Attachment”, select “Add Hard Disk” and “Choose existing disk“, then selected the vdi file and you are done.
- Download “gparted-live-x.xx.x-x-ixxx.iso” file from http://gparted.sourceforge.net/download.php. Mount this iso file as CD.
Virtual Machine -> Settings -> Storage -> Controller IDE (Right Click) -> Add CD/DVD -> Select gparted-live-x.xx.x-x-ixxx.iso file
- Run virtual machine, Virtual Machine will boot from this CD. Choose default values with pressing “Enter”, “Enter” … until Gpart ISO GUI starts. Select tool gpart program and start.
- Extend disk size as below;
- Right click on partitions and if “possible” click on “Disable Active Partion”.
- Extend Partition as much as possible from GUI (for this case 500GB).
- Right click the partition which is disabled and select “Enable Active Partion”.
- Apply and wait until the operations finished.
- Shut down virtual machine.
- Unmount gparted-live-x.xx.x-x-ixxx.iso.
$ Virtual Machine -> Settings -> Storage-> Controller IDE (Right Click on gparted-live-x.xx.x-x-ixxx.iso) -> Remove Attachement
- Start the virtual machine.
vgdisplay
df -h
File system Dim. Usati Dispon. Uso% Montato su /dev/mapper/centos-root 19G 6,2G 13G 34% / devtmpfs 910M 0 910M 0% /dev tmpfs 920M 0 920M 0% /dev/shm tmpfs 920M 8,6M 912M 1% /run tmpfs 920M 0 920M 0% /sys/fs/cgroup /dev/sda1 1014M 188M 827M 19% /boot tmpfs 184M 0 184M 0% /run/user/0
resize2fs /dev/mapper/centos-root
lvextend -l+100%FREE /dev/mapper/centos-root
resize2fs /dev/mapper/centos-root
xfs_growfs /dev/mapper/centos-root
df -ha
—– what did the provider to remeber—-
First step extend last partition:
fdisk /dev/sda
p > take note of beginning of sda4 just in case
d > 4
n > 4 > > >
t > 4 > e8 (to mark it as LVM partition)
w
reboot
Resize the lvm :
pvscan > to make sure we have free space
pvresize /dev/sda4
lvscan > to take note of lv path
lvextend -l +100%FREE /dev/centos/root
xfs_growfs /dev/mapper/centos-root -d