VirtualBox modifies the Virtual Machine disk VDI size
During the use of VirtualBox virtual machines, the disk size is sometimes insufficient. If you set "Dynamic Storage Allocation", you can manually expand the disk space using the following method.
1. Start the CMD command line to enter the VirtualBox installation directory. For example
Cd E: \ Program Files \ Oracle \ VirtualBox
2. view the virtual hard disk to be modified:
E: \ Program Files \ Oracle \ VirtualBox> VBoxManage.exe list hdds
UUID: e8e2c341-b3b1-49db-ad2d-ab4e6b08bc5a
Parent UUID: base
State: locked write
Type: normal (base)
Location: F: \ VM \ CentOS-64.vdi
Storage format: VDI
Capacity: 8000 MBytes
UUID: 707d45b6-440d-4e51-96bd-8c9508bfd313
Parent UUID: base
State: created
Type: normal (base)
Location: F: \ VM \ CentOS-64-ext.vdi
Storage format: VDI
Capacity: 21273 MBytes
UUID: aca81637-fbc0-4826-be66-847ecc96d83b
Parent UUID: base
State: created
Type: normal (base)
Location: C: \ Users \ Edward. Wu \ VirtualBox VMs \ WinXP. vdi
Storage format: VDI
Capacity: 10240 MBytes
----
We see there are three Virtual Disks, we want to modify the first in the figure, its space size is 8 GB, UUID: e8e2c341-b3b1-49db-ad2d-ab4e6b08bc5a
2. Adjust the disk space to 15 GB:
E: \ Program Files \ Oracle \ VirtualBox> VBoxManage.exe modifyhd e8e2c341-b3b1-49db-ad2d-ab4e6b08bc5a -- resize 150000%... 10%... 20%... 30%... 40%... 50%... 60%... 70%... 80%... 90%... 100%
3. Check again:
E: \ Program Files \ Oracle \ VirtualBox> VBoxManage.exe list hdds UUID: e8e2c341-b3b1-49db-ad2d-ab4e6b08bc5a Parent UUID: base State: locked write Type: normal (base) Location: F: \ VM \ CentOS-64.vdi Storage format: VDI Capacity: 15000 MBytes
UUID: 707d45b6-440d-4e51-96bd-8c9508bfd313 Parent UUID: base State: created Type: normal (base) Location: F: \ VM \ CentOS-64-ext.vdi Storage format: VDI Capacity: 21273 MBytes
UUID: aca81637-fbc0-4826-be66-847ecc96d83b Parent UUID: base State: created Type: normal (base) Location: C: \ Users \ Edward. wu \ VirtualBox VMs \ WinXP. vdi Storage format: VDI Capacity: 10240 MBytes
4. view new disk space
Restart the VM to view the disk status.
[Root @ aimin ~] # Fdisk-l/dev/sda
Disk/dev/sda: 15.7 GB, 15728640000 bytes 255 heads, 63 sectors/track, 1912 cylinders
We can see that the disk space has been extended to 15 GB, but it cannot be used yet.
5. New Enable space
Use fdisk to create the free space of the virtual disk as a new partition. Note that the partition code 8e representing Linux LVM should be used as the ID.
# Fdisk/dev/sda
N {new partition}
P {primary partition}
3 {partition number}
[You will be prompted to change the size. Press enter by default.]
T {change partition id}
3 {partition number}
8e {Linux LVM partition}
W
------
If there is a prompt such as setting the size in the middle, press Enter.
If the prompt is:
WARNING: Re-reading the partition table failed with error 16: the device or resource is busy. the kernel still uses the old table. the new table will be used at the next reboot or after you run partprobe (8) or kpartx (8)
Restart the system.
6. Check whether the newly added sda3 is marked as LVM. If no reboot is required
# Fdisk-l/dev/sda
7. Adjust LVM size
Let's take a look at the Volume Group name.
[Root @ aimin ~] # Vgdisplay --- Volume group --- VG Name vg_aimin
....
Vg_aimin is the name of my VolumeGroup. In actual operation, you must use the name actually displayed.
8. Create a new physical volume for the newly allocated space
# Pvcreate/dev/sda3
9. Then use the new physical volume to expand the LVM VolGroup,
# vgextend vg_aimin /dev/sda3 No physical volume label read from /dev/sda3 Writing physical volume data to disk "/dev/sda3" Physical volume "/dev/sda3" successfully created Volume group "vg_aimin" successfully extended
10. then extend the logical volume vg_aimin-lv_root of LVM,
# lvextend /dev/vg_aimin/lv_root /dev/sda3
11. Adjust the logical volume size
# Resize2fs/dev/vg_aimin/lv_root
Now the space is expanded.
12. view results
[Root @ aimin ~] # Df-H file system capacity available in use % mount point/dev/mapper/vg_aimin-lv_root 12G 5.2G 6.2G 46%/tmpfs 499 M 80 K 499 M 1%/dev/shm /dev/sda1 485 MB 33 M 427 M 8%/boot
Extended successfully !!!
This article permanently updates the link address: