Software

OSError: [Errno 28] No space left on device

突然有一天早上發現 GCP 上面有台 CE 無法開機
經過 Serial port 的查詢出現了 OSError: [Errno 28] No space left on device 的訊息
查了一下應該是硬碟空間不足造成了
解法就是擴充現在有硬碟空間
但是問題來了,沒辦法 SSH 進去所以只能使用另外一台機器掛載上去後再擴充然後再掛回去
以下是擴充的指令

確認磁碟編號

sudo fdisk -l
### 出現了剛剛擴充的空間,但是還沒分配
GPT PMBR size mismatch (62914559 != 268435455) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
Disk /dev/sdb: 128 GiB, 137438953472 bytes, 268435456 sectors
Disk model: PersistentDisk  
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: EB01DF16-EC92-4726-92F5-A49044CC806F

Device      Start      End  Sectors  Size Type
/dev/sdb1  227328 62914526 62687199 29.9G Linux filesystem
/dev/sdb14   2048    10239     8192    4M BIOS boot
/dev/sdb15  10240   227327   217088  106M EFI System

然後將磁碟 monut 起來

sudo mount -t ext4 /dev/sdb1 ./tmp/

使用 growpart 做分配

sudo growpart /dev/sdb 1

### 將空間分配給 sdb1
CHANGED: partition=1 start=227328 old: size=62687199 end=62914527 new: size=268208095 end=268435423

resize 空間

sudo resize2fs /dev/sdb1

### 完成resize
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/sdb1 is mounted on /home/bright_su72/tmp; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 16
The filesystem on /dev/sdb1 is now 33526011 (4k) blocks long.

上面步驟都完成後使用 umount 卸載後再重新掛回原本的 CE 就可以了