เพิ่ม Storage EBS บน EC2

  • เช็ค Disk
$ df -h
...
Filesystem      Size  Used Avail Use% Mounted on
udev            966M     0  966M   0% /dev
tmpfs           196M   21M  176M  11% /run
/dev/nvme0n1p1  7.7G  7.7G     0 100% /
tmpfs           978M     0  978M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           978M     0  978M   0% /sys/fs/cgroup
/dev/loop1       18M   18M     0 100% /snap/amazon-ssm-agent/1566
/dev/loop2       98M   98M     0 100% /snap/core/9289
/dev/loop3       29M   29M     0 100% /snap/amazon-ssm-agent/2012
/dev/loop4       97M   97M     0 100% /snap/core/9436
tmpfs           196M     0  196M   0% /run/user/1000

No space left on device


Step 1 คลิด Volumes ตรง ELASTIC BLOCK STORE menu (แถบซ้ายมือ)

aws-ebs1.png

Resize and Click Modify

Step 2 Remote to Server and Check disk

$ lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop1         7:1    0   18M  1 loop /snap/amazon-ssm-agent/1566
loop2         7:2    0   97M  1 loop /snap/core/9289
loop3         7:3    0 28.1M  1 loop /snap/amazon-ssm-agent/2012
loop4         7:4    0 96.5M  1 loop /snap/core/9436
nvme0n1     259:0    0   20G  0 disk
└─nvme0n1p1 259:1    0    8G  0 part /

Step 3 จากนั้น attempt to increase the root partition

$ sudo growpart /dev/nvme0n1 1
CHANGED: partition=1 start=2048 old: size=16775135 end=16777183 new: size=41940959,end=41943007

*ในกรณีที่ growpart แล้ว ขึ้น no space left *

  • วิธีแก้
$ sudo mount -o size=10M,rw,nodev,nosuid -t tmpfs tmpfs /tmp
$ sudo growpart /dev/nvme0n1 1 
...
CHANGED: partition=1 start=4096 old: size=16773087 end=16777183 new: size=18870239 end=18874335
  • จากนั้น unmount /tmp หลังจากทำ step 4
$ sudo umount /tmp

Step 4 Resize

$ sudo resize2fs /dev/nvme0n1p1 

เช็ค Disk อีกครั้ง

$ df -h
...
Filesystem      Size  Used Avail Use% Mounted on
udev            966M     0  966M   0% /dev
tmpfs           196M  3.3M  193M   2% /run
/dev/nvme0n1p1   20G  7.8G   12G  40% /
tmpfs           978M     0  978M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           978M     0  978M   0% /sys/fs/cgroup
/dev/loop1       18M   18M     0 100% /snap/amazon-ssm-agent/1566
/dev/loop2       98M   98M     0 100% /snap/core/9289
/dev/loop3       29M   29M     0 100% /snap/amazon-ssm-agent/2012
/dev/loop4       97M   97M     0 100% /snap/core/9436
tmpfs           196M     0  196M   0% /run/user/1000
July 3, 2020