|
疑惑
最近在反复搭建ceph集群过程中,总是遇到osd创建不成功的问题,疑似硬盘残留信息,排查中引出了很多陌生的命令,比如vgremove等,于是打算重新了解这部分。
LVM是什么?
逻辑卷管理器(LVM,Logical Volume Manager)是一种把硬盘空间分配成逻辑卷的方法。
看到定义可能还比较懵,不妨结合场景:
有一块系统盘空间随着时间推移容量需要扩容该怎么做?
- 这时候使用LVM就比较方便了,它可以弹性的调整文件系统的容量,可以整合多个物理分区在一起,让这些分区看起来像是一个磁盘一样。通俗理解就是它可以将很多硬盘/分区全部拿过来作为一个资源池,然后自己再随意划分成逻辑层面的分区,那么这个分区后期进行扩容缩容删除就比较方便了!
复制代码 LVM相关概念
1、Physical Volume,PV,物理卷
- [root@node3 ~]# fdisk /dev/sdb
- Welcome to fdisk (util-linux 2.23.2).
- Changes will remain in memory only, until you decide to write them.
- Be careful before using the write command.
- Device does not contain a recognized partition table
- Building a new DOS disklabel with disk identifier 0x172f2548.
- Command (m for help): p ###输入 p 查看分区情况
- Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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: dos
- Disk identifier: 0x172f2548
- Device Boot Start End Blocks Id System
- Command (m for help): n ###输入 n 创建新分区
- Partition type:
- p primary (0 primary, 0 extended, 4 free)
- e extended
- Select (default p): p ### 默认是 p ,创建主分区,视情况而定
- Partition number (1-4, default 1): 1 ###这里做第一块主分区
- First sector (2048-20971519, default 2048):
- Using default value 2048
- Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519):
- Using default value 20971519
- Partition 1 of type Linux and of size 10 GiB is set
- Command (m for help): p ###再次输入 p 查看分区情况
- Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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: dos
- Disk identifier: 0x172f2548
- Device Boot Start End Blocks Id System
- /dev/sdb1 2048 20971519 10484736 83 Linux
- Command (m for help): w ###最后输入 w 保存从sdb分出来的sdb1
- The partition table has been altered!
- Calling ioctl() to re-read partition table.
- Syncing disks.
复制代码fdisk -l查看是否分区成功
- [root@node3 ~]# fdisk -l
- Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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: dos
- Disk identifier: 0x172f2548
- Device Boot Start End Blocks Id System
- /dev/sdb1 2048 20971519 10484736 83 Linux
复制代码可以看到实际分区Id字段为83,使用时需要通过 fdisk 命令将Id字段调整为8e(LVM 的标识符),再经过 pvcreate 命令将它转为 LVM 最底层的物理卷(PV),之后这些PV才能够被利用
[code][root@node3 ~]# fdisk /dev/sdbWelcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them.Be careful before using the write command.Command (m for help): t ###输入 t 修改分区类型Selected partition 1Hex code (type L to list all codes): L ###输入 L 列出所有分区类型 0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT- 2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT- 3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT- 4 FAT16 |
|