本頁說明調整永久磁碟大小或永久磁碟空間不足時,可能遇到的常見問題,以及各項問題的修正方式。
事前準備
- 請務必建立磁碟快照,再執行任何疑難排解步驟,確保資料已備份。
-
如果尚未設定驗證,請先完成設定。
「驗證」是指驗證身分的程序,確認您有權存取 Google Cloud 服務和 API。如要從本機開發環境執行程式碼或範例,請選取下列其中一個選項,向 Compute Engine 進行驗證:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
-
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
- Set a default region and zone.
- 您每 6 小時只能調整一次 Extreme 永久磁碟或 Hyperdisk Throughput 磁碟區的大小。
- 您每 4 小時只能調整一次 Hyperdisk Extreme 磁碟區大小。
- 每 4 小時只能變更一次 Hyperdisk 磁碟區的佈建 IOPS 或處理量。
確認 VM 的 SSH 失敗是否是因為啟動磁碟空間不足:
gcloud compute instances tail-serial-port-output VM_NAME
如果開機磁碟已滿,輸出結果會包含
No space left on device
訊息。如果尚未建立快照,請建立 VM 開機磁碟的快照。
嘗試重新啟動 VM。
如果還是無法存取 VM,請按照下列步驟操作:
停止 VM:
gcloud compute instances stop VM_NAME
將您的 VM 名稱替換為
VM_NAME
。增加開機磁碟大小:
gcloud compute disks resize BOOT_DISK_NAME --size DISK_SIZE
更改下列內容:
BOOT_DISK_NAME
:VM 啟動磁碟的名稱DISK_SIZE
:開機磁碟的新大小 (以 GB 為單位)
舉例來說,如要將名為
example-disk-1
的磁碟大小調整為 6 GB,請執行下列指令:gcloud compute disks resize example-disk-1 --size=6GB
啟動 VM:
gcloud compute instances start VM_NAME
再次嘗試 透過 SSH 連線至 VM。 如果還是無法存取 VM,請執行下列其中一項操作:
使用快照建立新磁碟。詳情請參閱「復原無法存取的 VM 或整個開機磁碟」。
使用開放原始碼 GCE Rescue 工具,暫時以救援模式啟動 VM,然後執行「檔案系統問題」一節中的步驟。
使用下列其中一種方法,檢查 VM 是否已調整開機磁碟大小:
檢查序列埠輸出內容。 尋找指出根分區已調整大小的行。
舉例來說,在搭載 Debian 映像檔的 VM 上,如果自動調整大小成功,主控台記錄檔會包含
... expand-root.sh[..]: Resizing ext4 filesystem on /dev/sda1
這行。如果可以使用 SSH 連線至 Linux VM,請執行
df -h
指令,檢查是否有可用磁碟空間。舉例來說,以下輸出內容顯示根檔案系統已使用 92% 的空間:
Filesystem Size Used Avail Use% Mounted on udev 63G 0 63G 0% /dev tmpfs 13G 1.4M 13G 1% /run /dev/sda1 339G 315G 24G 92% /
如果 VM 未調整根檔案系統大小,請手動調整檔案系統和分區大小。
REST
如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
詳情請參閱 Google Cloud 驗證說明文件中的「Authenticate for using REST」。
修改磁碟時發生速率限制錯誤
嘗試修改 Extreme Persistent Disk 或 Google Cloud Hyperdisk 時,您可能會遇到下列常見錯誤。您可能會在許多地方看到這些錯誤,例如在序列埠控制台輸出內容或應用程式記錄中。
Disk cannot be resized due to being rate limited.
Cannot update provisioned iops due to being rate limited.
Cannot update provisioned throughput due to being rate limited.
修改磁碟的時間限制如下:
如要解決這些錯誤,請等待一段時間 (自上次修改磁碟起算),然後再嘗試修改磁碟。
磁碟容量錯誤
磁碟已滿
當永久磁碟達到容量上限時,您可能會遇到下列常見錯誤。您可能會在多個位置看到這些錯誤,例如在序列埠控制台輸出或應用程式記錄中。
No space left on device
Not enough storage is available to process this command
如要解決這個問題,請按照下列步驟操作:
開機磁碟空間不足,導致無法存取 VM
如果 VM 的開機磁碟已滿,您可能無法存取 VM。這種情況很難判斷,因為 VM 連線問題不一定是由開機磁碟空間不足所致。如果開機磁碟已滿,導致您無法透過 Google Cloud CLI 存取 VM,可能會遇到下列常見錯誤:
Network error: Software caused connection abort
ERROR: (gcloud.compute.ssh) Could not SSH into the instance. It is possible that your SSH key has not propagated to the instance yet. Try running this command again. If you still cannot connect, verify that the firewall and instance are set to accept ssh traffic.
You cannot connect to the VM instance because of an unexpected error. Wait a few moments and then try again.
No space left on device
ERROR Exception calling the response handler. [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']...
如要解決上述問題,請按照下列步驟操作:
檔案系統問題
調整檔案系統大小
調整 VM 開機磁碟大小後,大多數 VM 會調整根檔案系統大小,並重新啟動 VM。不過,部分 VM 映像檔類型可能需要手動調整檔案系統大小。如果 VM 不支援自動調整根檔案系統大小,或是您已調整資料 (非開機) 永久磁碟的大小,就必須手動調整檔案系統和磁碟分區的大小。
如要確認根檔案系統是否在您調整 VM 開機磁碟大小後自動擴充,請按照下列步驟操作:
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-21 (世界標準時間)。
-