LoginSignup
41
43

More than 5 years have passed since last update.

VirtualBox環境下でのCentOS7ディスク拡張[2018-10] 

Posted at

VirtualBoxの最近のバージョンでのVMディスクの拡張方法(2018年10月)

環境:

VirtualBox 5.2.18
CentOS 7.5
※デフォルト最小構成でインストール

手順:

まずは仮想基盤上での拡張

[GUIからできるようになっている!!]

  • 対象VM停止

  • VirtualBox画面右上のグローバルツール→
    ハードディスク→
    対象VMのディスク→
    プロパティ→
    サイズ変更(拡張)→
    適用

  • 対象VM起動

次にfdiskによるパーティションの拡張

# fdisk /dev/sda

コマンド (m でヘルプ): p
Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectors

デバイス ブート      始点        終点     ブロック   Id  システム
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    33554431    15727616   8e  Linux LVM

コマンド (m でヘルプ): d
パーティション番号 (1,2, default 2): 2
Partition 2 is deleted

コマンド (m でヘルプ): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended

Select (default p): p
パーティション番号 (2-4, default 2):
最初 sector (2099200-62914559, 初期値 2099200):
初期値 2099200 を使います
Last sector, +sectors or +size{K,M,G} (2099200-62914559, 初期値 62914559):
初期値 62914559 を使います
Partition 2 of type Linux and of size 29 GiB is set

コマンド (m でヘルプ): w
パーティションテーブルは変更されました!

ioctl() を呼び出してパーティションテーブルを再読込みします。

WARNING: Re-reading the partition table failed with error 16: デバイスもしくはリソースがビジー状態です.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
ディスクを同期しています

# reboot

最後にLVM拡張

# pvresize /dev/sda2
# lvextend -l +100%FREE /dev/centos/root
# xfs_growfs /dev/centos/root

以上です。

41
43
2

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
41
43