Create and manage LVM
To create an LVM system, you typically need to go through the following steps:
1. Create a partition Fdisk/dev/sdb
Using the partitioning tool (such as FDISK, etc.) to create an LVM partition is the same way as creating other general partitions, except that the partition type of LVM is only 8e. As shown in the following figure:
2. Create PV pvcreate/dev/sdb{1,2,3,4,5}tip device/dev/sdxx not found (or ignored by Filtering), you need toTo add SDB to the/etc/lvm/lvm.conf filter.
3. Create VG Vgcreate volgroup00/dev/sdb{1,2,3,4}
After the VG is created, a LV can be divided from the VG.
4. Create LV lvcreate-l 2g-n lv00 VolGroup00
A partition named lv00, with a capacity size of 2G, is created, where:-L: Specifies the size of the LV-N: Specifies the name of the LV. VO1GROUP00: Represents the division of LV from this VG;
5. LV format and Mount
The next step is to format the LV (using MKSF for formatting), and then LV to store the data
The formatted LV partition is mounted to the specified directory, and the data can be stored like a normal directory.
Once mounted, you can see the capacity of this LV.
If you want to start the LV when the system starts, it is best to write lvdata to the fstable file as follows:
Using the Vim editor, Open/etc/fstab, as shown in the last line add, where/dev/volgroup00/lvdata specifies the partition to mount Lv,/root/test specify the directory to mount (mount point), ext3 partition file system format, Other uses default can be
Expanding the current partition
First, create a new partition:
Fdisk/dev/hda
N
L #选择逻辑分区, if not, first create an extended partition and then add the logical partition (hard disk: up to four partitions p-p-p-p or P-P-P-E)
6 #分区号 (starting from 5),/dev/hda6
T 8e #分区类型8e表示LVM分区
W #写入分区表
Partprobe #重读分区表
Mkfs-t Ext3/dev/hda6 #格式化
Partx/dev/hda #查看当前硬盘的分区表及使用情况
Second, the creation of PV, expansion vg,lv
Pvcreate/dev/hda6
Vgdisplay #查看当前已经存在的VG信息, taking the existence of vg:volgroup00 as an example
Vgextend Volgroup00/dev/hda6 #扩展VolGroup00
Lvdisplay #查看已经存在的LV信息, taking the existence of LV:LOGVOL01 as an example
Lvextend-l 1g/dev/volgroup00/logvol01 #扩展LV or Lvextend-l +100%free/dev/volgroup00/logvol01
Resize2fs/dev/volgroup00/logvol01 #执行该重设大小, valid for LogVol01 currently in use
Df-h #查看挂载情况, has been enlarged
Linux LVM Management