Skip to content

Latest commit

 

History

History
220 lines (156 loc) · 5.93 KB

系统盘扩容.md

File metadata and controls

220 lines (156 loc) · 5.93 KB

Table of Contents generated with DocToc

系统盘扩容

查看根目录/dev/mapper/

df -Th
...
/dev/mapper/openeuler_host--10--190--13--37-root ext4       46G  6.1G   38G  14% /

查看/dev/vda磁盘大小

fdisk -l |grep /dev/vda

Disk /dev/vda: 200 GiB, 107374182400 bytes, 209715200 sectors
/dev/vda1  *       2048   2099199   2097152   1G 83 Linux
/dev/vda2       2099200 104857599 102758400  49G 8e Linux LVM

磁盘分区

fdisk /dev/vda

[root@ecs-xinxzx-sspywgznl-0023 ~]# fdisk /dev/vda

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3):
First sector (104857600-209715199, default 104857600):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (104857600-209715199, default 209715199):

Created a new partition 3 of type 'Linux' and of size 50 GiB.

Command (m for help): w
The partition table has been altered.
Syncing disks.

创建物理卷

查看pv

pvdisplay

--- Physical volume ---
  PV Name               /dev/vda2
  VG Name               openeuler_host-10-190-13-37
  PV Size               <49.00 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              12543
  Free PE               0
  Allocated PE          12543
  PV UUID               MuXBcG-J5qS-442s-xzFO-Nnp5-MCqN-qVecGO

创建pv

pvcreate /dev/vda3  # 上面是/dev/vda2,这儿一般叫/dev/vda3,类推

Physical volume "/dev/vda3" successfully created.

查询物理卷

vgscan

 Reading volume groups from cache.
  Found volume group "openeuler_host-10-190-13-37" using metadata type lvm2

使用新增的物理卷扩展

vgextend openeuler_host-10-190-13-37 /dev/vda3

Volume group "openeuler_host-10-190-13-37" successfully extended

加上扩展的分区

# 根据 df -Th 得到mapper和格式
# 加上需要扩展的大小,一般偏小一点点(约1G),
lvextend -L +149G /dev/mapper/openeuler_host--10--190--13--37-root

lvextend -L +249G /dev/mapper/openeuler_host--10--190--13--37-root

增加分区

# 根据 df -Th 得到mapper和格式
# ext4 使用
resize2fs /dev/mapper/openeuler_host--10--190--13--37-root
# xfs 使用
# xfs_growfs /dev/mapper/centos-root

检查扩容情况

df -h

/dev/mapper/openeuler_host--10--190--13--37-root ext4      193G  6.1G  179G   4% /

home目录挂载空间移动到/

# 1、获取根目录挂载类型 xfs
df -Th 

umount /home

lvremove /dev/mapper/centos-home

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

# 2、修改 /etc/fstab 挂载点

主要命令

fdisk - 磁盘分区

fdisk /dev/vda

[root@ecs-xinxzx-sspywgznl-0023 ~]# fdisk /dev/vda

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3):
First sector (104857600-209715199, default 104857600):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (104857600-209715199, default 209715199):

Created a new partition 3 of type 'Linux' and of size 50 GiB.

Command (m for help): w
The partition table has been altered.
Syncing disks.

lvextend - 扩展逻辑卷空间

-L 指定逻辑卷的大小,单位为“kKmMgGtT”字节

# 例子   
lvextend -L +100M /dev/myvg/mylv   # 如果不知道块设备需要先把pv挂上去 vgextend openeuler_host-10-190-13-37 /dev/vda3

lvextend -L +100 /dev/myvg/mylv /dev/sdb1
lvextend -l +100%FREE  /dev/centos/root

xfs_growfs - 同步xfs文件系统

xfs_growfs /dev/mapper/centos-root

根路径挂载点 mapper

resize2fs - 同步ext4文件系统

resize2fs /dev/mapper/openeuler_host--10--190--13--37-root

根路径挂载点 mapper