Amazon EC2 disk resize No space left on device

On an Amazon EC2 instance disk usage was full.

[email protected]:/# df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 791M 8.9M 782M 2% /run
/dev/nvme0n1p1 9.7G 9.6G 65M 100% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/loop0 97M 97M 0 100% /snap/core/9665
/dev/loop1 97M 97M 0 100% /snap/core/9436
/dev/loop2 18M 18M 0 100% /snap/amazon-ssm-agent/1566
/dev/loop3 29M 29M 0 100% /snap/amazon-ssm-agent/2012
tmpfs 791M 0 791M 0% /run/user/998
tmpfs 791M 0 791M 0% /run/user/1000
[email protected]:/#

I increased disk size on Amazone AWS console. But disk did not get changed in EC2 instance.

[email protected]:~# parted -l
Model: NVMe Device (nvme)
Disk /dev/nvme0n1: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
1 1049kB 10.7GB 10.7GB primary ext4 boot

[email protected]:~#

The partition still shows 10 GB. When i try growpart, i get error

[email protected]:/# growpart /dev/nvme0n1 1
mkdir: cannot create directory ‘/tmp/growpart.1889’: No space left on device
FAILED: failed to make temp dir
[email protected]:/#

This is because disk is full. I try delete some unwanted files. But was not able to free up much disk space. To fix the error, i mounted /tmp in memory with commands.

mkdir /dev/shm/tmp
chmod 1777 /dev/shm/tmp
mount –bind /dev/shm/tmp /tmp

This ec2 instance had lot of free RAM, so it should handle /tmp folder with out any issue. Now growpart worked.

[email protected]:/# growpart /dev/nvme0n1 1
CHANGED: partition=1 start=2048 old: size=20969439 end=20971487 new: size=41940959,end=41943007
[email protected]:/#

parted -l shows the partition using all available disk space

[email protected]:/# parted -l
Model: NVMe Device (nvme)
Disk /dev/nvme0n1: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
1 1049kB 21.5GB 21.5GB primary ext4 boot

[email protected]:/#

still df -h won’t show increased disk space, this is because you need to increase filesystem size.

resize2fs /dev/nvme0n1p1

Leave a Comment

Your email address will not be published. Required fields are marked *

Hire a server Expert to resolve the issue Now.

Hire a server Expert to resolve the issue Now.

Resolve this issue in just 5$ from https://serverexpert.io

 

You have Successfully Subscribed!

Open chat