Ubuntu GCE 在调整磁盘大小后没有看到新的系统磁盘 space

Ubuntu GCE does not see new system disk space after disk resize

我有一个 Ubuntu 16.04.3 LTS GCE 实例。 我增加了系统磁盘 space(从 20 GB 到 30 GB)但是在 GCE 重启后,如果我 运行

df -h 

我还有 20GB 的磁盘空间。

过去,在 Ubuntu 个 GCE 实例上,实例重启后,系统会自动看到新磁盘 space。

也在我阅读的文档中:

"Alternatively, instances that use most recent versions of Public Images can automatically resize their partitions and file systems after a system reboot. The SUSE Linux Enterprise Server (SLES) public images are the only images that do not support this feature."

所以,问题是什么? 我该怎么做才能获得新的 space?

你可以执行:

$ sudo lsblk
$ sudo resize2fs /dev/sda1 30G

如果您收到消息:

The filesystem is already 5242619 (4k) blocks long. Nothing to do!

抱歉,我认为您无法使用 resize2fs 调整磁盘大小。

所以,我知道您可以遵循两个备选方案。

选择 1 - 在 VM 中附加另一个磁盘。

备选方案 2 - 从原始磁盘的快照创建新磁盘。 从快照创建磁盘的步骤:

  1. 停止机器(没必要但很安全)
  2. 拍摄快照
gcloud beta compute disks snapshot <disk_name> --project=<project_id> --snapshot-names=snapshot-1 --zone=<zone> --storage-location=us 
  1. 从该快照创建新机器