lvm磁盘扩容

Posted mark-yi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了lvm磁盘扩容相关的知识,希望对你有一定的参考价值。

LVM实现新挂载磁盘扩容到原有目录

技术图片
 1 #查看磁盘
 2 fdisk -l
 3 #创建pv
 4 pvcreate /dev/sdb
 5 [root@VM-67-49 ~]# pvcreate /dev/sdb 
 6   Physical volume "/dev/sdb" successfully created.
 7 [root@VM-67-49 ~]# pvdisplay 
 8   --- Physical volume ---
 9   PV Name               /dev/sda2
10   VG Name               centos
11   PV Size               29.51 GiB / not usable 3.00 MiB
12   Allocatable           yes 
13   PE Size               4.00 MiB
14   Total PE              7554
15   Free PE               10
16   Allocated PE          7544
17   PV UUID               jfRAJl-pnUs-8lXi-1F37-IX3t-Nq8S-RdtQvq
18    
19   "/dev/sdb" is a new physical volume of "100.00 GiB"
20   --- NEW Physical volume ---
21   PV Name               /dev/sdb
22   VG Name               
23   PV Size               100.00 GiB
24   Allocatable           NO
25   PE Size               0   
26   Total PE              0
27   Free PE               0
28   Allocated PE          0
29   PV UUID               ggiAwS-NizD-1liX-7b5i-fqpR-ZKL8-t8aZqD
30 #查看VG
31 [root@VM-67-49 ~]# vgdisplay 
32   --- Volume group ---
33   VG Name               centos
34   System ID             
35   Format                lvm2
36   Metadata Areas        2
37   Metadata Sequence No  6
38   VG Access             read/write
39   VG Status             resizable
40   MAX LV                0
41   Cur LV                2
42   Open LV               2
43   Max PV                0
44   Cur PV                2
45   Act PV                2
46   VG Size               129.50 GiB
47   PE Size               4.00 MiB
48   Total PE              33153
49   Alloc PE / Size       33153 / 129.50 GiB
50   Free  PE / Size       0 / 0   
51   VG UUID               Y9ksOO-scOb-2VAn-bGUB-vX9U-oVee-mPt59q
52 [root@VM-66-82 ~]# vgextend centos /dev/sdb
53   Volume group "centos" successfully extended
54 [root@VM-66-82 ~]# lvextend -l +100%FREE /dev/mapper/centos-root
55   Size of logical volume centos/root changed from 26.51 GiB (6786 extents) to 126.50 GiB (32385 extents).
56   Logical volume centos/root successfully resized.
57 #创建vg
58 lvextend -l +100%FREE /dev/mapper/centos-root
59 #查看文件系统
60 [root@VM-67-49 ~]# df -T
61 Filesystem              Type     1K-blocks    Used Available Use% Mounted on
62 /dev/mapper/centos-root xfs       27740944 9828872  17912072  36% /
63 devtmpfs                devtmpfs   3994572       0   3994572   0% /dev
64 tmpfs                   tmpfs      4005240       0   4005240   0% /dev/shm
65 tmpfs                   tmpfs      4005240  403684   3601556  11% /run
66 tmpfs                   tmpfs      4005240       0   4005240   0% /sys/fs/cgroup
67 /dev/sda1               xfs         508588  191684    316904  38% /boot
68 #是添加的磁盘生效
69 [root@VM-67-49 ~]# xfs_growfs /dev/mapper/centos-root
70 meta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=1734656 blks
71          =                       sectsz=512   attr=2, projid32bit=1
72          =                       crc=0        finobt=0 spinodes=0
73 data     =                       bsize=4096   blocks=6938624, imaxpct=25
74          =                       sunit=0      swidth=0 blks
75 naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
76 log      =internal               bsize=4096   blocks=3388, version=2
77          =                       sectsz=512   sunit=0 blks, lazy-count=1
78 realtime =none                   extsz=4096   blocks=0, rtextents=0
79 data blocks changed from 6938624 to 33162240
80 #验证
81 Filesystem               Size  Used Avail Use% Mounted on
82 /dev/mapper/centos-root  127G  9.4G  118G   8% /
83 devtmpfs                 3.9G     0  3.9G   0% /dev
84 tmpfs                    3.9G     0  3.9G   0% /dev/shm
85 tmpfs                    3.9G  395M  3.5G  11% /run
86 tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
87 /dev/sda1                497M  188M  310M  38% /boot
View Code

 

以上是关于lvm磁盘扩容的主要内容,如果未能解决你的问题,请参考以下文章

VMware基于LVM实现根目录磁盘扩容

关于linux中的磁盘扩容和LVM的疑问

Linux 使用LVM动态调整磁盘大小/扩容

lvm磁盘扩容

Linux lvm 卷扩容-2022-5-20

Linux----LVM扩容磁盘空间