LVMシステムでのext4ファイルシステム拡張

スポンサーリンク

ボリュームグループ内に空きがある状態で、論理ボリュームおよびファイルシステム(ext4)を拡張します。

検証した環境

$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
$ uname -r
5.15.56-v8+

変更前の状態

$ df -Th /data
Filesystem                Type  Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-lvdata ext4   20G   15G  4.2G  78% /data

論理ボリュームの拡張とファイルシステム拡張

$ sudo vgdisplay rootvg
  --- Volume group ---
  VG Name               rootvg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  17
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                11
  Open LV               10
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <223.07 GiB
  PE Size               4.00 MiB
  Total PE              57105
  Alloc PE / Size       26880 / 105.00 GiB
  Free  PE / Size       30225 / <118.07 GiB
  VG UUID               83GKze-HuNR-fAaJ-cxM0-7ujj-dlr5-YNmzMo

$ sudo lvextend -l +12800 /dev/mapper/rootvg-lvdata ・・・ 12800x4MB=51200MB
  Size of logical volume rootvg/lvdata changed
 from 20.00 GiB (5120 extents) to 70.00 GiB (17920 extents).
  Logical volume rootvg/lvdata successfully resized.
$ sudo vgdisplay rootvg
  --- Volume group ---
  VG Name               rootvg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  18
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                11
  Open LV               10
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <223.07 GiB
  PE Size               4.00 MiB
  Total PE              57105
  Alloc PE / Size       39680 / 155.00 GiB
  Free  PE / Size       17425 / <68.07 GiB
  VG UUID               83GKze-HuNR-fAaJ-cxM0-7ujj-dlr5-YNmrMo

$ sudo resize2fs /dev/mapper/rootvg-lvdata
resize2fs 1.46.2 (28-Feb-2021)
Filesystem at /dev/mapper/rootvg-lvdata is mounted on /data; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 9
The filesystem on /dev/mapper/rootvg-lvdata is now 18350080 (4k) blocks long.

変更後の確認

$ df -Th /data
Filesystem                Type  Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-lvdata ext4   69G   15G   52G  22% /data