日期:2014-05-16  浏览次数:20739 次

Linux LVM 创建、删除、扩展
redhat6.2上做LVM
1
先给虚拟机上的RH加一个硬盘。
2
启动RH
3
在终端上输入
[BeiGang@localhost~]$fdisk -l
Disk /dev/sdc: 1073 MB, 1073741824 bytes
……
Disk /dev/sdc doesn't contain a valid partition table
4
分区1
[BeiGang@localhost~]$fdisk /dev/sdc
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-130, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): +100M

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[BeiGang@localhost~]$

5
查看
[BeiGang@localhost~]$fdisk -l
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1          14      112423+  83  Linux

6
分区2
[BeiGang@localhost~]$fdisk /dev/sdc
n
p
2
15
+100M
w

7
查看
[BeiGang@localhost~]$fdisk -l
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1          14      112423+  83  Linux
/dev/sdc2              15          28      112455   83  Linux

8
添加物理卷
[BeiGang@localhost~]$pvcreate /dev/sdc1
  Writing physical volume data to disk "/dev/sdc1"
  Physical volume "/dev/sdc1" successfully created
[BeiGang@localhost~]$pvcreate /dev/sdc2
  Writing physical volume data to disk "/dev/sdc2"
  Physical volume "/dev/sdc2" successfully created
[BeiGang@localhost~]$

9
查看PV
[BeiGang@localhost~]$pvs
  PV         VG       Fmt  Attr PSize   PFree  
  /dev/sdc1           lvm2 a--  109.79m 109.79m
  /dev/sdc2           lvm2 a--  109.82m 109.82m
[BeiGang@localhost~]$

10
创建卷组
[BeiGang@localhost~]$vgcreate VG1 /dev/sdc1 /dev/sdc2
  Volume group "VG1" successfully created
[BeiGang@localhost~]$

11
查看卷组
[BeiGang@localhost~]$vgs
  VG       #PV #LV #SN Attr   VSize   VFree  
  VG1        2   0   0 wz--n- 216.00m 216.00m
[BeiGang@localhost~]$

12
创建逻辑卷1
[BeiGang@localhost~]$lvcreate -n lv1 -L +50M VG1
  Rounding up size to full physical extent 52.00 MiB
  Logical volume "lv1" created
[BeiGang@localhost~]$

13
创建逻辑卷2,因为是PE(4M)的整数倍,所以没有上调
[BeiGang@localhost~]$lvcreate -n lv2 -L +60M VG1
  Logical volume "lv2" created
[BeiGang@localhost~]$

14
查看逻辑卷
[BeiGang@localhost~]$lvs
  LV      VG       Attr   LSize  Origin Snap%  Move Log Copy%  Convert
  lv1     VG1&