Linux实用工具-lvm(2) 基本操作-pv 基本操作-vg 基本操作-lv

基本操作-pv

创建pv

$pvcreate /dev/sda{1,2,3}

查看pv

$pvs
$pvscan
$pvdisplay

基本操作-vg

两种创建vg方式

创建vg,默认PE大小为4M

$vgcreate vg1 /dev/sda{1,2,3}

设置PE大小为8M的vg

$vgcreate -s 8M vg1 /dev/sda{1,2,3}

查看vg

$vgs
$vgscan
$vgdisplay

一般而言,创建了名为 vg1 的vg之后,会在系统中看到对应的 /dev/vg1 路径。

基本操作-lv

几种创建lv方式

指定大小方式创建lv

$lvcreate -L 5G -n lv1 vg1

这里,大小 5G, 卷名 lv1 , 从 vg1 中获取空间。

指定PE块方式创建lv

$lvcreate -l 640 -n lv1 vg1

创建一个占全部卷组大小的lv

$lvcreate -l 100%VG -n lv1 vg1

这个命令比较特殊,通过百分比指定。相关的man手册:

-l|--extents Number[PERCENT]
......The suffix %VG denotes the total size of the VG, the suffix %FREE the remaining free space in the VG, and the suffix %PVS the free space in the specified PVs.  For a snapshot, the size can be expressed as a percentage of the total size of the origin LV with the suffix %ORIGIN(100%ORIGIN provides space for the whole origin).

给lv创建文件系统,并挂载

$mkfs.ext4 /dev/vg1/lv1
$mount /dev/vg1/lv1 /mnt/lv1

查看lv

$lvs
$lvscan
$lvdisplay

一般来说,在vg1上创建了名为 lv1 的lv之后,,会在系统中看到对应的 /dev/vg1/lv1 软链接,其实际指向 /dev/ 下的一个设备文件,同时 /dev/mapper/vg1-lv1 也是指向该文件。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章