Помощь по изменению размера моих разделов LVM

Мне нужна помощь по изменению размера двух разделов LVM, так как я боюсь потерять данные.

Я использую безголовый режим Ubuntu Server 12.04.

LVS:

root@server:/# lvs
  LV      VG   Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  home    LVG  -wi-ao  27,94g
  root    LVG  -wi-ao   6,52g
  storage LVG  -wi-ao 504,84g
  swap    LVG  -wi-ao 732,00m

FDISK:

root@server:/# fdisk -l

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders, total 156301488 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00067ea1

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      585727      291840   83  Linux
/dev/sda2          587774   156301311    77856769    5  Extended
/dev/sda5          587776   156301311    77856768   8e  Linux LVM

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008c066

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048   976771071   488384512   8e  Linux LVM

Disk /dev/mapper/LVG-root: 6996 MB, 6996099072 bytes
255 heads, 63 sectors/track, 850 cylinders, total 13664256 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/LVG-root doesn't contain a valid partition table

Disk /dev/mapper/LVG-swap: 767 MB, 767557632 bytes
255 heads, 63 sectors/track, 93 cylinders, total 1499136 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/LVG-swap doesn't contain a valid partition table

Disk /dev/mapper/LVG-home: 30.0 GB, 29997662208 bytes
255 heads, 63 sectors/track, 3647 cylinders, total 58589184 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/LVG-home doesn't contain a valid partition table

Disk /dev/mapper/LVG-storage: 542.1 GB, 542063460352 bytes
255 heads, 63 sectors/track, 65902 cylinders, total 1058717696 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/LVG-storage doesn't contain a valid partition table

Я хочу уменьшить /home раздел ЛЖ и расширить /storage раздел ЛЖ.

Какой правильный способ сделать это?

Спасибо

-1
задан 5 March 2014 в 15:27

2 ответа

Необходимо использовать vgreduce на домашнем устройстве и vgextend на устройстве хранения. После этого youhave для использования resize2fs на обоих для изменения размеров файловой системы в противном случае это не будет никакое шоу изменения.

0
ответ дан 5 March 2014 в 15:27

Эти lvresize команда используется для изменения размера логических томов и может использоваться для "торгования" степенями среди двух LVs в той же группе объема.

самый важный флаг для предоставления при использовании lvresize на непустом / активные тома эти -r флаг, который, из страницы справочника:

   -r, --resizefs
          Resize  underlying  filesystem  together with the logical volume
          using fsadm(8).

пока эти -r флаг включен, lvresize изменит размер файловой системы на логическом томе для установки новому размеру LV (автоматически перемещающий любые занятые блоки в области, которая будет уменьшена при уменьшении объема), который гарантирует, что никакие данные не потеряны.

другие важные флаги, для типичного использования, -L и -l флаги для определения целевого размера логического тома или дельты размера. Снова, страница справочника:

   -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, т' тестовые прогоны.

Так, чтобы уменьшить / размещают ~50GB и затем добавить, что пространство к / устройству хранения данных, Вы могли использовать:

# 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 будет просто работать "под" другой активностью диска для реконфигурирования объемов. (По стоимости скорости, конечно.)

0
ответ дан 6 March 2014 в 02:27

Другие вопросы по тегам:

Похожие вопросы: