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

LVM

时间:2016-02-01 10:00:55      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:lvm

fdisk -l 显示物理磁盘/dev/sda  /dev/sdb   /dev/sdc 等,如果有某个磁盘上有多个分区,则/dev/sda1   /dev/sda2    /dev/sdb1  /dev/sdb2等,还会 display logical volumn


[root@virtual-2 dev]# fdisk -l


Disk /dev/sda: 107.4 GB, 107374182400 bytes

255 heads, 63 sectors/track, 13054 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: 0x00052aa6


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          64      512000   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              64       13055   104344576   8e  Linux LVM


Disk /dev/mapper/vg_virtual2-lv_root: 53.7 GB, 53687091200 bytes

255 heads, 63 sectors/track, 6527 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: 0x00000000



Disk /dev/mapper/vg_virtual2-lv_swap: 1577 MB, 1577058304 bytes

255 heads, 63 sectors/track, 191 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: 0x00000000



Disk /dev/mapper/vg_virtual2-lv_home: 51.6 GB, 51581550592 bytes

255 heads, 63 sectors/track, 6271 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: 0x00000000


[root@virtual-2 dev]# pvdisplay

  --- Physical volume ---

  PV Name               /dev/sda2

  VG Name               vg_virtual2

  PV Size               99.51 GiB / not usable 3.00 MiB

  Allocatable           yes (but full)

  PE Size               4.00 MiB

  Total PE              25474

  Free PE               0

  Allocated PE          25474

  PV UUID               69C1Bm-OhuT-lw1f-80w2-Dxzi-92vY-Lzahx3

 说明/dev/sda2被创建成了pv,该命令为pvcreate /dev/sda2


[root@virtual-2 dev]# vgdisplay

  --- Volume group ---

  VG Name               vg_virtual2

  System ID             

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  4

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                3

  Open LV               3

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               99.51 GiB

  PE Size               4.00 MiB

  Total PE              25474

  Alloc PE / Size       25474 / 99.51 GiB

  Free  PE / Size       0 / 0   

  VG UUID               knomNV-2sdf-4GKm-7Z1f-JFQ7-cdZL-QHYMSA

  

[root@virtual-2 dev]# vgdisplay

  --- Volume group ---

  VG Name               vg_virtual2

  System ID             

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  4

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                3

  Open LV               3

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               99.51 GiB

  PE Size               4.00 MiB

  Total PE              25474

  Alloc PE / Size       25474 / 99.51 GiB

  Free  PE / Size       0 / 0   

  VG UUID               knomNV-2sdf-4GKm-7Z1f-JFQ7-cdZL-QHYMSA

   

[root@virtual-2 dev]# lvdisplay

  --- Logical volume ---

  LV Path                /dev/vg_virtual2/lv_root

  LV Name                lv_root

  VG Name                vg_virtual2

  LV UUID                hH0dhv-xcIO-1kgf-06li-auoe-58zt-STYBGt

  LV Write Access        read/write

  LV Creation host, time virtual-2, 2016-01-23 04:40:09 -0500

  LV Status              available

  # open                 1

  LV Size                50.00 GiB

  Current LE             12800

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:0

   

  --- Logical volume ---

  LV Path                /dev/vg_virtual2/lv_home

  LV Name                lv_home

  VG Name                vg_virtual2

  LV UUID                LbwHv6-devD-0jhg-Fhb0-7yX3-AqHT-pPmU7A

  LV Write Access        read/write

  LV Creation host, time virtual-2, 2016-01-23 04:40:17 -0500

  LV Status              available

  # open                 1

  LV Size                48.04 GiB

  Current LE             12298

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:2

   

  --- Logical volume ---

  LV Path                /dev/vg_virtual2/lv_swap

  LV Name                lv_swap

  VG Name                vg_virtual2

  LV UUID                Wpb2eQ-Bdd1-XQIS-qLPg-cYwY-Q0DE-4hDKg8

  LV Write Access        read/write

  LV Creation host, time virtual-2, 2016-01-23 04:40:25 -0500

  LV Status              available

  # open                 1

  LV Size                1.47 GiB

  Current LE             376

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:1


or

pvs, vgs, lvs显示简洁的统计信息


在线扩容:

1、看该文件系统对应的逻辑卷lv

[root@virtual-2 dev]# df -lh

Filesystem                       Size  Used Avail Use% Mounted on

/dev/mapper/vg_virtual2-lv_root   50G  5.5G   42G  12% /

tmpfs                            376M  516K  375M   1% /dev/shm

/dev/sda1                        485M   33M  427M   8% /boot

/dev/mapper/vg_virtual2-lv_home   48G  2.2G   43G   5% /home

/dev/sr0                          57M   57M     0 100% /media/VBOXADDITIONS_5.0.12_104815

2、找到该lv所在的vg

[root@virtual-2 dev]# lvs

  LV      VG          Attr       LSize  Pool Origin Data%  Move Log Cpy%Sync Convert

  lv_home vg_virtual2 -wi-ao---- 48.04g                                             

  lv_root vg_virtual2 -wi-ao---- 50.00g                                             

  lv_swap vg_virtual2 -wi-ao----  1.47g   

3、查看该LV所在的vg有无free PE(physical extent) 

root@virtual-2 dev]# vgs

  VG          #PV #LV #SN Attr   VSize  VFree

  vg_virtual2   1   3   0 wz--n- 99.51g    0 

4、添加pv到vg

pvcreate /dev/sdd

vgextend vg_virtual2 /dev/sdd


5、扩lv的size

lvresize -L +10G /dev/vg_virtual2/lv_home


6、将lv增加的空间进行文件系统格式化

resize2fs /dev/vg_virtual2/lv_home


LV的在线扩容完成。


lv的在线缩容:


LVM

标签:lvm

原文地址:http://dannyswallow.blog.51cto.com/5062777/1740258

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