GCPの
Google Compute Engine(GCE)のローカルディスクの拡張方法です。
インスタンス名は、test-serverとしてご説明します。
(us-east1-d、centos-7-v20171003環境)
拡張前のディスク状態
1 2 3 4 5 6 7 8 |
[root@test-server ~]$ df -lh Filesystem Size Used Avail Use% Mounted on /dev/sda1 10G 1.5G 8.6G 15% / devtmpfs 288M 0 288M 0% /dev tmpfs 295M 0 295M 0% /dev/shm tmpfs 295M 4.3M 290M 2% /run tmpfs 295M 0 295M 0% /sys/fs/cgroup tmpfs 59M 0 59M 0% /run/user/1001 |
ディスクサイズ変更
[test-server] – [VM インスタンスの詳細]
ブートディスクとローカルディスクにあるディスクのリンクを押し、
[ディスク]画面に移動し、編集ボタン(鉛筆マーク)を押します。
[サイズ]を10GB→20GBに編集して保存します。
これで、コンソース上は、20GBになります
インスタンスを再起動すると、サーバー上でも 20GBになります。
1 2 3 4 5 6 7 8 9 |
root@test-server ~]$ df -lh Filesystem Size Used Avail Use% Mounted on /dev/sda1 20G 1.6G 19G 8% / devtmpfs 288M 0 288M 0% /dev tmpfs 295M 0 295M 0% /dev/shm tmpfs 295M 4.3M 290M 2% /run tmpfs 295M 0 295M 0% /sys/fs/cgroup tmpfs 59M 0 59M 0% /run/user/0 tmpfs 59M 0 59M 0% /run/user/1001 |
これでディスクの拡張は完了です。
反映されない場合
OSによっては 上記処理では反映されず、手動でコマンド処理をする必要があります。(1年前は、この後の「コマンド処理」をする必要がある環境が多かったのですが、今は、ほとんど、この処理はいらなくなってきていると思います)
▼オペレーティング システムが自動サイズ変更をサポートしているかどうか
https://cloud.google.com/compute/docs/disks/create-root-persistent-disks#autoresize
コマンド処理で失敗すると、
「接続できませんでした
ポート 22 で VM に接続できません。この問題の考えられる原因の詳細についてご確認ください。」
となって、SSHログインできず、どうしようもなくなる場合があるので、
処理をする前には スナップショットは必ず取っておきましょう。
◆コマンド処理(自動サイズ変更をサポートしていない場合)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
[root@test-server ~]$ fdisk /dev/sda Command (m for help): d //パーティションを削除 Selected partition 1 Command (m for help): n //パーティションを作成 Command action e extended p primary partition (1-4) p //プライマリパーティションを作成 Partition number (1-4): 1 First sector (2048-31457279, default 2048): //デフォルトのまま Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-31457279, default 31457279): //デフォルトのまま Using default value 31457279 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. 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) Syncing disks. |
1 |
[root@test-server ~]$ reboot |
再起動後、以下コマンドを打てば完了です。
1 |
[root@test-server ~]$ xfs_growfs /dev/sda1 |