本頁說明調整永久磁碟大小或永久磁碟已滿時可能遇到的常見問題,以及如何修正這些問題。
事前準備
- 請務必先建立磁碟快照,再執行任何疑難排解步驟,以確保資料已備份。
-
如果尚未設定,請先設定驗證機制。驗證是指驗證身分,以便存取 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.
REST
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the 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.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
-
修改磁碟時發生速率限制錯誤
以下是嘗試修改 Extreme 持久磁碟或 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.
請查看下列磁碟修改時間限制:
- 您只能在 6 小時內調整一次 Extreme 永久磁碟或 Hyperdisk 吞吐量磁碟區的大小。
- 在 4 小時內,您只能調整一次 Hyperdisk Extreme 磁碟區的大小。
- 每 4 小時只能變更一次 Hyperdisk 磁碟區的已配置 IOPS 或處理量。
如要解決這些錯誤,請等待上次修改後的必要時間,然後再嘗試再次修改磁碟。
磁碟容量錯誤
磁碟已滿
以下是常見的錯誤訊息,您可能會在永久磁碟達到容量上限時遇到這些錯誤。您可能會在多個位置看到這些錯誤,例如序列主控台輸出內容或應用程式記錄。
No space left on device
Not enough storage is available to process this command
如要解決這個問題,請按照下列步驟操作:
開機磁碟已滿,因此無法存取 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 的 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_NAME
替換為您的 VM 名稱。增加開機磁碟的大小:
gcloud compute disks resize BOOT_DISK_NAME --size DISK_SIZE
更改下列內容:
BOOT_DISK_NAME
:VM 的啟動磁碟名稱DISK_SIZE
:開機磁碟的新大尺寸 (以 GB 為單位)
舉例來說,如要將名為
example-disk-1
的磁碟大小調整為 6GB,請執行下列指令:gcloud compute disks resize example-disk-1 --size=6GB
啟動 VM:
gcloud compute instances start VM_NAME
重新嘗試透過 SSH 連線至 VM。如果仍無法存取 VM,請執行下列其中一項操作:
使用快照建立新磁碟。詳情請參閱「復原無法存取的 VM 或整個開機磁碟」。
使用開放原始碼 GCE Rescue 工具,暫時以救援模式啟動 VM,然後執行「檔案系統問題」一節中的步驟。
檔案系統問題
調整檔案系統大小
調整 VM 開機磁碟大小後,大多數 VM 都會調整根檔案系統的大小,並重新啟動 VM。不過,對於某些 VM 映像檔類型,您可能必須手動調整檔案系統大小。如果 VM 不支援自動調整根檔案系統大小,或是您已調整資料 (非開機) 永久磁碟的大小,就必須手動調整檔案系統和分區的大小。
如要檢查根檔案系統是否在您調整 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 未調整根檔案系統的大小,請手動調整檔案系統和分區的大小。