How to Access and Use Ephemeral Storage (Instance Store) on AWS EC2 Instances


2 views

When launching an EC2 instance with both EBS and instance store volumes, many developers encounter confusion about accessing the ephemeral storage. The AWS documentation states that certain instance types come with instance store volumes (like the 160GB mentioned), but these don't automatically appear in your filesystem.

First, let's verify what storage devices are actually available to your instance. The lsblk command provides the most comprehensive view:


$ lsblk
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0   8G  0 disk 
└─xvda1 202:1    0   8G  0 part /
xvdb    202:16   0 160G  0 disk

In this output, xvdb represents our 160GB instance store volume that isn't yet mounted.

To make this storage available, we need to format and mount it. Here's the complete process:


# Create a filesystem (ext4 in this example)
$ sudo mkfs -t ext4 /dev/xvdb

# Create a mount point
$ sudo mkdir /mnt/ephemeral

# Mount the volume
$ sudo mount /dev/xvdb /mnt/ephemeral

# Verify the mount
$ df -h /mnt/ephemeral
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvdb       158G   60M  150G   1% /mnt/ephemeral

To ensure the instance store remains mounted after reboots, add an entry to /etc/fstab:


$ echo "/dev/xvdb /mnt/ephemeral ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab

The nofail option is crucial - it allows the system to boot even if the instance store isn't available (which can happen during certain EC2 maintenance events).

Instance store volumes provide better performance than EBS for certain workloads:

  • Higher IOPS (especially for sequential reads/writes)
  • Lower latency (no network overhead)
  • No throughput limits beyond physical hardware capabilities

However, remember these are ephemeral - data will be lost when the instance stops or terminates.

Here are some common scenarios where instance store shines:


# Temporary file storage for batch processing
$ export TMPDIR=/mnt/ephemeral/tmp
$ mkdir -p $TMPDIR

# Database temporary tables (MySQL example)
[mysqld]
tmpdir = /mnt/ephemeral/mysql-tmp

If you don't see your instance store volume:

  1. Verify your instance type actually includes instance store
  2. Check if you launched the instance with the correct AMI (some don't include drivers)
  3. Look for kernel messages about storage devices: dmesg | grep -i xvd

When working with AWS EC2 instances, many developers are surprised to find their instance store volumes (also called ephemeral storage) not automatically mounted, especially when using EBS-backed instances. The instance store is physically attached storage that offers high performance but is temporary - it's wiped when the instance stops or terminates.

First, verify if your instance type actually includes instance store volumes. Run:

aws ec2 describe-instance-types \
  --instance-types YOUR_INSTANCE_TYPE \
  --query "InstanceTypes[0].InstanceStorageInfo"

For example, with an m1.small instance (now legacy), you should see 160GB listed.

On Linux instances, check for unmounted devices:

lsblk
sudo fdisk -l

You might see output like:

NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0   8G  0 disk 
└─xvda1 202:1    0   8G  0 part /
xvdb    202:16   0 160G  0 disk

Here, xvdb is our unmounted 160GB instance store.

To use the ephemeral storage:

# Create filesystem
sudo mkfs -t ext4 /dev/xvdb

# Create mount point
sudo mkdir /mnt/ephemeral

# Mount the volume
sudo mount /dev/xvdb /mnt/ephemeral

# Verify
df -h

To automatically mount on reboot, add to /etc/fstab:

/dev/xvdb  /mnt/ephemeral  ext4  defaults,nofail  0  2

Note: The nofail option prevents boot issues if the storage isn't available.

Instance store provides:

  • Higher IOPS than EBS volumes
  • Lower latency as it's physically attached
  • Better for temporary data, caches, or scratch space

Here's how you might configure a web server to use ephemeral storage:

# Move MySQL tmpdir to ephemeral storage
sudo mkdir /mnt/ephemeral/mysqltmp
sudo chown mysql:mysql /mnt/ephemeral/mysqltmp

# Add to my.cnf
[mysqld]
tmpdir=/mnt/ephemeral/mysqltmp
  • Data is lost on instance stop/terminate
  • Not all instance types include instance store
  • Some instance types require manual mounting
  • Always verify backups for critical data