EC2 Ubuntu Instance: 30GB Attached Volume Says No Space Left, But Device Has Space

Abstract: Resolve No space left on device errors on EC2 Ubuntu by fixing Docker inode exhaustion or cleaning unused images and logs.

Created: 2026-09-01 by
The "No space left on device" error on an AWS EC2 Ubuntu instance with a 30GB attached volume typically stems from Docker consuming all available disk space or inodes, rather than the underlying EBS volume being full. This occurs because Docker stores images, containers, and logs in specific directories that can grow rapidly during builds or runtime operations. Resolving this requires identifying whether the issue is related to data blocks or inode exhaustion, then cleaning up unused resources.

Understanding the Root Cause

When you encounter a no space left on device error despite having free space reported by df -h, the problem is often related to how Docker manages storage. Docker uses a storage driver (typically overlay2) to manage image layers and container writable layers. If these layers accumulate without cleanup, they fill up the allocated space on your EBS volume. Additionally, if every file on the volume is small (such as log files or temporary build artifacts), you might run out of inodes even if megabytes of space remain. This distinction is critical for diagnosing the issue correctly.

Detecting Inode Exhaustion

Before assuming the volume is full of data, verify if you have exhausted the number of inodes. Inodes are metadata structures that store information about files. Each file, directory, or symbolic link consumes one inode. When the inode count reaches the maximum limit defined when the filesystem was created, no new files can be created, resulting in the same error message. To check inode usage, run the following command:
df -i
Look at the IUse% column for your root partition or the mounted volume. If it shows 100% or close to it, you have an inode exhaustion issue. This is common in environments where many small files are generated, such as during frequent Docker builds or application logging.

Cleaning Up Docker Resources

Docker is frequently the culprit for rapid disk space consumption. It retains unused images, stopped containers, and dangling volumes that take up significant space. To reclaim this space safely, use the Docker system prune command. This command removes stopped containers, unused networks, dangling images, and build cache. Execute the following command to clean up resources:
docker system prune -a --volumes
The -a flag ensures all unused images are removed, not just dangling ones, and --volumes deletes anonymous volumes that are no longer referenced by any container. Be cautious, as this action is irreversible. Ensure you do not need any of the removed resources before executing. For more targeted cleanup, you can remove specific stopped containers using docker rm or images using docker rmi.

Managing Disk Space on Ubuntu

If Docker cleanup does not resolve the issue, investigate other processes consuming space on the Ubuntu instance. Check large directories using the du command to identify which folders are taking up the most space. For example, to find the top 10 largest directories in the current path, run:
du -ah . | sort -rh | head -n 10
Common culprits include old kernel versions, log files in /var/log, and cached package files in /var/cache/apt. You can clear the APT cache by running sudo apt-get clean. Additionally, rotate or compress old log files to prevent them from growing indefinitely. Regular maintenance of these areas helps maintain sufficient free space for system operations.

Expanding the EBS Volume

If cleaning up resources is insufficient and your applications legitimately require more space, consider expanding the EBS volume. AWS allows you to increase the size of an existing EBS volume without stopping the instance. First, modify the volume through the AWS Management Console or CLI to increase its capacity. After resizing the volume, you must extend the filesystem to utilize the additional space. On Ubuntu, this typically involves using resize2fs for ext4 filesystems or xfs_growfs for XFS. Verify the new space with df -h after completing the resize operation.

Preventive Measures

To avoid recurring space issues, implement automated cleanup policies. Configure Docker to automatically prune unused resources periodically using cron jobs or systemd timers. Monitor disk usage with tools like prometheus-node-exporter integrated with Grafana for real-time alerts. Set up log rotation for application logs to ensure they do not consume excessive space. By proactively managing resources, you can maintain a stable environment and prevent unexpected service disruptions due to disk space exhaustion.

Frequently Asked Questions

How do I check if my EBS volume is actually full?

Run df -h to view the percentage of used space on each mounted filesystem. If the usage is below 100% but you still get the error, the issue is likely inode exhaustion or Docker-specific storage management rather than raw volume capacity.

Can I recover space from stopped Docker containers?

Yes, stopped containers occupy disk space. Use docker ps -a to list all containers, including stopped ones. Remove unwanted containers with docker rm <container_id> to free up the space they were using.

What causes inode exhaustion on an Ubuntu instance?

Inode exhaustion happens when too many small files are created, exceeding the maximum number of inodes allowed on the filesystem. This is common with applications generating many temporary files or logs, even if total data size is low.

How do I expand an EBS volume online?

You can increase the volume size via the AWS Console while the instance is running. After resizing, use resize2fs or xfs_growfs to extend the filesystem. No downtime is required for the expansion process itself.

Why does Docker consume so much space on EC2?

Docker stores image layers, container writable layers, and build caches locally. Without regular pruning, these components accumulate over time, especially during development or continuous integration workflows, leading to rapid space consumption.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More