centos7 mount the hard disk unallocated space

===============================================

 2019/7 / 28_ first edit              ccb_warlock          

 

===============================================

In the recent work done to provide virtual machine discovery, vcenter templates and although you can quickly create a virtual machine template exactly the same, but because of different configurations on the hard drive of each person's request, vmware only support expansion of hard drive configuration.

In doing so the template, designed to be smaller hard drive, and then do the expansion disk, depending on each person's needs just fine.

 


One, Scene

The initial virtual machine hard disk: 16G

After the expansion of the virtual machine hard disk: 50G

Requirements: The expansion of 34G of space added to the file system / dev / mapper / centos-root in

 


Second, the expansion of the file system

2.1 confirmation hard disk space

# View the file system of the hard disk

df -h

 

# Check the hard disk and partition number of cases

fdisk -l

 

2.2 pairs of unallocated space to partition

# Create a new partition

fdisk / dev / sda

 

1) Enter "n", the transport; (n: New Partition)

 

2) do not enter, the transport; (p: primary partition)

 

3) There are several options do not enter, Enter;

 

4) Enter "t", Enter; then do not enter, the transport; (t: Set partition number)

 

5) Enter "L", the transport; then enter "8e", carriage return; (8e: Specifies the partition as Linux LVM)

 

6) Enter "w", carriage return; (w: save changes)

 

2.3 restart the virtual machine

reboot

 

2.4  View new partitioning (the new partition / dev / sda3)

fdisk -l

 

2.5  the target partition expansion

# Create a physical volume

pvcreate /dev/sda3

 

# Adding a physical volume (/ dev / sda3) to the volume group (CentOS)

vgextend centos /dev/sda3

 

# 查看centos卷组的属性

vgdisplay

可以看到有不到34G的空闲空间可以扩展。

 

# 将空闲的空间都分配给root文件系统

lvextend -l +100%FREE /dev/mapper/centos-root

 

# 对root文件系统执行扩容

xfs_growfs /dev/mapper/centos-root

 

# 查看扩容后文件系统的硬盘使用

df -h

 

 


参考资料

1.https://www.cnblogs.com/piaoyang2087/articles/6829225.html

2.https://www.cnblogs.com/kevingrace/p/5825963.html

 

 

Guess you like

Origin www.cnblogs.com/straycats/p/11261364.html