LVM扩容操作

 首先lsblk查看磁盘是否有剩余空间

如果还有剩余的空间,需要进行新的分区

1.使用命令:fdisk /dev/sda  让硬盘进入分区模式 

[root@jt-gnode-v100-18 ~]#  fdisk /dev/sda
Welcome to fdisk (util-linux 2.37.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.

2. p:显示当前分区列表


Command (m for help): p

Disk /dev/sda: 446.1 GiB, 478998953984 bytes, 935544832 sectors
Disk model: AVAGO           
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes
Disklabel type: dos
Disk identifier: 0x244f7946

Device     Boot     Start       End  Sectors Size Id Type
/dev/sda1  *         2048   2099199  2097152   1G 83 Linux
/dev/sda2         2099200  56623103 54523904  26G 8e Linux LVM
/dev/sda3       935413760 935544831   131072  64M  c W95 FAT32 (LBA)

3.n:添加新的分区 

Command (m for help): n
Partition type
   p   primary (3 primary, 0 extended, 1 free)
   e   extended (container for logical partitions)

 4.p:选择主分区,其余回车默认

Select (default e): p

Selected partition 4
First sector (56623104-935413759, default 56623104): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (56623104-935413759, default 935413759): 

Created a new partition 4 of type 'Linux' and of size 419 GiB.

 5.p:查看分区列表,查看新的分区

Command (m for help): p
Disk /dev/sda: 446.1 GiB, 478998953984 bytes, 935544832 sectors
Disk model: AVAGO           
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes
Disklabel type: dos
Disk identifier: 0x244f7946

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sda1  *         2048   2099199   2097152    1G 83 Linux
/dev/sda2         2099200  56623103  54523904   26G 8e Linux LVM
/dev/sda3       935413760 935544831    131072   64M  c W95 FAT32 (LBA)
/dev/sda4        56623104 935413759 878790656  419G 83 Linux

Partition table entries are not in disk order.

 6.w:保存

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

 这时,我们的新分区有了,之后把空间分配

[root@jt ~]#  partprobe /dev/sda          #重新扫描分区表
[root@jt ~]#  pvcreate /dev/sda4          #创建pv
  Physical volume "/dev/sda4" successfully created.
[root@jt ~]#  vgextend rootvg /dev/sda4   #rootvg:卷组名字,将/dev/sda1扩展到rootvg中
  Volume group "rootvg" successfully extended
[root@jt ~]#  vgs                         #查看vg
  VG     #PV #LV #SN Attr   VSize    VFree   
  rootvg   2   4   0 wz--n- <445.04g <419.04g
[root@jt ~]#  lvextend -L200G /dev/rootvg/root       #分200G给/root
  Size of logical volume rootvg/root changed from <11.00 GiB (2815 extents) to 200.00 GiB (51200 extents).
  Logical volume rootvg/root successfully resized.
[root@jt ~]#  lvextend -l +100%FREE /dev/rootvg/var  #其余全部分给/var
  Size of logical volume rootvg/var changed from 5.00 GiB (1280 extents) to <235.04 GiB (60169 extents).
  Logical volume rootvg/var successfully resized.  
[root@jt ~]#  xfs_growfs /dev/rootvg/var             #使用df -Th,根据文件系统选择扩容
meta-data=/dev/mapper/rootvg-var isize=512    agcount=4, agsize=327680 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1    bigtime=1 inobtcount=0
data     =                       bsize=4096   blocks=1310720, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 1310720 to 61613056
[root@jt ~]#  xfs_growfs /dev/rootvg/root           #df -Th根据文件系统扩容  
meta-data=/dev/mapper/rootvg-root isize=512    agcount=4, agsize=720640 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1    bigtime=1 inobtcount=0
data     =                       bsize=4096   blocks=2882560, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 2882560 to 5242880

最后lsblk查看即可

lvm缩容操作

1.首先取消挂载,不然会造成数据丢失

2.其次缩容有风险,一般是不会让缩容的,这里就略过了,而且xfs系统是不支持缩容的,只有etx4系统支持缩容

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值