LVM

解释:lvm的全名logical volume manager.逻辑滚动管理员。lvm的做法是将几个实体的partitions(或disk)透过软件组合成一块看起来独立的大磁盘(vg),然后将这块大磁盘分割成分割槽(LV),最后就可以挂载使用了。

PV,physical volume实体滚动条

partition需要调成系统标识符(system ID)是8e(LVM的标识符),然后再经过pvcreate将LVM最底层的实体滚动条(PV),之后才能将这些PV加以利用!fdisk去调整system
ID。

VG,Volume Group滚动条群组

每个vg最多能包含65534个PE,如果使用lvm预设的参数,则一个vg最大可达256GB!pv整合成这个VG就是lvm的大磁盘!

PE physical
extend,实体延申区块

lvm预设使用4MB的PE区块,而lvm的vg最多含65534个PE,因此预设LVM VG会有4m*65534/(1024m/g)=256g。PE是lvm最小的存储区快,也就是档案资料都是由写入PE来处理的,所以调整PE会影响VG的最大容量!

实验操作

[root@localhost ~]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor
Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier
0x6abd09e9.

Changes will remain in memory only, until you decide to
write them.

After that, of course, the previous content won’t be
recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be
corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It’s strongly
recommended to

     switch off

the mode (command ‘c’) and change display units to

     sectors

(command ‘u’).

Command (m for help): p

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x6abd09e9

Device Boot Start End Blocks
Id System

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-652, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-652, default
652): 100M

Command (m for help): p

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x6abd09e9

Device Boot Start End Blocks
Id System

/dev/sdb1
1 100 803218+
83 Linux

Command (m for help): t

Selected partition 1

Hex code (type L to list codes): 8e

Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x6abd09e9

Device Boot Start End Blocks
Id System

/dev/sdb1
1 100 803218+
8e Linux LVM

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 2

First cylinder (101-652, default 101):

Using default value 101

Last cylinder, +cylinders or +size{K,M,G} (101-652,
default 652): 100M

Value out of range.

Last cylinder, +cylinders or +size{K,M,G} (101-652,
default 652): +100M

Command (m for help): p

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x6abd09e9

Device Boot Start End Blocks
Id System

/dev/sdb1
1 100 803218+
8e Linux LVM

/dev/sdb2
101 114 112455
83 Linux

Command (m for help): t

Partition number (1-4): 2

Hex code (type L to list codes): 8e

Changed system type of partition 2 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x6abd09e9

Device Boot Start End Blocks
Id System

/dev/sdb1
1 100 803218+
8e Linux LVM

/dev/sdb2
101 114 112455
8e Linux LVM

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

先将/dev/sdb划了两个100m的区,并改成lvm模式

1)、创建pv

[root@localhost ~]# pvcreate /dev/sdb1

dev_is_mpath:
failed to get device for 8:17

Physical volume
“/dev/sdb1” successfully created

[root@localhost ~]# pvscan

PV /dev/sdb1 lvm2 [784.39 MiB]

Total: 1 [784.39
MiB] / in use: 0 [0 ] / in no VG: 1
[784.39 MiB]

[root@localhost ~]# pvdisplay

“/dev/sdb1” is a new physical volume of “784.39 MiB”

— NEW Physical
volume —

PV Name /dev/sdb1

VG Name

PV Size 784.39 MiB

Allocatable NO

PE Size 0

Total PE 0

Free PE 0

Allocated PE 0

PV UUID
sfa1lE-S41b-eRc1-iZV7-XXXA-kqez-niV1uY

2)、创建vg(卷组),来管理pv

[root@localhost ~]# vgscan

Reading all
physical volumes. This may take a
while…

No volume groups
found

[root@localhost ~]# vgcreate vgdata /dev/sdb1 创建vgdata,并将/dev/sdb1加入卷组

Volme group
“vgdata” successfully created

[root@localhost ~]# vgscan

Reading all
physical volumes. This may take a
while…

Found volume
group “vgdata” using metadata type lvm2

[root@localhost ~]# vgdisplay

— Volume group

VG Name vgdata

System ID

Format lvm2

Metadata
Areas 1

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 1

Act PV 1

VG Size 780.00 MiB

PE Size 4.00 MiB

Total PE 195

Alloc PE /
Size 0 / 0

Free PE / Size 195 / 780.00 MiB

VG UUID
WIvIdv-QAO9-z5hk-CXfb-lCVP-BN9b-5fmCBH

3)创建lv

[root@localhost ~]# lvscan 没有就这样

[root@localhost ~]# lvcreate -L 100m -n lvData vgdata -L大小 -n名字

Logical volume
“lvData” created

[root@localhost ~]# lvdisplay

— Logical
volume —

LV Path /dev/vgdata/lvData

LV Name lvData

VG Name vgdata

LV UUID
sP5EZw-LsoM-pbXl-8NqV-2oHN-2wDS-LoulYS

LV Write
Access read/write

LV Creation host,
time localhost.localdomain, 2019-11-07 01:14:06 +0800

LV Status available

open 0

LV Size 100.00 MiB

Current LE 25

Segments 1

Allocation inherit

Read ahead
sectors auto

  • currently set
    to 256

Block device 253:0

格式化

[root@localhost ~]# mkfs.ext4 /dev/vgdata/lvData

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

Stride=0 blocks, Stripe width=0 blocks

25688 inodes, 102400 blocks

5120 blocks (5.00%) reserved for the super user

First data block=1

Maximum filesystem blocks=67371008

13 block groups

8192 blocks per group, 8192 fragments per group

1976 inodes per group

Superblock backups stored on blocks:

      8193,

24577, 40961, 57345, 73729

Writing inode tables: done

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting
information: done

This filesystem will be automatically checked every 39
mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

挂载

[root@localhost ~]# mkdir /LVM

[root@localhost /]# mount /dev/vgdata/lvData /LVM

开机自动挂载

vi /etc/fstab

#################

总结

先创建pv,物理卷,再创建vg,lv,pe

fdisk /dev/sdb

pvcreate /dev/sdb1

pvdisplay

vgcreate vgdata /dev/sdb1

vgdisplay

lvcreate -L 100m
-n lvData vgdata

lvdisplay

mkfs.ext4 /dev/vgdata/lvData

mkdir /LVM

mount /dev/vgdata/lvData /LVM

vi /etc/fstab

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值