|
|
|
@ -3,7 +3,7 @@
|
|
|
|
|
[lvm逻辑卷管理图](http://upload.wikimedia.org/wikipedia/commons/thumb/e/e6/Lvm.svg/620px-Lvm.svg.png)
|
|
|
|
|
|
|
|
|
|
| 用途 | PV | VG | LV |
|
|
|
|
|
| :--: | :--: | :--: |
|
|
|
|
|
| :------: | :------: | :------: |
|
|
|
|
|
| 搜寻 (scan) | pvscan | vgscan | lvscan |
|
|
|
|
|
| 创建 (create) | pvcreate | vgcreate | lvcreate |
|
|
|
|
|
| 列出 (display) | pvdisplay | vgdisplay | lvdisplay |
|
|
|
|
@ -53,7 +53,7 @@ Common options for lvm:
|
|
|
|
|
|
|
|
|
|
## 实例
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
```bash
|
|
|
|
|
pvcreate /dev/hda{6,7,8,9} # 在/dev/hda6-9分区创建pv
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
@ -152,7 +152,7 @@ FAQ:(Frequently Asked Question)
|
|
|
|
|
|
|
|
|
|
## LVM拉伸逻辑卷
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
```bash
|
|
|
|
|
(可在线扩容,无需卸载逻辑卷)
|
|
|
|
|
vgdisplay或vgs # 确保VG中有足够的空闲空间,通过以下指令查询即可
|
|
|
|
|
lvextend -L +5G /dev/vg01/lv01 # 扩充逻辑卷,增大5G的大小
|
|
|
|
@ -166,7 +166,7 @@ df -hT # 查看更新后文件系统
|
|
|
|
|
|
|
|
|
|
## LVM缩小逻辑卷
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
```bash
|
|
|
|
|
(在实际运作当中很少使用且这种操作及其危险,容易导致数据丢失)备注:逻辑卷的缩小必须是离线操作,要卸载逻辑卷;xfsdump可备份xfs系统格式
|
|
|
|
|
umount /dev/vg01/lv01 # 卸载已经挂载的逻辑卷
|
|
|
|
|
e2fsck -f /dev/vg01/lv01 # 强制检测文件系统信息
|
|
|
|
@ -180,7 +180,7 @@ mount /dev/vg01/lv01 /mnt # 挂载
|
|
|
|
|
|
|
|
|
|
## LVM拉伸卷组
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
```bash
|
|
|
|
|
pvcreate /dev/sdd # 创建新的物理卷
|
|
|
|
|
vgextend vg01 /dev/sdd # 向vg01卷组中添加物理卷/dev/sdd
|
|
|
|
|
vgs, vgdisplay # 查看卷组信息
|
|
|
|
@ -188,7 +188,7 @@ vgs, vgdisplay # 查看卷组信息
|
|
|
|
|
|
|
|
|
|
## LVM缩小卷组
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
```bash
|
|
|
|
|
vgreduce vg01 /dev/sdd # 将一个PV从指定卷组中移除
|
|
|
|
|
vgdisplay或vgs # 查看缩小后的卷组大小
|
|
|
|
|
```
|
|
|
|
@ -268,7 +268,7 @@ Labels on physical volume "/dev/sdb2" successfully wiped
|
|
|
|
|
|
|
|
|
|
## LVM(逻辑卷管理)
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
```bash
|
|
|
|
|
概念介绍:
|
|
|
|
|
LVM (logical volume Manager)逻辑卷管理通过将底层物理硬盘抽象封装起来,以逻辑卷的形式表现给上层系统,逻辑卷的大小可以动态调整的而且不会丢失数据。新加入的硬盘也不会改变现有上层的逻辑卷
|
|
|
|
|
|
|
|
|
@ -298,7 +298,7 @@ FAQ:(Frequently Asked Question)
|
|
|
|
|
|
|
|
|
|
## LVM拉伸逻辑卷
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
```bash
|
|
|
|
|
(可在线扩容,无需卸载逻辑卷)
|
|
|
|
|
vgdisplay或vgs # 确保VG中有足够的空闲空间,通过以下指令查询即可
|
|
|
|
|
lvextend -L +5G /dev/vg01/lv01 # 扩充逻辑卷,增大5G的大小
|
|
|
|
@ -311,7 +311,7 @@ df -hT # 查看更新后文件系统
|
|
|
|
|
|
|
|
|
|
## LVM缩小逻辑卷
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
```bash
|
|
|
|
|
(在实际运作当中很少使用且这种操作及其危险,容易导致数据丢失)备注:逻辑卷的缩小必须是离线操作,要卸载逻辑卷
|
|
|
|
|
umount /dev/vg01/lv01 # 卸载已经挂载的逻辑卷
|
|
|
|
|
e2fsck -f /dev/vg01/lv01 # 强制检测文件系统信息
|
|
|
|
@ -325,7 +325,7 @@ mount /dev/vg01/lv01 /mnt # 挂载
|
|
|
|
|
|
|
|
|
|
## LVM拉伸卷组
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
```bash
|
|
|
|
|
pvcreate /dev/sdd # 创建新的物理卷
|
|
|
|
|
vgextend vg01 /dev/sdd # 向vg01卷组中添加物理卷/dev/sdd
|
|
|
|
|
vgs, vgdisplay # 查看卷组信息
|
|
|
|
@ -333,7 +333,7 @@ vgs, vgdisplay # 查看卷组信息
|
|
|
|
|
|
|
|
|
|
## LVM缩小卷组
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
```bash
|
|
|
|
|
vgreduce vg01 /dev/sdd # 将一个PV从指定卷组中移除
|
|
|
|
|
vgdisplay或vgs # 查看缩小后的卷组大小
|
|
|
|
|
```
|
|
|
|
|