Linux 入门 5 LVM的使用

添加一块新SATA磁盘4G

linux-0k5g:~ # fdisk -l

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0002ba94

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         194     1558273+  82  Linux swap / Solaris
/dev/sda2   *         195         847     5245222+  83  Linux
/dev/sda3             848        1044     1582402+  83  Linux

Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn‘t contain a valid partition table

分区完后
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         125     1004031   83  Linux
/dev/sdb2             126         250     1004062+  83  Linux
/dev/sdb3             251         522     2184840    5  Extended
/dev/sdb5             251         313      506016   83  Linux
/dev/sdb6             314         376      506016   83  Linux
/dev/sdb7             377         522     1172713+  83  Linux

创建PV(漏掉了修改分区id为8e)
linux-0k5g:~ # lvm pvcreate /dev/sdb{2,5,6,7}
  Physical volume "/dev/sdb2" successfully created
  Physical volume "/dev/sdb5" successfully created
  Physical volume "/dev/sdb6" successfully created
  Physical volume "/dev/sdb7" successfully created
linux-0k5g:~ # lvm pvscan
  PV /dev/sdb2         lvm2 [980.53 MB]
  PV /dev/sdb5         lvm2 [494.16 MB]
  PV /dev/sdb6         lvm2 [494.16 MB]
  PV /dev/sdb7         lvm2 [1.12 GB]
  Total: 4 [3.04 GB] / in use: 0 [0   ] / in no VG: 4 [3.04 GB]
创建VG
  linux-0k5g:~ # lvm vgcreate -s 16M vg_srsy /dev/sdb{2,5,6,7}
  Volume group "vg_srsy" successfully created
  linux-0k5g:~ # lvm pvscan
  PV /dev/sdb2   VG vg_srsy   lvm2 [976.00 MB / 976.00 MB free]		# 容量变小了,因为每个PV里都添加了VGDA信息
  PV /dev/sdb5   VG vg_srsy   lvm2 [480.00 MB / 480.00 MB free]
  PV /dev/sdb6   VG vg_srsy   lvm2 [480.00 MB / 480.00 MB free]
  PV /dev/sdb7   VG vg_srsy   lvm2 [1.11 GB / 1.11 GB free]
  Total: 4 [3.00 GB] / in use: 4 [3.00 GB] / in no VG: 0 [0   ]
  linux-0k5g:~ # lvm vgdisplay
  --- Volume group ---
  VG Name               vg_srsy
  System ID             
  Format                lvm2
  Metadata Areas        4
  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                4
  Act PV                4
  VG Size               3.00 GB
  PE Size               16.00 MB
  Total PE              192				# 共192个PE
  Alloc PE / Size       0 / 0   
  Free  PE / Size       192 / 3.00 GB
  VG UUID               Mbl8Ki-mP2W-qZkB-5EBe-kT2k-tyFD-5Lpdi1

现在在逻辑上创建了一块“大磁盘”了,下面对“大磁盘"进行”分区“,即创建两个LV
linux-0k5g:~ # lvm lvcreate -l 96 -n lv1_srsy vg_srsy linux-0k5g:~ # lvm lvcreate -l 96 -n lv2_srsy vg_srsy linux-0k5g:~ # lvm lvscan (或lvdisplay) ACTIVE ‘/dev/vg_srsy/lv1_srsy‘ [1.50 GB] inherit # 注意LV全名是这个哦 ACTIVE ‘/dev/vg_srsy/lv2_srsy‘ [1.50 GB] inherit 对lv1创建文件系统(格式化)
linux-0k5g:~ # mkfs.ext3 /dev/vg_srsy/lv1_srsy 挂载 linux-0k5g:~ # mkdir /mnt/lvmlv1 linux-0k5g:~ # mount /dev/vg_srsy/lv1_srsy /mnt/lvmlv1 linux-0k5g:~ # df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda2 5162828 2414952 2485616 50% / udev 387404 132 387272 1% /dev /dev/sda3 1557496 247504 1230872 17% /home /dev/mapper/vg_srsy-lv1_srsy # 逻辑卷的位置在这里!!! 1548144 35112 1434392 3% /mnt/lvmlv1 查看分区情况 linux-0k5g:/dev # fdisk -l Disk /dev/sda: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x0002ba94 Device Boot Start End Blocks Id System /dev/sda1 1 194 1558273+ 82 Linux swap / Solaris /dev/sda2 * 195 847 5245222+ 83 Linux /dev/sda3 848 1044 1582402+ 83 Linux Disk /dev/sdb: 4294 MB, 4294967296 bytes 255 heads, 63 sectors/track, 522 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0xb9091808 Device Boot Start End Blocks Id System /dev/sdb1 1 125 1004031 83 Linux /dev/sdb2 126 250 1004062+ 83 Linux /dev/sdb3 251 522 2184840 5 Extended /dev/sdb5 251 313 506016 83 Linux /dev/sdb6 314 376 506016 83 Linux /dev/sdb7 377 522 1172713+ 83 Linux Disk /dev/dm-0: 1610 MB, 1610612736 bytes 255 heads, 63 sectors/track, 195 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00000000 Disk /dev/dm-0 doesn‘t contain a valid partition table    # 这个是啥意思? Disk /dev/dm-1: 1610 MB, 1610612736 bytes 255 heads, 63 sectors/track, 195 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00000000 Disk /dev/dm-1 doesn‘t contain a valid partition table # 用lvm lvdisplay 查看 发现两个lv 是block device 253:0 和 block device 253:1
dev/mapper/vg_srsy-lv1_srsy 和 vg_srsy-lv2_srsy 用ls -al 查看也分别是 253:0 253:1,另外dm-0和dm-1也是
brw-r----- 1 root disk 253,0 Jul 12 11:56 dm-0
brw-r----- 1 root disk 253,1 Ju1 12 11:57 dm-1
这块不太懂。。。。。。



  

 

 

 

Linux 入门 5 LVM的使用,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。