vmware expands centos7 virtual machine disk (1)

Shut down the virtual machine and open virtual machine settings->Add
Insert image description here

Click the hard disk -> Select next step
Insert image description here
. It is recommended to use SCSI. The default is enough.
Insert image description here
Create a new virtual disk. Next step
Insert image description here
is to split the virtual machine disk into multiple files. Next step
Insert image description here
is to name it and customize it. Complete.
Insert image description here
The addition is completed. Turn on the virtual machine and set it up.
Insert image description here

This article introduces how to expand the "/" directory

View file system

[root@localhost ~]# df -h

Insert image description here

Check the partition and you can see that the newly added disk is in /dev/sdb

fdisk -l   查看分区使用情况

Insert image description here

Insert image description here
Enter "p" and press Enter, #View the number of partitions
Insert image description here
. Enter "n" and press Enter, #Add a new partition.
Insert image description here
Enter "p" and press Enter, #Use the default partition number, and
Insert image description here
press Enter at the starting sector (use the default value)
Insert image description here
Press Enter after popping up last,
Insert image description here
then enter "p" to view the current partition information,
Insert image description here
enter "w" to write the disk information and save it.
Insert image description here
Restart the virtual machine to format the new partition;

[root@localhost ~]# init 6  重启虚拟机
[root@localhost ~]# fdisk -l

Insert image description here

[root@localhost ~]# vgdisplay

Insert image description here

Initialize the created partition,

[root@localhost ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created. #命令执行结果,物理卷“/dev/sdb1”创建成功。

To expand the space of the original file system, you need to perform the following steps:

Add partition to virtual volume

[root@localhost ~]# vgextend centos /dev/sdb1
Volume group "centos" successfully extended #命令执行结果,卷组“centos”成功扩展

Then lvextend -L +19G /dev/mapper/centos-root to expand the volume group capacity, and use fdisk -l to query the disk /dev/mapper/centos-root.

[root@localhost ~]# lvextend -L +19G /dev/mapper/centos-root
  Insufficient free space: 5120 extents needed, but only 5119 available

xfs_growfs /dev/mapper/centos-root expands disk space

[root@localhost ~]# xfs_growfs /dev/mapper/centos-root 

Insert image description here
The next step is to mount, df -h to check the disk status before mounting
Insert image description here

Mounting cannot be done directly here because the disk system format is not ext4.

[root@localhost ~]# mount /dev/sdb1 /
mount: 未知的文件系统类型“LVM2_member”

Use the command mkfs.ext4 /dev/sdb1 to format the hard disk to ext4

[root@localhost ~]# mkfs.ext4 /dev/sdb1

Insert image description here
mount mounts the disk

[root@localhost ~]# mount /dev/sdb1 /

The root directory of the mounted disk has 20G of available space.
Insert image description here

Guess you like

Origin blog.csdn.net/qq_39689711/article/details/129601605