LoginSignup
5
6

More than 5 years have passed since last update.

Fedora25でrootファイルシステムを拡張する

Last updated at Posted at 2017-01-22

fedora 25 (Server Edition)をインストールしてみたら、rootファイルシステムが15GBしかないことに気づいた。

調べても、情報が古かったり断片的だったりするので、メモ書き程度に残しておく

現状調査

ディスクとしては64GBぐらい使えるはず。

[user@host ~]$ df -h
ファイルシス                  サイズ  使用  残り 使用% マウント位置
devtmpfs                        449M     0  449M    0% /dev
tmpfs                           460M     0  460M    0% /dev/shm
tmpfs                           460M  832K  459M    1% /run
tmpfs                           460M     0  460M    0% /sys/fs/cgroup
/dev/mapper/fedora-root          15G  6.4G  8.7G   43% /
tmpfs                           460M  4.0K  460M    1% /tmp
/dev/sda1                       976M  131M  779M   15% /boot
tmpfs                            92M     0   92M    0% /run/user/1000

確かにrootに15GBしか割当たっていない。

では、ボリュームグループの状態はどうか。

[user@host ~]$ sudo vgdisplay 
  --- Volume group ---
  VG Name               fedora
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               63.00 GiB
  PE Size               4.00 MiB
  Total PE              16127
  Alloc PE / Size       4364 / 17.05 GiB
  Free  PE / Size       11763 / 45.95 GiB

VG Size = 63GiB とある。

では、論理ボリュームの状態はどうか。

[user@host ~]$ sudo lvdisplay 
  --- Logical volume ---
  LV Path                /dev/fedora/swap
  LV Name                swap
  VG Name                fedora
  LV Write Access        read/write
  LV Creation host, time host, 2017-01-15 15:04:45 +0900
  LV Status              available
  # open                 2
  LV Size                2.05 GiB
  Current LE             524
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Logical volume ---
  LV Path                /dev/fedora/root
  LV Name                root
  VG Name                fedora
  LV Write Access        read/write
  LV Creation host, time host, 2017-01-15 15:04:45 +0900
  LV Status              available
  # open                 1
  LV Size                15.00 GiB
  Current LE             3840
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

rootのLV Sizeは15GiB。。。

オンライン拡張する

LVMはリブートしなくても拡張できる

まずは、論理ボリュームをザクザクっと拡張する

[user@host ~]$ sudo lvextend -L +20G /dev/fedora/root
  Size of logical volume fedora/root changed from 15.00 GiB (3840 extents) to 35.00 GiB (8960 extents).
  Logical volume fedora/root successfully resized.
[user@host ~]$ sudo lvextend -L +20G /dev/fedora/root
  Size of logical volume fedora/root changed from 35.00 GiB (8960 extents) to 55.00 GiB (14080 extents).
  Logical volume fedora/root successfully resized.
[user@host ~]$ sudo lvextend -L +20G /dev/fedora/root
  Insufficient free space: 5120 extents needed, but only 1523 available
[user@host ~]$ sudo lvextend -L +9G /dev/fedora/root
  Insufficient free space: 2304 extents needed, but only 1523 available
[user@host ~]$ sudo lvextend -L +5G /dev/fedora/root
  Size of logical volume fedora/root changed from 55.00 GiB (14080 extents) to 60.00 GiB (15360 extents).
  Logical volume fedora/root successfully resized.

60GBまで拡張できた。

空き領域を全部使うのならば、以下の方法で一発。

[user@host ~]$ sudo lvextend -l +100%FREE /dev/fedora/root

次に、ファイルシステムを拡張する。
resize2fs はXFSに使えないので、 xfs_growfs を使う。

[user@host ~]$ sudo xfs_growfs /dev/fedora/root
meta-data=/dev/mapper/fedora-root isize=512    agcount=4, agsize=983040 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1 spinodes=0 rmapbt=0
         =                       reflink=0
data     =                       bsize=4096   blocks=3932160, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 3932160 to 15728640

確認してみる。

[user@host ~]$ df -h
ファイルシス                  サイズ  使用  残り 使用% マウント位置
devtmpfs                        449M     0  449M    0% /dev
tmpfs                           460M     0  460M    0% /dev/shm
tmpfs                           460M  832K  459M    1% /run
tmpfs                           460M     0  460M    0% /sys/fs/cgroup
/dev/mapper/fedora-root          60G  6.4G   54G   11% /
tmpfs                           460M  4.0K  460M    1% /tmp
/dev/sda1                       976M  131M  779M   15% /boot
tmpfs                            92M     0   92M    0% /run/user/1000

60GBまで拡張されている。めでたしめでたし。

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6