Linux文件系统 -- LVM

LVM

LVM(Logical Volume Manager)逻辑卷管理,底层是多块磁盘拼凑起来的,跟raid很像。LVM最大特点是便于动态调整磁盘容量

/boot分区用于存放引导文件,不能应用LVM机制

LVM机制的基本概念:

  • 物理卷(Physical Volume,PV): 这是实际硬盘驱动器或用fdisk等工具建立的普通分区,包括许多默认4M大小的PE。可以将一个或多个物理卷组合成一个卷组

  • 卷组(Volume Group,VG): 由一个或多个物理卷组成,是LVM中的逻辑存储池。卷组是LVM的核心,逻辑卷从卷组分配空间

  • 逻辑卷(Logical Volume,LV): 逻辑卷相当于传统硬盘上的分区,但更加灵活。它是从卷组中分配的逻辑块设备,可以被格式化并用作文件系统

  • 物理区域(Physical Extent,PE): 物理卷被分成物理区域,通常是4MB或8MB的大小。这些物理区域是LVM中分配和管理存储空间的最小单位

LVM的创建流程

  1. 创建物理卷(PV): 将硬盘或分区添加到LVM中作为物理卷

    [root@localhost tt]# pvcreate /dev/sdc
      Physical volume "/dev/sdc" successfully created.
    [root@localhost tt]# pvscan
      PV /dev/sda2   VG centos          lvm2 [<19.00 GiB / 0    free]
      PV /dev/sdc                       lvm2 [50.00 GiB]
      Total: 2 [<69.00 GiB] / in use: 1 [<19.00 GiB] / in no VG: 1 [50.00 GiB]
    
    
  2. 创建卷组(VG): 将一个或多个物理卷组合成卷组

    [root@localhost tt]# vgcreate mail_store /dev/sdc
      Volume group "mail_store" successfully created
    [root@localhost tt]# vgscan
      Reading volume groups from cache.
      Found volume group "centos" using metadata type lvm2
      Found volume group "mail_store" using metadata type lvm2
    
    
  3. 创建逻辑卷(LV): 从卷组中分配逻辑卷

    [root@localhost tt]# lvcreate -L 40G -n chen_mail mail_store
      Logical volume "chen_mail" created.
    [root@localhost tt]# lvscan
      ACTIVE            '/dev/centos/swap' [2.00 GiB] inherit
      ACTIVE            '/dev/centos/root' [<17.00 GiB] inherit
      ACTIVE            '/dev/mail_store/chen_mail' [40.00 GiB] inherit
    
    
  4. 格式化逻辑卷: 类似于在传统硬盘上创建文件系统

    [root@localhost tt]# mkfs.xfs /dev/mail_store/chen_mail 
    meta-data=/dev/mail_store/chen_mail isize=512    agcount=4, agsize=2621440 blks
             =                       sectsz=512   attr=2, projid32bit=1
             =                       crc=1        finobt=0, sparse=0
    data     =                       bsize=4096   blocks=10485760, imaxpct=25
             =                       sunit=0      swidth=0 blks
    naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
    log      =internal log           bsize=4096   blocks=5120, version=2
             =                       sectsz=512   sunit=0 blks, lazy-count=1
    realtime =none                   extsz=4096   blocks=0, rtextents=0
    
    
  5. 挂载逻辑卷: 将逻辑卷挂载到文件系统的特定目录

    [root@localhost tt]# mount /dev/mail_store/chen_mail /test
    [root@localhost tt]# vim /etc/fstab 
    [root@localhost tt]# tail -n 1 /etc/fstab 
    /dev/mail_store/chen_mail /test xfs defaults 0 0
    
    

命令:

功能物理卷卷组逻辑卷
scan扫描pvscanvgscanlvscan
create建立pvcreatevgcreatelvcreate
display显示pvdisplayvgdisplaylvdisplay
remove删除pvremovevgremovelvremove
extend扩展vgextendlvextend
reduce减少vgreducelvresize

扩容

# 扩容
lvextend -L +5G /dev/mail_store/chen_mail
# 让Linux内核重新识别lv的大小
xfs_growfs /dev/mail_store/chen_mail
  • 19
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值