Show Table of Contents
4.4.12. 遞增邏輯卷冊
若要增加邏輯卷冊的大小,請使用
lvextend 指令。
當您延伸邏輯卷冊時,您可指定要將卷冊延伸多少或是當您將它延伸後它應該要多大。
下列指令會將邏輯卷冊
/dev/myvg/homevol 延伸為 12 GB。
# lvextend -L12G /dev/myvg/homevol
lvextend -- extending logical volume "/dev/myvg/homevol" to 12 GB
lvextend -- doing automatic backup of volume group "myvg"
lvextend -- logical volume "/dev/myvg/homevol" successfully extended
下列指令會增加額外的 1GB 至邏輯卷冊
/dev/myvg/homevol。
# lvextend -L+1G /dev/myvg/homevol
lvextend -- extending logical volume "/dev/myvg/homevol" to 13 GB
lvextend -- doing automatic backup of volume group "myvg"
lvextend -- logical volume "/dev/myvg/homevol" successfully extended
就和
lvcreate 指令相同,您可使用 lvextend 指令的 -l 引數來指定扇區的數量,並遞增邏輯卷冊的大小。您亦可使用此引數來指定卷冊群組的百分比例,或是卷冊群組剩下可用空間的百分比。下列指令將會延伸一個名為 testlv 的邏輯卷冊,並填滿卷冊群組 myvg 中所有未分配的空間。
# lvextend -l +100%FREE /dev/myvg/testlv
Extending logical volume testlv to 68.59 GB
Logical volume testlv successfully resized
在您延伸了邏輯卷冊後,您需要增加檔案系統大小來進行匹配。
就預設值來講,大部分用來重設檔案系統大小的工具都會將檔案系統的大小遞增為基本邏輯卷冊的大小,如此一來您便無須擔心得為這兩項指令指定相同的大小。
4.4.12.1. 延伸等量的卷冊
若要增加等量邏輯卷冊的大小,用來製作支援 stripe 的卷冊群組的基本實體卷冊上就必須要有足夠的空間。比方說,若您有個雙向的 stripe 而它使用了所有的卷冊群組,新增一個單獨的實體卷冊至卷冊群組將無法讓您延伸該 stripe。您必須要新增至少兩個實體卷冊至卷冊群組中。
比方說,請參考一個包含著兩個基本實體卷冊的卷冊群組
vg,如下列透過 vgs 指令所示。
# vgs
VG #PV #LV #SN Attr VSize VFree
vg 2 0 0 wz--n- 271.31G 271.31G
您可透過使用卷冊群組中的所有空間來建立磁條。
#lvcreate -n stripe1 -L 271.31G -i 2 vgUsing default stripesize 64.00 KB Rounding up size to full physical extent 271.31 GB Logical volume "stripe1" created #lvs -a -o +devicesLV VG Attr LSize Origin Snap% Move Log Copy% Devices stripe1 vg -wi-a- 271.31G /dev/sda1(0),/dev/sdb1(0)
請注意,卷冊群組現在已無可用空間。
# vgs
VG #PV #LV #SN Attr VSize VFree
vg 2 1 0 wz--n- 271.31G 0
下列指令會增加額外的實體卷冊至卷冊群組,如此一來它便會含有 135G 的額外空間。
#vgextend vg /dev/sdc1Volume group "vg" successfully extended #vgsVG #PV #LV #SN Attr VSize VFree vg 3 1 0 wz--n- 406.97G 135.66G
在此情況下,您無法將等量邏輯卷冊延伸為整個卷冊群組的大小,因為需要兩個基本的裝置才可 stripe 資料。
# lvextend vg/stripe1 -L 406G
Using stripesize of last segment 64.00 KB
Extending logical volume stripe1 to 406.00 GB
Insufficient suitable allocatable extents for logical volume stripe1: 34480
more required
若要延伸等量邏輯卷冊,請新增另一實體卷冊然後再延伸邏輯卷冊。在此範例中,新增了兩個實體卷冊至卷冊群組之後,我們便可將邏輯卷冊延伸為卷冊群組的完整大小。
#vgextend vg /dev/sdd1Volume group "vg" successfully extended #vgsVG #PV #LV #SN Attr VSize VFree vg 4 1 0 wz--n- 542.62G 271.31G #lvextend vg/stripe1 -L 542GUsing stripesize of last segment 64.00 KB Extending logical volume stripe1 to 542.00 GB Logical volume stripe1 successfully resized
在您沒有足夠的基本實體裝置來延伸等量邏輯卷冊的情況下,若延伸沒有被 stripe 無所謂的話,您依然還是能夠延伸該卷冊,而這將有可能造成效能上的不一致。當增加邏輯卷冊的空間時,預設的作業就是使用和現有邏輯卷冊的最後一個區段相同的 striping 參數,不過您可將這些參數置換掉。下列範例在初始的
lvextend 指令失敗後延伸了現有的等量邏輯卷冊來使用剩下的可用空間。
#lvextend vg/stripe1 -L 406GUsing stripesize of last segment 64.00 KB Extending logical volume stripe1 to 406.00 GB Insufficient suitable allocatable extents for logical volume stripe1: 34480 more required #lvextend -i1 -l+100%FREE vg/stripe1

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.