centos从磁盘阵列扩容home目录

该操作展示了在Linux环境中使用fdisk、pvcreate、vgextend、lvextend和xfs_growfs命令来扩展逻辑卷的过程。首先,通过pvcreate创建物理卷/dev/sdb,然后将其添加到名为centos的卷组中,接着扩展/home逻辑卷并更新文件系统大小,最终成功增加了/home分区的可用空间。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

操作步骤

fdisk -l

pvcreate /dev/sdb

pvdisplay    记录VG Name

vgextend centos_{} /dev/sdb
#分配100%的空间到home下
lvextend -l +100%FREE /dev/mapper/centos_{}-home
#格式化
xfs_growfs /dev/mapper/centos_{}-home

操作示例

[root@node12234 ~]# df -H
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   54G  1.5G   53G   3% /
devtmpfs                  34G     0   34G   0% /dev
tmpfs                     34G     0   34G   0% /dev/shm
tmpfs                     34G  8.9M   34G   1% /run
tmpfs                     34G     0   34G   0% /sys/fs/cgroup
/dev/sda2                1.1G  152M  912M  15% /boot
/dev/mapper/centos-home  2.2T  1.9T  262G  88% /home
tmpfs                    6.8G     0  6.8G   0% /run/user/0
[root@node12234 ~]# fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sda: 2199.0 GB, 2199023255552 bytes, 4294967296 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: gpt
Disk identifier: B09BCD38-7131-4441-9A50-B522492FAE7B


#         Start          End    Size  Type            Name
 1         2048         4095      1M  BIOS boot       
 2         4096      2101247      1G  Microsoft basic 
 3      2101248   4294965247      2T  Linux LVM       

Disk /dev/sdb: 10995.1 GB, 10995116277760 bytes, 21474836480 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 /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 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 /dev/mapper/centos-swap: 33.8 GB, 33822867456 bytes, 66060288 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 /dev/mapper/centos-home: 2110.4 GB, 2110431166464 bytes, 4121935872 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

[root@node12234 ~]# pvcreate /dev/sdb
  Physical volume "/dev/sdb" successfully created.
[root@node12234 ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               centos
  PV Size               <2.00 TiB / not usable 0   
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              524031
  Free PE               1
  Allocated PE          524030
  PV UUID               LvOdeq-j1np-2Ze6-6yMG-THAh-ivkj-tC12AW
   
  "/dev/sdb" is a new physical volume of "10.00 TiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb
  VG Name               
  PV Size               10.00 TiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               s22EJr-PL3M-qeWc-ltfj-1uCe-b210-tkwkcV
   
[root@node12234 ~]# vgextend centos /dev/sdb
  Volume group "centos" successfully extended
[root@node12234 ~]# lvextend -l +100%FREE /dev/mapper/centos-home
  Size of logical volume centos/home changed from <1.92 TiB (503166 extents) to <11.92 TiB (3124606 extents).
  Logical volume centos/home successfully resized.
[root@node12234 ~]# xfs_growfs /dev/mapper/centos-home
meta-data=/dev/mapper/centos-home isize=512    agcount=4, agsize=128810496 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=515241984, imaxpct=5
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=251583, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 515241984 to 3199596544
[root@node12234 ~]# df -H
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   54G  1.5G   53G   3% /
devtmpfs                  34G     0   34G   0% /dev
tmpfs                     34G     0   34G   0% /dev/shm
tmpfs                     34G  8.9M   34G   1% /run
tmpfs                     34G     0   34G   0% /sys/fs/cgroup
/dev/sda2                1.1G  152M  912M  15% /boot
/dev/mapper/centos-home   14T  1.9T   12T  15% /home
tmpfs                    6.8G     0  6.8G   0% /run/user/0
[root@node12234 ~]# 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值