实验

从两块磁盘中各取10G,组成20G的卷组。从卷组中划分一个16G的逻辑卷,将此逻辑卷格式化,并挂载到/mbox。

1。添加磁盘sdb并给磁盘划分一个10G的区出来

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


      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

      Partition number (1-4): 1

      First cylinder (1-10443, default 1): 

      Using default value 1

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

2.将划分出来的一个区格式改为LVM

      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                 {输入p查看创建磁盘分区信息}

     Disk /dev/sdb: 85.9 GB, 85899345920 bytes

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


   Device Boot      Start         End      Blocks   Id  System

   /dev/sdb1               1        1306    10490413+  8e  Linux LVM

   Command (m for help): w                  {确认创建OK后输入w保存

3.添加第二块磁盘重复以上1.2.操作

4.查看两块LVM磁盘是否OK

    [root@localhost ~]# fdisk -l |grep LVM

    /dev/sdb1               1        1306    10490413+  8e  Linux LVM

    /dev/sdc1               1        1306    10490413+  8e  Linux LVM

5.创建PV

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

      dev_is_mpath: failed to get device for 8:17

      Physical volume "/dev/sdb1" successfully created

      dev_is_mpath: failed to get device for 8:33

      Physical volume "/dev/sdc1" successfully created

6.查看创建所创建的PV

    [root@localhost ~]# pvscan

      PV /dev/sdb1                      lvm2 [10.00 GiB]

      PV /dev/sdc1                      lvm2 [10.00 GiB]

      Total: 2 [20.01 GiB] / in use: 0 [0   ] / in no VG: 2 [20.01 GiB]

7.查看PV详细信息

[root@localhost ~]# pvdisplay

  "/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               ZeKDrx-nPLC-t3rc-osP1-122x-lU1A-yWBjFs

   

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

  --- NEW Physical volume ---

  PV Name               /dev/sdc1

  VG Name               

  PV Size               10.00 GiB

  Allocatable           NO

  PE Size               0   

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               BKbSSe-Tugx-KUgi-lIew-LH5Y-PBzo-KEZvWt

   


8.创建VG [命名为data_vg]

[root@localhost ~]# vgcreate data_vg /dev/sdb1 /dev/sdc1

  Device data_vg not found (or ignored by filtering).

  dev_is_mpath: failed to get device for 8:17

  Physical volume "/dev/sdb1" successfully created

  Physical volume "/dev/sdc1" successfully created

[root@localhost ~]# vgdisplay

  --- Volume group ---

  VG Name               data_vg

  System ID             

  Format                lvm2

  Metadata Areas        2

  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                2

  Act PV                2

  VG Size               20.00 GiB

  PE Size               4.00 MiB

  Total PE              5120

  Alloc PE / Size       0 / 0   

  Free  PE / Size       5120 / 20.00 GiB

  VG UUID               lGJtbL-E71i-aSch-AX01-nbyB-T8yN-ojJ4z1

9.从创建的20G的vg中划分出16G  [命名为data_lv]

[root@localhost ~]# lvcreate -L 16G -n data_lv data_vg

  Logical volume "data_lv" created


   

10.对划分出来的16Glv格式化为ext3格式

  [root@localhost ~]# mkfs.ext3 /dev//data_vg/data_lv 

  mke2fs 1.41.12 (17-May-2010)

  文件系统标签=

  操作系统:Linux

  块大小=4096 (log=2)

  分块大小=4096 (log=2)

  Stride=0 blocks, Stripe width=0 blocks

  1048576 inodes, 4194304 blocks

  209715 blocks (5.00%) reserved for the super user

  第一个数据块=0

  Maximum filesystem blocks=4294967296

  128 block groups

  32768 blocks per group, 32768 fragments per group

  8192 inodes per group

  Superblock backups stored on blocks: 

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 

4096000


  正在写入inode表: 完成                            

  Creating journal (32768 blocks): 完成

  Writing superblocks and filesystem accounting information: 完成

11.创建/mbox并将/data_lv挂在到/mbox

  [root@localhost ~]# mkdir /mbox

  [root@localhost ~]# mount /dev/data_vg/data_lv /mbox

12.输入df -h查看挂载信息

  [root@localhost ~]# df -h

  Filesystem                   Size  Used Avail Use% Mounted on

  /dev/sda2                     97G  4.0G   88G   5% /

  tmpfs                        932M  556K  931M   1% /dev/shm

  /dev/sda1                    194M   34M  151M  19% /boot

  /dev/sda3                     97G  188M   92G   1% /data

  /dev/sr0                     3.6G  3.6G     0 100% /media/RHEL_6.5 x86_64 Disc 1

  /dev/mapper/data_vg-data_lv   16G  173M   15G   2% /mbox

  [root@localhost ~]#