GCE 调整永久磁盘大小

GCE Resizing Persistent Disks

我在调整永久磁盘的大小时遇到​​问题。磁盘 "z-temp" (10GB) 只有一个分区(Ubuntu 16)。 我在这里遵循 google 指南: https://cloud.google.com/compute/docs/disks/add-persistent-disk#resize_partitions 我对第 3 步有疑问。 当我 运行 命令

sudo resize2fs /dev/disk/by-id/google-z-temp

这是结果:

resize2fs 1.42.13 (17-May-2015)
resize2fs: Device or resource busy while trying to open /dev/disk/by-id/google-z-temp
Couldn't find valid filesystem superblock.

有什么问题?

如果您的 OS 位于该磁盘中,我建议您为您的文件添加另一个磁盘而不是分区。根据 Google here.

的推荐

"Compute Engine handles most disk management tasks for you so that you do not need to deal with partitioning, redundant disk arrays, or subvolume management. You can apply these practices to your persistent disks if you want, but you can save time and get the best performance if you format your persistent disks with a single file system and no partition tables. If you need to separate your data into multiple unique volumes, create additional disks rather than dividing your existing disks into multiple partitions."

但如果不可能,

检查是否

fdisk -l /dev/sda

显示正确的磁盘大小,如果是,运行

pvresize

调整分区大小。最后,

lvextend -r -l +100%FREE /dev/mapper/...

我遇到了同样的问题,结果我只需要重新启动实例,然后它就会自动调整大小。如果您调整根磁盘的大小,此行为与 documentation 一致:

If you create or resize a root persistent disk or create a disk from an image or a snapshot, your virtual machine instance can automatically resize the partition to recognize the additional space after you restart the instance.