Команда lvresize используется для изменения размера логических томов и может использоваться для «обмена» экстентами между двумя LV в одной группе томов.
Самый важный флаг для подачи, когда используя lvresize на непустых / активных томах, это флаг -r, который с man-страницы:
-r, --resizefs
Resize underlying filesystem together with the logical volume
using fsadm(8).
Пока включен флаг -r, lvresize будет измените размер файловой системы на логическом томе, чтобы он соответствовал новому размеру LV (автоматически перемещая любые занятые блоки в уменьшаемой области при сжатии тома), что гарантирует, что данные не будут потеряны.
Другими важными флагами для типичного использования являются флаги -L и -l для указания целевого размера логического тома или размера delta. Опять же, страница man:
-l, --extents [+|-]LogicalExtentsNumber[%{VG|LV|PVS|FREE|ORIGIN}]
Change or set the logical volume size in units of logical
extents. With the + or - sign the value is added to or sub‐
tracted from the actual size of the logical volume and without
it, the value is taken as an absolute one. The total number of
physical extents affected will be greater than this if, for
example, the volume is mirrored. The number can also be
expressed as a percentage of the total space in the Volume Group
with the suffix %VG, relative to the existing size of the Logi‐
cal Volume with the suffix %LV, as a percentage of the remaining
free space of the PhysicalVolumes on the command line with the
suffix %PVS, as a percentage of the remaining free space in the
Volume Group with the suffix %FREE, or (for a snapshot) as a
percentage of the total space in the Origin Logical Volume with
the suffix %ORIGIN. The resulting value is rounded downward for
the subtraction otherwise it is rounded upward. N.B. In a
future release, when expressed as a percentage with PVS, VG or
FREE, the number will be treated as an approximate total number
of physical extents to be allocated or freed (including extents
used by any mirrors, for example). The code may currently allo‐
cate or remove more space than you might otherwise expect.
-L, --size [+|-]LogicalVolumeSize[bBsSkKmMgGtTpPeE]
Change or set the logical volume size in units of megabytes. A
size suffix of M for megabytes, G for gigabytes, T for ter‐
abytes, P for petabytes or E for exabytes is optional. With the
+ or - sign the value is added or subtracted from the actual
size of the logical volume and rounded to the full extent size
and without it, the value is taken as an absolute one.
Кроме того, выполняется -v' provides verbose output, -t`.
Итак, чтобы сжать / домой на ~ 50 ГБ, а затем добавить это пространство to / storage, вы можете использовать:
# test run
lvresize -t -v -r -L-50G LVG/home
# If all looks good, shrink for real
lvresize -v -r -L-50G LVG/home
# Give it all to /storage
lvresize -v -r -l+100%FREE LVG/storage
Все это можно сделать с томами, смонтированными, используемыми и даже активно передающими данные во время операций изменения размера. LVM будет просто работать «под» другой деятельностью диска для перенастройки томов. (Разумеется, за счет скорости.)