For current network developers, a good partner is a combination of Win7 + VirtualBox + CentOS, which can leverage the powerful network service functions of Linux and effectively isolate slow systems of various services, the impact on the system operation can reduce the loss caused by configuration Errors for new users. The most important thing is to facilitate the migration. Different system reinstallation requires a lot of trouble.
However, if we find that the system storage is not enough when installing and using the virtual machine, we can use VirtualBox version 4 or later to conveniently and quickly scale up.
In VirtualBox, virtual hard disks include VMDK, VDI, VHD, and HDD,
VMDK is developed and used by VMware and is also supported by SUN's xVM, QEMU, SUSE Studio, and. NET DiscUtils, so it has better compatibility.
VDI is the processing format of Virtual Box, and Virtual Box supports Windows and Linux, so it is better for users who use VirtualBox.
VHD is a proprietary processing format for Windows, and HDD is Apple's proprietary processing format. Therefore, it does not support cross-platform processing and is generally not considered.
Here we will take how to resize VMDK and VDI as an example. For other formats, convert them to Baidu Google.
VDI
The simplest command for VDI resizing is as follows:
VBoxManage modifyhd xxxx. vdi -- resize 16000 // xxxx. vdi is generally stored in VirtualBox VMs.
VMDK
If it is a VMDK, it must be converted to VDI before resizing.
VBoxManage clonehd "xxxx. vmdk" "cloned. vdi" -- format vdiVBoxManage modifyhd "cloned. vdi" -- resize 16000 // The unit here is M
If you want to switch back to VMDK, you can directly use the vdi format.
Open the system on the Virtual Machine and run df-h to check whether the root directory is the same. We can use lVM to expand partitions.
LVM (Logic Volume Manager) logical Volume management, like the default partition management method of the RedHat system, is built on the hard disk partition, the Logic layer under the file system, it is used to solve the problem of incorrect evaluation and partition capacity allocation during initial partitioning, resulting in insufficient system partitions.
Think of a word from a great god. Any problems in the computer can be solved by adding an intermediate layer.
So extending partitions is just a few lines of code.
Sudo fdisk-l to view the current system partition. You can view the created partition, sda1 sda2, or ls/dev. If there is a second hard disk, you will see sdb,
I only have one, and have already divided sda1 and sda2.
Create the extended space and create a new partition
Sudo mkfs. ext4/dev/sda4 // format the partition to ext4
Perform the following LVM operations:
Sudo vgdisplay // check the volume group name. Here is the VolGroup. Remember to use
Sudo pvcreate/dev/sda4 // create a new physical volume sudo vgextend VolGroup/dev/sda4 // extend to the volume group
/Dev/VolGroup/lv_root is the root partition and the partition to be extended.Sudo lvextend-L + 6.96/dev/VolGroup/lv_rootsudo lvextend/dev/VolGroup/lv_root/dev/sda4/both commands can be used, but the following are better and do not need to be calculated, commands mean to extend to logical partitions.
LastSudo resize2fs/dev/VolGroup/lv_root // refresh the capacity of the logical partition sudo df-h // you will find that the root partition is doubled...
Sudo reboot // restart the system. Everything is OK. My VM is revived again...
PS: add some basic LVM knowledge:
In LVM, PVS, VG, and LV indicate physical volumes, Volume groups, and logical volumes respectively.
The procedure is to create the entire partition and hard disk as a physical volume through pvcreate -- create a volume group volgroup for home vgcreate, add the physical volume of pvcreate to -- and then use lvcreate to create a logical volume of 20 GB in the volume group volgroup --> Use mkfs to format it as the expected format, such as ext4 --> mount the file through mount, form a file system that we can access.
If you want to scale out, use lvextend-L + xxG/dev/VolGroup/zzz to Increase the capacity.
If you want to compress ---- unmount the logical volume -- e2fsck detects the remaining capacity -- resizef2fs/dev/VolGroup/zzz xxM reduces xxM -- lvreduce-L xxM reduces the logical volume by xxM
The "lvremove vgremove pvremove" command also requires umount to modify the mounting information in/etc/fstab at the same time; otherwise, it cannot be started.