Expand the CentOS disk capacity in VMware

How to set up CentOS 7 disk expansion for VMware virtual machine - Baidu Experience (baidu.com)

When the CentOS disk space in VMware is insufficient, disk expansion is required. The specific steps are as follows:

Step 1: Expand the disk capacity of the virtual machine

1. First, open the virtual machine that has been installed, select the virtual machine that needs to expand the disk, and click "hard disk" in the device. As shown in the picture:

2. Then, enter the virtual machine setting interface, and select "Extension" on the right side of the interface. As shown in the picture:

3. Then, in the pop-up expansion disk capacity, enter the size of the disk to be expanded, and click "OK" after completion. As shown in the picture:

4. Next, wait for the system to automatically expand, and select "OK" in the pop-up dialog box, so that the disk expansion of the virtual machine is completed. As shown in the picture:

5. Then, return to the virtual machine setting interface, click "OK" below to save the parameters just set. As shown in the picture:

In this way, the expansion of the disk capacity of the virtual machine is completed, and then enter centos to expand the disk capacity.

Step 2: Mount the disk in the centos 7 system

1. First, start the virtual machine, enter the centos 7 system, open the terminal, enter the "# df -h" command in the terminal interface, and press Enter, you can see the original 30G disk in the terminal interface, and it has not been expanded . As shown in the picture:

 2. Next, enter the "# fdisk -l" command in the terminal interface to view the partition information of the new disk. As shown in the picture:

 3. Next, enter the "# fdisk /dev/sda" command in the terminal interface to partition the newly added disk (select the newly added disk), and press Enter. As shown in the picture:

4. Then, in the terminal command, enter the "p" command and press Enter to view the number of partitions. As shown in the picture:

5. Then, in the terminal command, enter the "n" command and press Enter to add a new partition. As shown in the picture:

6. Then, enter the "p" command in the terminal command window, press Enter, hit the default partition number in the opened partition number, and press Enter. As shown in the picture:

7. Then, directly press the Enter key in the displayed starting sector, and directly press the Enter key in the pop-up Last to enter the next step (directly use the Enter key at the position of the picture frame to enter the next step) . As shown in the picture:

8. Next, continue to enter "p" in the terminal command window and press Enter to view the information of the current partition. In the displayed information, you can see that a new partition has been added, and the size is the size just set. As shown in the picture:

9. Then, enter the "w" command in the terminal command, press Enter, write the disk information and save it. As shown in the picture:

 10. Then, in the terminal command window, enter "# reboot" and press Enter to restart the virtual machine and format the newly created partition. As shown in the picture:

11. Next, wait for the system to restart automatically, open the terminal command, and enter "# vgdisplay" in the command window to view the disk volume group name. As shown in the picture:

12. Next, enter the "# pvcreate /dev/sda3" command in the terminal command window and press Enter to initialize the newly created partition. As shown in the picture:

13. Next, enter the "# vgextend centos /dev/sda3" command in the terminal command window and press Enter to add the newly initialized partition to the virtual volume group name (command: # vgextend virtual volume group name to add a new partition) . As shown in the picture:

 14. Next, continue to enter the "# vgdisplay" command in the terminal command window to view the detailed information of the volume group. In the detailed information, you can see that the newly added 10G space is still in an idle state. As shown in the picture:

 15. Then, continue to enter the "# df -h" command in the terminal command window and press Enter, check and write down the name of the file system that needs to be expanded (the system name I checked here is: /dev/mapper/centos -root, what you see in different versions should be different, you should pay attention to the distinction). As shown in the picture:

16. Then, continue to enter the "# lvextend -L +9G /dev/mapper/centos-root" command in the terminal command window and press Enter to expand the existing volume group capacity (note: if you expand the capacity to 10G, here 10G cannot be fully expanded, only a capacity smaller than 10G can be expanded, otherwise the system will report an error and the expansion will fail. The editor only expands 9G here. Command: # lvextend -L + the file system name that needs to be expanded to expand the capacity, you need to pay attention case-sensitive letters in the command ). As shown in the picture:

 17. Next, continue to enter the "# pvdisplay" command in the terminal command window and press Enter to view the current volume group. In the displayed information, the volume group has been expanded successfully, and the file system needs to be expanded next. As shown in the picture:

18. Next, continue to enter the "# cat /etc/fstab | grep centos-root" command in the terminal command window and press Enter to view the format of the file system. As shown in the picture:

 19. Then, you have seen the format of the file system in the previous step, you need to use the corresponding command to expand the disk space, enter the "# xfs_growfs /dev/mapper/centos-root" command in the terminal command and press Enter (command : # xfs_growfs file system name, different file systems need to use different commands, otherwise it will cause an error). As shown in the picture:

 20. Next, wait for the system to automatically expand. After completion, enter the "# df -h" command in the terminal command window and press Enter to check whether the disk size has been expanded successfully. In the displayed disk information, you can see that the disk has been expanded successfully. up. As shown in the picture:

 21. At this point, the sharing of how to set up the CentOS 7 disk expansion tutorial for the VMware virtual machine is over.

Guess you like

Origin blog.csdn.net/Cecidit_824/article/details/131245349