使用lsblk命令查看磁盘情况
lsblk 
 
fdisk创建新分区
fdisk /dev/sdb
 fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x03295b0a.

Command (m for help):
 
输入p  回车
Command (m for help): p

Disk /dev/sdb: 5368 MB, 5368709120 bytes, 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x03295b0a

   Device Boot      Start         End      Blocks   Id  System

Command (m for help):

  输入n 回车

Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): 

 

输入 p 回车, 1 回车,回车,回车。
Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 

  

输入 p ,回车

Command (m for help): p

Disk /dev/sdb: 5368 MB, 5368709120 bytes, 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x03295b0a

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    10485759     5241856   83  Linux

Command (m for help):

  输入 w ,回车,保存退出。至此,磁盘分区完成。

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

  

刷新分区并创建物理卷

partprobe /dev/sda

pvcreate /dev/sda3

  

 

 

6.查看卷组名称,以及卷组使用情况

vgdisplay

 

 

 

VG Name为centos

7.将物理卷扩展到卷组

vgextend centos /dev/sda3

 

 

 

使用sda3扩展VG  centos 

8.查看当前逻辑卷的空间状态

lvdisplay

 

 

 

 
需要扩展LV  /dev/centos/root

9.将卷组中的空闲空间扩展到根分区逻辑卷

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

 

 

 

 

10.刷新根分区

xfs_growfs /dev/centos/root

 

 

 

 

11.查看磁盘使用情况,扩展之前和之后是不一样的

 

 

 

根分区已经变成27G

CentOS7,非LVM根分区扩容步骤:

1.查看现有的分区大小

 

 

 

非LVM分区,目前磁盘大小为20G,根分区总容量为17G


作者:神冰凰
链接:https://www.jianshu.com/p/273daea17b2a
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
 
卸载分区 umount /data1
(18条消息) centos 7磁盘扩容,扩展分区 /dev/mapper/centos-root_weixin_42874602的博客-CSDN博客
posted on 2021-12-06 19:34  博客园197  阅读(76)  评论(0编辑  收藏  举报