码迷,mamicode.com
首页 > 其他好文 > 详细

LVM的使用(一)

时间:2015-10-26 18:59:23      阅读:309      评论:0      收藏:0      [点我收藏+]

标签:lvm 学习

1 LVM的一些术语

PV(Physical Volume):物理卷

PE(Physical Extent):物理存储块,存储单元

LV(Logic Volume):逻辑卷

LE(Logic Volume):逻辑存储块,存储单元

VG(Volume Group):卷组,PV组


LVM通过把多个物理存储规划到一个大硬盘也就是VG中通过自带的一些进行文件系统级别的管理

大致步骤如下:

fdisk ---> create PV ---> create VG or add to VG --->create LV ---> format LV and mount the partion

2 实验环境

vm12下的debian 8 

3 创建lvm

3.1 通过fdisk创建一个LVM格式的分区

root@liuliancao:~# fdisk /dev/sdb

Command (m for help): n

Partition type

   p   primary (0 primary, 0 extended, 4 free)

   e   extended (container for logical partitions)

Select (default p): p #为主分区,或者选择新建扩展分区再新建一个逻辑分区

Partition number (1-4, default 1): 

First sector (2048-41943039, default 2048): 

Last sector, +sectors or +size{K,M,G,T,P} (2048-41943039, default 41943039): +10G


Created a new partition 1 of type ‘Linux‘ and of size 10 GiB.


Command (m for help): t #修改分区类型

Selected partition 1

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

Changed type of partition ‘Linux‘ to ‘Linux LVM‘.


Command (m for help): p

Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 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

Disklabel type: dos

Disk identifier: 0x4056b7d4


Device     Boot Start      End  Sectors Size Id Type

/dev/sdb1        2048 20973567 20971520  10G 8e Linux LVM


Command (m for help): w #写入保存

The partition table has been altered.

Calling ioctl() to re-read partition table.

Syncing disks.


3.2 创建PV 

一般只需要一个参数

root@liuliancao:~# pvcreate /dev/sdb1

  Physical volume "/dev/sdb1" successfully created

root@liuliancao:~# pvdisplay /dev/sdb1

  "/dev/sdb1" is a new physical volume of "10.00 GiB"

  --- NEW Physical volume ---

  PV Name               /dev/sdb1

  VG Name               

  PV Size               10.00 GiB

  Allocatable           NO

  PE Size               0   

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               bujqYf-GO73-DebW-flTi-Xnmj-jug1-MaIlCw

3.3 创建VG并加入把lvm卷加入VG,-s可以指定PE大小,默认4M

root@liuliancao:~# vgcreate liulianca_test /dev/sdb1

  Volume group "liulianca_test" successfully created

root@liuliancao:~# vgdisplay

  --- Volume group ---

  VG Name               liulianca_test

  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               10.00 GiB

  PE Size               4.00 MiB

  Total PE              2559

  Alloc PE / Size       0 / 0   

  Free  PE / Size       2559 / 10.00 GiB

  VG UUID               HQsd1f-XU0o-4rUZ-q60o-KrT2-wMTb-SrTT7n


3.4 创建LV  -L指定大小,-n指定name,最后接上VG的名称

root@liuliancao:~# lvcreate -L 1G -n lqx liulianca_test

  Logical volume "lqx" created

root@liuliancao:~# lvdisplay

  --- Logical volume ---

  LV Path                /dev/liulianca_test/lqx

  LV Name                lqx

  VG Name                liulianca_test

  LV UUID                GeZhTn-Tjb5-Fl7L-wZKu-wvcg-agbj-zaddza

  LV Write Access        read/write

  LV Creation host, time liuliancao, 2015-10-26 01:16:37 -0700

  LV Status              available

  # open                 0

  LV Size                1.00 GiB

  Current LE             256

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           254:5


3.5 格式化和挂载,这个就比较容易了

root@liuliancao:~# mke2fs -t ext3 /dev/liulianca_test/lqx

mke2fs 1.42.12 (29-Aug-2014)

Creating filesystem with 262144 4k blocks and 65536 inodes

Filesystem UUID: 0db59220-379a-4c14-84da-c2f4b0b9f085

Superblock backups stored on blocks: 

32768, 98304, 163840, 229376


Allocating group tables: done                            

Writing inode tables: done                            

Creating journal (8192 blocks): done

Writing superblocks and filesystem accounting information: done


root@liuliancao:~# mkdir /lvm_test

root@liuliancao:~# mount /dev/liulianca_test/lqx /lvm_test

root@liuliancao:~# ls /lvm_test

lost+found


root@liuliancao:~# echo "/dev/liulianca_test/lqx/lvm_test     /lvm_test   ext3 defaults     0    0" >> /etc/fstab 


简单的LVM使用就是这样了,下面再说下可能甬道的LVM管理

本文出自 “启学的学习之路” 博客,请务必保留此出处http://qixue.blog.51cto.com/7213178/1706434

LVM的使用(一)

标签:lvm 学习

原文地址:http://qixue.blog.51cto.com/7213178/1706434

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!