lvm扩张与收缩小结

本文介绍了LVM(逻辑卷管理)的结构,包括磁盘、分区、PV、VG、LV和文件系统的层级关系。详细阐述了如何进行LVM的扩张和收缩操作,扩张时需先扩展LV再扩展文件系统,而收缩时则需先缩小文件系统再缩小LV,并给出了具体的命令示例。此外,提到了创建PV所需分区的步骤和查看分区信息的命令。
摘要由CSDN通过智能技术生成

lvm结构:

磁盘 => 分区 => PV => VG => LV => 文件系统


扩张:

先扩LV再扩文件系统

lvextend -L +100M /dev/vg1/lv1 逻辑卷的大小增加100M

resize2fs /dev/vg1/lv1 文件系统增到逻辑卷的大小


收缩:

先减文件系统再减LV(注意顺序)

umount /dev/vg1/lv1

e2fsck -f /dev/vg1/lv1

resize2fs /dev/vg1/lv1 100M 减小文件系统到100M

lvreduce -L 100M /dev/vg1/lv1 减小逻辑卷到100M

mount -a



创建PV所需分区:

[root@rhel6-client ~]# fdisk -cul /dev/sda


Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 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 identifier: 0x000cb393

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      411647      204800   83  Linux
/dev/sda2          411648    41371647    20480000   83  Linux
/dev/sda3        41371648    45467647     2048000   82  Linux swap / Solaris
[root@rhel6-client ~]# fdisk -cu /dev/sda

Command (m for help): p

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 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 identifier: 0x000cb393

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      411647      204800   83  Linux
/dev/sda2          411648    41371647    20480000   83  Linux
/dev/sda3        41371648    45467647     2048000   82  Linux swap / Solaris

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Selected partition 4
First sector (45467648-209715199, default 45467648):
Using default value 45467648
Last sector, +sectors or +size{K,M,G} (45467648-209715199, default 209715199):
Using default value 209715199

Command (m for help): p

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 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 identifier: 0x000cb393

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      411647      204800   83  Linux
/dev/sda2          411648    41371647    20480000   83  Linux
/dev/sda3        41371648    45467647     2048000   82  Linux swap / Solaris
/dev/sda4        45467648   209715199    82123776    5  Extended

Command (m for help): n
First sector (45469696-209715199, default 45469696):
Using default value 45469696
Last sector, +sectors or +size{K,M,G} (45469696-209715199, default 209715199): +100M

Command (m
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值