Linux逻辑卷管理(LVM)


前言:LVM基本术语
 物理存储介质(The physical media)
 这里指系统的存储设备:硬盘,如:/dev/hda、/dev/sda等等,是存储系统最低层的存储单元。
 物理卷(physical volume)
 物理卷就是指硬盘分区或从逻辑上与磁盘分区具有同样功能的设备(如RAID),是LVM的基本存储逻辑块,但和基本的物理存储介质(如分区、磁盘等)比较,却包含有与LVM相关的管理参数。
 卷组(Volume Group)
 LVM卷组类似于非LVM系统中的物理硬盘,其由物理卷组成。可以在卷组上创建一个或多个“LVM分区”(逻辑卷),LVM卷组由一个或多个物理卷组成。
 逻辑卷(logical volume)
 LVM的逻辑卷类似于非LVM系统中的硬盘分区,在逻辑卷之上可以建立文件系统(比如/home或者/usr等)。
 PE(physical extent)
 每一个物理卷被划分为称为PE(Physical Extents)的基本单元,具有唯一编号的PE是可以被LVM寻址的最小单元。PE的大小是可配置的,默认为4MB。
 LE(logical extent)
 逻辑卷也被划分为被称为LE(Logical Extents) 的可被寻址的基本单位。在同一个卷组中,LE的大小和PE是相同的,并且一一对应。
 
一、创建逻辑卷的步骤
 1)通过pvcreate命令将linux分区处理成物理卷(PV);
 2)通过vgcreate命令将创建好的物理卷处理成卷组(Vg);
 3)通过lvcreate命令将卷组分成若干个逻辑卷(Lv);
 之后我们可以对逻辑卷进行格式化,挂载,删除等操作,我们可以动态的调整逻辑卷的大小,并且该操作不会影响我们在逻辑卷(Lv)上的数据。
 
二、物理卷创建管理操作
 1、物理分区信息
 [root@node1 ~]# fdisk /dev/sdd
 
The number of cylinders for this disk is set to 2610.
 There is nothing wrong with that, but this is larger than 1024,
 and could in certain setups cause problems with:
 1) software that runs at boot time (e.g., old versions of LILO)
 2) booting and partitioning software from other OSs
 (e.g., DOS FDISK, OS/2 FDISK)
 
Command (m for help): p
 
Disk /dev/sdd: 21.4 GB, 21474836480 bytes
 255 heads, 63 sectors/track, 2610 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 
Device Boot Start End Blocks Id System
 /dev/sdd1 1 200 1606468+ 83 Linux
 /dev/sdd2 201 400 1606500 83 Linux
 /dev/sdd3 401 600 1606500 83 Linux
 /dev/sdd4 601 2610 16145325 5 Extended
 /dev/sdd5 601 800 1606468+ 83 Linux
 /dev/sdd6 801 1000 1606468+ 83 Linux
 /dev/sdd7 1001 1200 1606468+ 83 Linux
 /dev/sdd8 1201 1400 1606468+ 83 Linux
 /dev/sdd9 1600 1800 1614532+ 83 Linux
 /dev/sdd10 1401 1599 1598404+ 83 Linux
 /dev/sdd11 1801 2000 1606468+ 83 Linux
 /dev/sdd12 2001 2200 1606468+ 83 Linux
 /dev/sdd13 2201 2400 1606468+ 83 Linux
 /dev/sdd14 2401 2610 1686793+ 83 Linux
 
Partition table entries are not in disk order
 
2、创建物理卷
 [root@node1 ~]# pvcreate /dev/sdd*
 Device /dev/sdd not found (or ignored by filtering).
 Physical volume “/dev/sdd1″ successfully created
 Physical volume “/dev/sdd10″ successfully created
 Physical volume “/dev/sdd11″ successfully created
 Physical volume “/dev/sdd12″ successfully created
 Physical volume “/dev/sdd13″ successfully created
 Physical volume “/dev/sdd14″ successfully created
 Physical volume “/dev/sdd2″ successfully created
 Physical volume “/dev/sdd3″ successfully created
 Device /dev/sdd4 not found (or ignored by filtering).
 Physical volume “/dev/sdd5″ successfully created
 Physical volume “/dev/sdd6″ successfully created
 Physical volume “/dev/sdd7″ successfully created
 Physical volume “/dev/sdd8″ successfully created
 Physical volume “/dev/sdd9″ successfully created
 
3、删除物理卷
 [root@node1 ~]# pvremove /dev/sdd1
 Labels on physical volume “/dev/sdd1″ successfully wiped
 
4、添加物理卷
 [root@node1 ~]# pvcreate /dev/sdd1
 Physical volume “/dev/sdd1″ successfully created
 
5、查看物理卷信息
 [root@node1 ~]# pvscan
 PV /dev/sdd1 lvm2 [1.53 GB]
 PV /dev/sdd2 lvm2 [1.53 GB]
 PV /dev/sdd3 lvm2 [1.53 GB]
 PV /dev/sdd5 lvm2 [1.53 GB]
 PV /dev/sdd6 lvm2 [1.53 GB]
 PV /dev/sdd7 lvm2 [1.53 GB]
 PV /dev/sdd8 lvm2 [1.53 GB]
 PV /dev/sdd9 lvm2 [1.54 GB]
 PV /dev/sdd10 lvm2 [1.52 GB]
 PV /dev/sdd11 lvm2 [1.53 GB]
 PV /dev/sdd12 lvm2 [1.53 GB]
 PV /dev/sdd13 lvm2 [1.53 GB]
 PV /dev/sdd14 lvm2 [1.61 GB]
 Total: 13 [19.99 GB] / in use: 0 [0 ] / in no VG: 13 [19.99 GB]
 
6、查看物理卷详细参数
 root@node1 ~]# pvdisplay /dev/sdd5
“/dev/sdd5″ is a new physical volume of “1.53 GB”
 — NEW Physical volume —
PV Name /dev/sdd5
 VG Name
 PV Size 1.53 GB
 Allocatable NO
 PE Size (KByte) 0
 Total PE 0
 Free PE 0
 Allocated PE 0
 PV UUID 7Ms1jT-wxUI-2d7l-h24c-t17F-J9vL-fz2zHM
  • 1
  • 2
  • 3
  • 下一页

相关内容