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 也是指向該文件。

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