设为首页 加入收藏

TOP

逻辑卷管理lvm(一)
2017-10-12 18:05:32 】 浏览:10821
Tags:逻辑 管理 lvm

逻辑卷管理LVM

一 创建逻辑卷

1准备分区或硬盘

这里使用/dev/sdb、/dev/sdc两块硬盘和/dev/sda9、/dev/sda10两个分区,大小都为1G,磁盘有限,我也不想这么抠的。

添加分区/dev/sda9、/dev/sda10

[root@centos7 ~]# fdisk /dev/sda

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.

Command (m for help): n
All primary partitions are in use
Adding logical partition 9
First sector (31885312-41943039, default 31885312):
Using default value 31885312
Last sector, +sectors or +size{K,M,G} (31885312-41943039, default 41943039): +1G
Partition 9 of type Linux and of size 1 GiB is set

注意,要修改分区类型为Linux LVM

Command (m for help): t
Partition number (1-9, default 9): 8e
Partition number (1-9, default 9): 9
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help):

同样的方法创建/dev/sda10。

[root@centos7 ~]# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda9 8:9 0 1G 0 part
└─sda10 8:10 0 1G 0 part
sdb 8:16 0 1G 0 disk
sdc 8:32 0 1G 0 disk

2 创建PV(物理卷)

命令格式为:pvcreate DEVICE,可以一次创建一个设备,也可以一次创建多个设备。

查看物理卷命令:pvdisplay(查看详细信息)、pvs(查看简易信息)

[root@centos7 ~]# pvcreate /dev/sda9

Physical volume "/dev/sda9" successfully created.
[root@centos7 ~]# pvcreate /dev/sda10 /dev/sdb /dev/sdc
Physical volume "/dev/sda10" successfully created.
Physical volume "/dev/sdb" successfully created.
Physical volume "/dev/sdc" successfully created.

查看物理卷,看到已经成功创建。

[root@centos7 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda10 lvm2 --- 1.00g 1.00g
/dev/sda9 lvm2 --- 1.00g 1.00g
/dev/sdb lvm2 --- 1.00g 1.00g
/dev/sdc lvm2 --- 1.00g 1.00g

3 创建卷组(VG)

命令格式为:vgcreate -s PE VGNAME(vg名) DEVICE(设备名)

-s :指定物理扩展块大小 既就是PE的大小

查看命令:vgs、vgdisplay

[root@centos7 ~]# vgcreate -s 16M vg0 /dev/sda9 /dev/sda10 /dev/sdb /dev/sdc
Volume group "vg0" successfully created

查看一下

[root@centos7 ~]# vgs

VG #PV #LV #SN Attr VSize VFree
vg0 4 0 0 wz--n- 3.94g 3.94g

再来看下详细信息

[root@centos7 ~]# vgdisplay

--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 4
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 4
Act PV 4
VG Size 3.94 GiB
PE Size 16.00 MiB
Total PE 252
Alloc PE / Size 0 / 0
Free PE / Size 252 / 3.94 GiB
VG UUID qmoIMg-5wQR-GKCS-dpq9-HLrt-zVIi-JBC9ZX

一切都复合预期,大小约为4G,正好是两个分区和两个硬盘之和。

4创建逻辑卷(LV)

命令格式为:lvcreate -n LVNAME(指定LV名) -L SIZE(指定LV的大小) vg0(要使用的VG)

-l 指定PE 大小

查看命令(类似PV、VG):lvs、lvdisplay

[root@centos7 ~]# lvcreate -n lv0 -L 3G vg0

Logical volume "lv0" created.

创建成功,查看一下

[root@centos7 ~]# lvs

LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv0 vg0 -wi-a----- 3.00g

再看下详细信息

[root@centos7 ~]# lvdisplay

--- Logical volume ---
LV Path /dev/vg0/lv0
LV Name lv0
VG Name vg0
LV UUID 622i7m-uy6s-3nZI-8xSb-sxrR-cZzz-C9pwkd
LV Write Access read/write
LV Creation host, time centos7.3.loacl, 2017-04-25 16:25:13 +0800
LV Status available
# open 0
LV Size 3.00 GiB
Current LE 192
Segments 4
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0

可以确定已经成功创建。

现在就可以把/dev/vg0/lv0当做一块硬盘使用了。

现在看一下磁盘信息,已经发生了变化。

[root@centos7 ~]# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk
sda 8:0 0 20G 0 disk
├─sda9 8:9 0 1G 0 part
│ └─vg0-lv0 253:0 0 3G 0 lvm
└─sda10 8:10 0 1G 0 part
└─vg0-lv0 253:0
首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇ngix_http_stub_status_module 下一篇linux批量删除

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目