Linux创建LVM

1:将物理磁盘设备条带化为物理卷

[root@gechong ~]# pvcreate /dev/sdb

 查看物理卷:

[root@gechong ~]# pvs

或者

[root@gechong ~]# pvdisplay

 

2:创建卷组,并添加PV到卷组

[root@gechong ~]# vgcreate vg_gechong /dev/sdb

查看卷组

[root@gechong ~]# vgs

或者

[root@gechong ~]# vgdisplay

现在创建好了物理卷和卷组还不能使用。

 

创建完卷组后/dev/vgname多了一个文件夹

[root@gechong ~]# ll /dev/vg*
crw-rw----. 1 root root 10, 63 11月  6 19:11 /dev/vga_arbiter

/dev/vg_gechong:
总用量 0
lrwxrwxrwx. 1 root root 7 11月  6 19:11 lv_root -> ../dm-0
lrwxrwxrwx. 1 root root 7 11月  6 19:11 lv_swap -> ../dm-1

实际位置是在这里

[root@gechong vg_gechong]# cd /dev/mapper/

 

 

3:基于卷组创建逻辑卷

[root@gechong ~]# lvcreate -n lv_root -L 16G vg_gechong

查看逻辑卷

[root@gechong ~]# lvs
  LV      VG         Attr      LSize  Pool Origin Data%  Move Log Cpy%Sync Convert
  lv_root vg_gechong -wi-ao--- 16.51g
  lv_swap vg_gechong -wi-ao---  3.00g
[root@gechong ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/vg_gechong/lv_root
  LV Name                lv_root
  VG Name                vg_gechong
  LV UUID                yatm0L-pnIX-d9Rf-zfTf-0PPq-9zJC-K0Lh5J
  LV Write Access        read/write
  LV Creation host, time gechong, 2013-10-13 23:57:50 +0800
  LV Status              available
  # open                 1
  LV Size                16.51 GiB
  Current LE             4226
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

  --- Logical volume ---
  LV Path                /dev/vg_gechong/lv_swap
  LV Name                lv_swap
  VG Name                vg_gechong
  LV UUID                cxINGt-Nae0-XJYA-6gEV-N6lM-20zG-cWhY0Z
  LV Write Access        read/write
  LV Creation host, time gechong, 2013-10-13 23:58:02 +0800
  LV Status              available
  # open                 2
  LV Size                3.00 GiB
  Current LE             768
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:1

 

4:为逻辑卷创建文件系统

[root@gechong vg_gechong]# mkfs.ext4 /dev/vg_gechong/lv_swap

 

5:将格式化好的逻辑卷挂载使用

[root@gechong vg_gechong]# mount /dev/vg_gechong/lv_swap /mnt/vg/lv_swap

 

6:删除逻辑卷

 

删除逻辑卷之前必须先卸载

 

[root@gechong vg_gechong]# lvremove /dev/vg_gechong/lv_swap

 

7:删除卷组

 

[root@gechong vg_gechong]# vgremove vg_gechong

 

8:删除物理卷

 

[root@gechong vg_gechong]# pvremove /dev/sdb

 

你可能感兴趣的:(linux)