The virtual machine disk pre-allocation created by VMWare is changed to auto-grow

        After using a VMware virtual machine to install the Ubuntu system, I recently felt that the previously pre-allocated space was a bit large, so I wanted to reduce it a bit. Because when I chose to allocate the disk, I chose to allocate space immediately in the hope of improving the performance of the virtual machine, so now I cannot reduce the disk. Since I don't want to reinstall Ubuntu, I hope to find a reasonable and feasible solution. After searching the Internet for a long time, I feel that the solutions I see are not so clear at a glance. So I want to sort it out and simplify the solution.

        The current method of use is to use the method of modifying the disk type, that is, converting a disk with pre-allocated space into a self-growing disk. details as follows:

(1) Copy the disk file representing the VMare virtual machine to the VMare home folder (VMare installation directory). For example, if the name of the virtual machine is "Ubuntu16.04 LTS", the VMware virtual machine disk file may be called "Ubuntu 16.04 LTS.vmdk".

(2) Open the command line or terminal (command line in Linux) in the host to run the virtual disk management software. On the Windows host, change the directory to the directory where you installed the Workstation software. The default installation directory is C:\Program Files\VMware\VMware Workstation. Remember this address for later use. Mine is D:\VMware Workstation12.

(3) Open the CMD window (I am using a Windows system) and enter the address you need to remember above (D:\VMware Workstation12). Then use the VMware disk conversion command. The format of the command is: vmware-vdiskmanager [option];

What should be used here is:

vmware-vdiskmanager -r sourceDisk.vmdk -t 0 targetDisk.vmdk

The above command will convert a pre-allocated virtual disk sourceDisk.vmdk into a growable virtual disk targetDisk.vmdk.

If the disk file representing the VMare virtual machine is not copied to the VMare home folder, you can also directly apply the above command according to the absolute address of the disk file.

What I use is:

vmware-vdiskmanager -r "D:\Ubuntu 64\Ubuntu 16.04 LTS.vmdk" -t 0 "D:\Ubuntu 64\Ubuntu 16.04.vmdk"

I use the absolute address and indicate that the disk file location of the virtual machine is D:\Ubuntu 64.

(4) Wait for a while and close the CMD window when CMD prompts that the conversion is 100% complete.

(5) Open VMware Workstation, add the virtual machine disk file generated by the above disk to the virtual machine, and delete the unwanted disk.

(6) Remove excess virtual machine disk files in the local area, and be careful not to delete the newly generated virtual machine disk file.

(7) When you open the virtual machine, do you find that the functions are the same as before and the memory occupied is much less (provided that the disk file usage of the virtual machine itself has not reached the preset value).

At this point the whole world becomes easier again.

In fact, if you had not chosen to allocate memory immediately when creating a new virtual machine, this would not have happened. Immediate memory allocation would not provide much performance improvement. Currently, I do not feel any improvement. But this is also a learning process.

The above methods have been tested by me personally and I cannot guarantee the universal applicability of the above methods. If it doesn't work, you can try other methods. If it doesn't work, just reinstall it.

Other information addresses for reference:

http://www.codebye.com/how-to-change-a-vmware-disk-to-preallocated.html

https://zhidao.baidu.com/question/1574855471667804660.html

The first one is how to convert a self-growing disk into a disk with pre-allocated space; the second information explains the specific meaning of the disk type conversion command and the meaning of other options.

Note: You should shut down the virtual machine before performing the above operations.

Guess you like

Origin blog.csdn.net/liuxhCSDN/article/details/84074121