#输出结果如下: --- Physical volume --- PV Name /dev/sda3 VG Name ubuntu-vg PV Size <444.08 GiB / not usable 0 Allocatable yes PE Size 4.00 MiB Total PE 113684 Free PE 88084 Allocated PE 25600 PV UUID xWohoN-H8md-mtXq-mKIN-DEcs-k7MJ-mWAlhC
• not usable 0表示不可用的空间为0,LVM在物理卷上创建时,会尽可能地将其划分为物理扩展(PE)。然而,由于物理扩展的大小(默认为4MiB)是固定的,所以如果物理卷的大小不能被物理扩展的大小整除,那么就会有一部分空间无法使用。
#输出结果如下: --- Volume group --- VG Name ubuntu-vg System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size <444.08 GiB PE Size 4.00 MiB Total PE 113684 Alloc PE / Size 25600 / 100.00 GiB Free PE / Size 88084 / <344.08 GiB VG UUID eYGbbx-wZUO-sGeh-TDKa-34NO-kCRw-ZW3Hgt
System ID:这是一个可选的系统ID,用于锁定VG以防止来自其他系统的访问。在这个例子中,它是空的,表示没有设置系统ID。
Metadata Areas 1:元数据区域的数量。这通常与物理卷(PV)的数量相同,因为每个PV都有一个元数据区域。
Metadata Sequence No 2:这是元数据的序列号,表示元数据被更改的次数。每次更改VG(例如,添加或删除逻辑卷),这个数字都会增加。
VG Access read/write:这是VG的访问权限,这里是读/写。
VG Status resizable:这是VG的状态。在这个例子中,它是”resizable”,表示可以调整VG的大小。
Create a striped LV with 3 stripes, a stripe size of 8KiB and a size of 100MiB. The LV name is chosen by lvcreate. lvcreate -i 3 -I 8 -L 100m vg00
Create a raid1 LV with two images, and a useable size of 500 MiB. This operation requires two devices, one for each mirror image. RAID metadata (superblock and bitmap) is also included on the two devices. lvcreate --type raid1 -m1 -L 500m -n mylv vg00
Create a mirror LV with two images, and a useable size of 500 MiB. This operation requires three devices: two for mirror images and one for a disk log. lvcreate --type mirror -m1 -L 500m -n mylv vg00
Create a mirror LV with 2 images, and a useable size of 500 MiB. This operation requires 2 devices because the log is in memory. lvcreate --type mirror -m1 --mirrorlog core -L 500m -n mylv vg00
Create a copy-on-write snapshot of an LV: lvcreate --snapshot --size 100m --name mysnap vg00/mylv
Create a copy-on-write snapshot with a size sufficient for overwriting 20% of the size of the original LV. lvcreate -s -l 20%ORIGIN -n mysnap vg00/mylv
Create a sparse LV with 1TiB of virtual space, and actual space just under 100MiB. lvcreate --snapshot --virtualsize 1t --size 100m --name mylv vg00
Create a linear LV with a usable size of 64MiB on specific physical extents. lvcreate -L 64m -n mylv vg00 /dev/sda:0-7 /dev/sdb:0-7
Create a RAID5 LV with a usable size of 5GiB, 3 stripes, a stripe size of 64KiB, using a total of 4 devices (including one for parity). lvcreate --type raid5 -L 5G -i 3 -I 64 -n mylv vg00
Create a RAID5 LV using all of the free space in the VG and spanning all the PVs in the VG (note that the command will fail if there are more than 8 PVs in the VG, inwhichcase -i 7 must be used to get to the current maximum of 8 devices including parity for RaidLVs). lvcreate --config allocation/raid_stripe_all_devices=1 --type raid5 -l 100%FREE -n mylv vg00
Create RAID10 LV with a usable size of 5GiB, using 2 stripes, each on a two-image mirror. (Note that the -i and -m arguments behave differently: -i specifies the total number of stripes, but -m specifies the number of images in addition to the first image). lvcreate --type raid10 -L 5G -i 2 -m 1 -n mylv vg00
Create a 1TiB thin LV mythin, with 256GiB thinpool tpool0 in vg00. lvcreate --T --size 256G --name mythin vg00/tpool0
Create a 1TiB thin LV, first creating a new thin pool for it, where the thin pool has 100MiB of space, uses 2 stripes, has a 64KiB stripe size, and 256KiB chunk size. lvcreate --type thin --name mylv --thinpool mypool -V 1t -L 100m -i 2 -I 64 -c 256 vg00
Create a thin snapshot of a thin LV (the size option must not be used, otherwise a copy-on-write snapshot would be created). lvcreate --snapshot --name mysnap vg00/thinvol
Create a thin snapshot of the read-only inactive LV named "origin"which becomes an external origin for the thin snapshot LV. lvcreate --snapshot --name mysnap --thinpool mypool vg00/origin
Create a cache pool from a fast physical device. The cache pool can then be used to cache an LV. lvcreate --type cache-pool -L 1G -n my_cpool vg00 /dev/fast1
Create a cache LV, first creating a new origin LV on a slow physical device, then combining the new origin LV with an existing cache pool. lvcreate --type cache --cachepool my_cpool -L 100G -n mylv vg00 /dev/slow1
Create a VDO LV vdo0 with VDOPoolLV size of 10GiB and name vpool1. lvcreate --vdo --size 10G --name vdo0 vg00/vpool1
接下来让我们详细看看lv:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
lvdisplay
#输出结果如下: --- Logical volume --- LV Path /dev/ubuntu-vg/ubuntu-lv LV Name ubuntu-lv VG Name ubuntu-vg LV UUID XmYa9u-j4nc-PKRe-wauS-fsBz-x03f-dIsH1j LV Write Access read/write LV Creation host, time ubuntu-server, 2023-09-29 11:30:34 +0000 LV Status available # open 1 LV Size 100.00 GiB Current LE 25600 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0
LV Status available:这是LV的状态,这里是”available”,表示LV可用,可以被文件系统挂载和使用。
# open 1:打开LV的数量,通常表示有多少进程正在使用这个LV。这里的1表示有一个进程正在使用这个LV。
Current LE 25600:当前的逻辑扩展(LE)数量。LE是LV中的基本单位,与VG中的PE大小相同。这里的25600表示这个LV包含25600个LE,与LV Size的值相符。