Lvm
為什麼不能 pvresize 到從分配的物理範圍中獲取的確切空間
在一個物理卷中,我分配了 32 個物理擴展區,每個擴展區為 4194304 字節(或 4MiB)。32*4194304 是 134217728 (128MiB)。當試圖調整到那個確切的大小時,我得到一個錯誤。嘗試將大小調整為 129MiB 有效。
為什麼不能將 PV 調整到分配的物理範圍的確切數量?我如何正確知道我可以將其調整為多少?
root@osboxes:/etc/lvm# pvdisplay --unit b --- Physical volume --- PV Name /dev/sda4 VG Name vg1 PV Size 135266304 B / not usable 1048576 B Allocatable yes (but full) PE Size 4194304 B Total PE 32 Free PE 0 Allocated PE 32 PV UUID 4XbCGL-eTnk-KFea-eZs5-MQT4-il6C-OPPVTB root@osboxes:/etc/lvm# pvresize --setphysicalvolumesize 134217728b /dev/sda4 /dev/sda4: Requested size 128.00 MiB is less than real size <270.06 GiB. Proceed? [y/n]: y WARNING: /dev/sda4: Pretending size is 262144 not 566349824 sectors. /dev/sda4: cannot resize to 31 extents as 32 are allocated. 0 physical volume(s) resized or updated / 1 physical volume(s) not resized
LVM 元數據必須去某個地方。通常這是 PV 開始時的 1MiB。
您可以像這樣檢查第一個物理範圍的起始偏移量:
pvs -o +pe_start
將第一個 PE 偏移量添加到總大小中,它應該可以工作。
您也可以在 時設置此值
vgcreate
,如手冊頁中所述:--dataalignment Size[k|UNIT] Align the start of the data to a multiple of this number. Also specify an appropriate Physical Extent size when creating a VG. To see the location of the first Physical Extent of an existing PV, use pvs -o +pe_start. In addition, it may be shifted by an alignment offset. See lvm.conf/data_alignment_offset_detection and --dataalignmentoffset. --dataalignmentoffset Size[k|UNIT] Shift the start of the data area by this additional offset.
小心使用這些,否則你可能會得到非常奇怪的偏移量。