Member-only story

Fixing “No space left on device” issue in an ec2 instance

Madeesha’s Tech Space
2 min readDec 12, 2022

--

It is really common to receive “No space left on device” if you don’t allocate enough disk space to an ec2 instance. It can be occurred due to an unexpected large log file too. However most of the time, we can’t even run any command or login to the ec2 instance when we receive this error message from the kernel. In this case you can’t increase the EBS volume by logging to the instance. We can resolve this issue by attaching the root volume to a temporary instance, remove unwanted data from the volume and reattaching it to the original ec2. Let’s get into the detailed information on how to do this.

  1. spin up temp instance in same AZ. You may need to attache the same IAM role to the temporary instance to access encrypted root volume data.
  2. stop ec2 instance and detach the volume.
  3. attach the volume to the temporary instance.
  4. mount attached volume. To mount the volume, first you need to run “lsblk” command and list the available block devices. And found the attached disk name. You can use the volume size to find the correct disk name.

Then mount the disk to /mnt directory.

sudo mount /dev/nvme1n1p1 /mnt                                 

--

--

No responses yet