1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

複数パーティションが存在するディスク上のext4やxfsパーティションを拡張するには

Last updated at Posted at 2021-06-18

【1】パーティションの拡張

1.cfdiskを実行する

# cfdisk /dev/sda

2.拡張したいパーティションを選択し、[Resize]を選択する

                                                    Disk: /dev/sda
                                 Size: 150 GiB, 161061273600 bytes, 314572800 sectors
                             Label: gpt, identifier: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

    Device                           Start                End           Sectors          Size Type
    /dev/sda1                         2048               4095              2048            1M BIOS boot
 >> /dev/sda2                         4096          209713151         209709056          100G Linux filesystem
    Free space                   209713152          314572766         104859615           50G
 lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
 xPartition UUID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX                                                             x
 xPartition type: BIOS boot (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)                                                  x
 xFilesystem UUID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX                                                             x
 mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

                  [ Delete ]  [ Resize ]  [  Quit  ]  [  Type  ]  [  Help  ]  [  Write ]  [  Dump  ]
                  ↑
                  └ これを選択

3.拡張後のサイズを指定する。拡張可能な最大サイズで良ければ、そのままEnterキーを押下する

 New size: 150G

4.指定されたパーティションの容量が拡張されたことを確認し、[Write]を選択する

                                                    Disk: /dev/sda
                                 Size: 150 GiB, 161061273600 bytes, 314572800 sectors
                             Label: gpt, identifier: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

    Device                        Start                End            Sectors           Size Type
    /dev/sda1                      2048               4095               2048             1M BIOS boot
>>  /dev/sda2                      4096          314572766          314568671           150G Linux filesystem
 lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
 xPartition UUID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX                                                             x
 xPartition type: BIOS boot (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)                                                  x
 xFilesystem UUID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX                                                             x
 mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
                  [ Delete ]  [ Resize ]  [  Quit  ]  [  Type  ]  [  Help  ]  [  Write ]  [  Dump  ]
                                             ↑
                                             └ これを選択

5.パーティションテーブルをディスクに書いて良いか聞かれるので、「yes」と入力する

 Are you sure you want to write the partition table to disk? yes

6.[Quit]を選択する

                  [ Delete ]  [ Resize ]  [  Quit  ]  [  Type  ]  [  Help  ]  [  Write ]  [  Dump  ]
                         ↑
                         └ これを選択

【2】ファイルシステムに対して、拡張後の容量を認識させる

ext4パーティションを拡張する場合

resize2fs <ブロックデバイス(パーティション)名> を実行する。

# resize2fs /dev/sda2
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old_desc_blocks = 13, new_desc_blocks = 19
The filesystem on /dev/sda2 is now 39321083 (4k) blocks long.

xfsパーティションを拡張する場合

xfs_growfs <ブロックデバイス(パーティション)名> を実行する。

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?