How To RAID EC2 Instance Stores For Disk Cache

One way to get a fast disk cache on an EC2 instance is to attach the local instance stores. You can use a RAID-0 setup to use multiple instance stores as a single large disk cache. This article describes the steps to RAID multiple EC2 instance stores for disk cache. If your EC2 instance only has one instance store, please see this guide.

What you need: an EC2 instance with the instance stores added (see how to add instance store to your EC2 instance)

  1. SSH into your EC2 instance.

  2. Use lsblk to view the block devices attached to the instance.

    $ lsblk
    xvda    202:0    0    8G  0 disk
    |-xvda1 202:1    0    8G  0 part /
    xvdb    202:16   0 37.5G  0 disk /media/ephemeral0
    xvdc    202:32   0 37.5G  0 disk
    The example above shows two instance store block devices xvdb and xvdc are attached, and xvdb is already mounted on /media/ephemeral0

  3. If the instance store volume is already mounted, please umount it.

    $ sudo umount /media/ephemeral0

  4. Set up the two instance stores as a RAID-0.

    $ sudo mdadm --create --verbose /dev/md0 --level=0 --name=MY_RAID --chunk=64 --raid-devices=2 /dev/xvdb /dev/xvdc
    $ sudo mkfs.ext4 -L MY_RAID /dev/md0
    To RAID more than two instance stores, you can use the following command:
    $ sudo mdadm --create --verbose /dev/md0 --level=0 --name=<raid name> --chunk=64 --raid-devices=<NUM DEVICES> <dev name> <dev2 name> ... <dev N name>

  5. Create the disk cache directory for ObjectiveFS /var/cache/objectivefs and mount the instance store.

    $ sudo mkdir /var/cache/objectivefs
    $ sudo mount /dev/md0 /var/cache/objectivefs

  6. Run df -h and verify that the instance store directory is mounted correctly.

    $ df -h
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/xvda1      7.8G  1.2G  6.6G  15% /
    devtmpfs        7.4G   72K  7.4G   1% /dev
    tmpfs           7.4G     0  7.4G   0% /dev/shm
    /dev/md0         74G   52M   70G   1% /var/cache/objectivefs

Your disk cache directory on the local instance store is now ready. See Disk Cache User Guide for configuration details. Please also remember to configure the disk cache to mount on boot.

by ObjectiveFS staff, February 21, 2016
ObjectiveFS is a shared file system for OS X and Linux that automatically scales and gives you scalable cloud storage. If you have questions or article idea suggestions, please email us at

Get updates about ObjectiveFS