CentOS7 LVM構成されたディスクのファイルシステム拡張

シェアする

LVMで構成されたディスクで、VGにも余裕があるので、ゲストOSのイメージを格納しているパーティションの容量を拡張することにしました。

容量拡張前の確認

対象となるパーティションの容量を拡張する前に状態を確認します。

# df -T /virt <LF>
Filesystem                Type 1K-blocks      Used Available Use% Mounted on
/dev/mapper/centos00-virt xfs  209664000 178062568  31601432  85% /virt
# vgdisplay <LF> <= VGの情報を確認
  --- Volume group ---
  VG Name               centos00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  24
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                8
  Open LV               8
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               930.88 GiB <= VGの全サイズ
  PE Size               4.00 MiB <= 物理区画のサイズ
  Total PE              238306
  Alloc PE / Size       57856 / 226.00 GiB <= 割当サイズ
  Free  PE / Size       180450 / 704.88 GiB <= 空きサイズ
  VG UUID               xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxx
# lvdisplay /dev/centos00/virt <LF>
  --- Logical volume ---
  LV Path                /dev/centos00/virt
  LV Name                virt
  VG Name                centos00
  LV UUID                xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxxx
  LV Write Access        read/write
  LV Creation host, time host01.orange.daemon.asia, 2015-05-12 13:36:41 +0900
  LV Status              available
  # open                 1
  LV Size                200.00 GiB <= LVの全サイズ
  Current LE             51200
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:6

容量拡張の実施

VGには、まだ余裕がありますので、200GiB分を増分させることにします。

# lvextend -L +204800MB /dev/centos00/virt <LF> <= LVの拡張
 Size of logical volume centos00/virt changed from 200.00 GiB (51200 extents) to 400.00 GiB (102400 extents).
 Logical volume virt successfully resized
# lvdisplay /dev/centos00/virt <LF>
  --- Logical volume ---
  LV Path                /dev/centos00/virt
  LV Name                virt
  VG Name                centos00
  LV UUID                xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxxx
  LV Write Access        read/write
  LV Creation host, time host01.orange.daemon.asia, 2015-05-12 13:36:41 +0900
  LV Status              available
  # open                 1
  LV Size                400.00 GiB
  Current LE             102400
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:6
# xfs_growfs /dev/centos00/virt <LF> <= ファイルシステムを拡張(CentOS7からはコレ)
meta-data=/dev/mapper/centos00-virt isize=256 agcount=8, agsize=6553600 blks
         =                       sectsz=512 attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096 blocks=52428800, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=12800, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 52428800 to 104857600

容量拡張後の確認

容量を拡張後に想定どおりに出来ているかを確認します。

# df -T /virt <LF>
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/mapper/centos00-virt xfs 419379200 178062824 241316376 43% /virt
# lvdisplay /dev/centos00/virt <LF>
  --- Logical volume ---
  LV Path                /dev/centos00/virt
  LV Name                virt
  VG Name                centos00
  LV UUID                xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxxx
  LV Write Access        read/write
  LV Creation host, time host01.orange.daemon.asia, 2015-05-12 13:36:41 +0900
  LV Status              available
  # open                 1
  LV Size                400.00 GiB
  Current LE             102400
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:6
# vgdisplay <LF>
  --- Volume group ---
  VG Name               centos00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  25
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                8
  Open LV               8
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               930.88 GiB
  PE Size               4.00 MiB
  Total PE              238306
  Alloc PE / Size       109056 / 426.00 GiB
  Free  PE / Size       129250 / 504.88 GiB
  VG UUID               xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxxx