[GCE] Google Compute Engine + CentOS 7에서 Disk용량 늘리기.

최근 워드프레스나 기타 서비스가 제대로 작동하지 않아(특히 파일 업로드) 로그를 보니 용량이 다 찼다고 한다. 구글 클라우드의 VM의 경우 기본이 10GB라서 그런가..

그래서 본래 하던대로 아래와 같이 처리.

1. 기존 디스크를 snapshot

2. 새로운 디스크를 새로 뜬 스냅샷을 기반으로 한 100GB로 세팅하여 새로 만듬

3. compute engine에 기존 VM을 또 다시 복제하여 새로 만든 디스크와 연결

4. 기존VM 삭제 

5. 사용하던 IP를 복제된 VM​에 연결

이렇게 하면 끝일 줄 알았는데, 실제로 du -h하면 /dev/sda1 이 100%라고 나온다. 

왜일까? 해서 인터넷을 뒤져보니, GCE문서에 의하면 운영체제별로 자동 리사이징이 되는게 있고 안되는게 있덴다.

Operating systems supported by Compute Engine team Automatic Resizing
Ubuntu Yes.

All Compute Engine Ubuntu images will automatically resize the root partition to use the entire disk, up to a 2 TB limit. Even if the disk is larger than 2 TB, the operating system only recognizes up to 2 TB.

Windows Yes.

All Windows images will automatically resize the root partition up to 2 TB limit. Even if the disk is larger than 2 TB, the operating system only recognizes up to 2 TB.

Debian 7 & Debian 7 backports & Debian 8v20150127 or newer Supports a partial automatic resize.

These images will automatically resize root partitions up to 2 TB. In the future, for disks larger than 2 TB, Compute Engine will support automatically resizing up to the full disk space.

Note: On non-backport Debian 7 images, it might take longer for automatic resizing to finish. If your instance is not seeing the updated size, wait a couple of seconds, and check again.

All other operating systemssupported by Compute Engine No.

All other operating systems supported by the Compute Engine team will only partition enough space for the root filesystem, and do not currently recognize the additional space until you repartition the disk manually.

즉, CentOS 7을 사용중인 나는 수동으로 리파티션을 해줘야 한다는 것.

https://cloud.google.com/compute/docs/disks/persistent-disks#manualrepartition

위 링크의 방법대로 따라하면, 아주 쉽다. 참고로 나는 뭐 인스턴트 생성 그런거 없이 웹 콘솔에서 다 했으므로, 그냥 fdisk부터 해서 방법대로 처리했다.

주의할 점은, Cent OS7 은 resize2fs 가 안먹고 xfs_growfs 를 해줘야 한다는 것.(아래 참조)

Note: If you are running a CentOS 7 image, run the following command to resize your partition instead:

$ sudo xfs_growfs /