02_Linux系统管理_基础知识_高级文件系统管理_逻辑卷管理(LVM)

  • 环境
    • 虚拟机:VMware-10.0.7 build-2844087
    • Linux系统:CentOS 6.8
    • 远程工具:Xshell 6 (Build 0197)

02_Linux系统管理_基础知识_高级文件系统管理_逻辑卷管理(LVM)

一、逻辑卷简介

  • 相关概念
    • LVM(Logical Volume Manager 简称):逻辑卷管理
    • 物理卷(PV,Physical Volume):真正的物理硬盘或分区
    • 卷组(VG,Volume Group):
      • 多个物理卷合起来就是卷组
      • 卷组可以是同一个硬盘的不同分区,也可以是不同硬盘上的不同分区
      • 卷组就像一块逻辑硬盘
    • 逻辑卷(LV,Logical Volume):
      • 卷组是一块逻辑硬盘,必须分区后才可以使用,这个分区称之为逻辑卷
      • 逻辑卷可以格式化和写入数据,我们把逻辑卷想象成分区

二、LVM建立步骤

  • LVM建立步骤
    • 首先把物理硬盘分区,当然也可以是整块硬盘
    • 然后把分区建成物理卷(PV),也可以把整个分区建成物理卷
    • 接下来把物理卷整合成卷组(VG)
      • 卷组已经可以动态调整大小
      • 可以把物理分区加入卷组,也可以把物理分区从卷组中删除
    • 最后是把卷组划分成为逻辑卷(LV)
      • 逻辑卷也可以动态调整大小
      • 逻辑卷可以想象成分区,需要格式化和挂载

三、物理卷管理

3.1、硬盘分区

  • 创建方式:fdisk 命令创建分区

  • 注意事项:

    • 分区系统ID默认是83

    • LVM分区系统ID是8e

    • 创建完分区要修改系统ID为8e

 

  • 3.1.1、创建扩展分区 sdb2 、创建三个逻辑分区 sdb5、sdb6、sdb7
[root@localhost ~]# fdisk /dev/sdb
...
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
28 heads, 40 sectors/track, 37449 cylinders
Units = cylinders of 1120 * 512 = 573440 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008e6ae

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        3746     2097740   83  Linux
/dev/sdb2            3747       37449    18873680    5  Extended
/dev/sdb5            3747        7492     2097740   83  Linux
/dev/sdb6            7493       11238     2097740   83  Linux
/dev/sdb7           11239       14984     2097740   83  Linux

Command (m for help): 
  • 3.1.2、修改三个逻辑分区 sdb5、sdb6、sdb7 系统ID号为8e
Command (m for help): t
Partition number (1-7): 5
Hex code (type L to list codes): 8e
Changed system type of partition 5 to 8e (Linux LVM)

Command (m for help): t
Partition number (1-7): 6
Hex code (type L to list codes): 8e
Changed system type of partition 6 to 8e (Linux LVM)

Command (m for help): t
Partition number (1-7): 7
Hex code (type L to list codes): 8e
Changed system type of partition 7 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
28 heads, 40 sectors/track, 37449 cylinders
Units = cylinders of 1120 * 512 = 573440 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008e6ae

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        3746     2097740   83  Linux
/dev/sdb2            3747       37449    18873680    5  Extended
/dev/sdb5            3747        7492     2097740   8e  Linux LVM
/dev/sdb6            7493       11238     2097740   8e  Linux LVM
/dev/sdb7           11239       14984     2097740   8e  Linux LVM
Command (m for help): w   
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
  •  3.1.3、重启系统,reboot

        说明:目前系统内核所使用的依然是旧分区表,想要使用LVM,必须重启系统。如果不重启系统,创建物理卷(PV)时,会提示找不到磁盘分区:Device /dev/sdb5 not found (or ignored by filtering).

3.2、建立物理卷(PV)

  • 创建方法:
    • 图形化界面建立物理卷(首次安装 Linux 系统时所采用的方式)
    • 命令方式建立物理卷(本文采用)
  • 创建物理卷:pvcreate
    • 整块磁盘:[root@localhost ~]# pvcreate /dev/sdb
    • 某个分区:[root@localhost ~]# pvcreate /dev/sdb5(本文采用)
  • 查看物理卷:
    • pvscan:简要信息
    • pvdisplay:详细信息(常用)
  • 3.2.1、创建物理卷 
[root@localhost ~]# pvcreate /dev/sdb5
  Physical volume "/dev/sdb5" successfully created
[root@localhost ~]# pvcreate /dev/sdb6
  Phys
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

走向运维的老男孩

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值