How To Mount an Instance Store on EC2 for Disk Cache

One way to get a fast disk cache on an EC2 instance is to attach a local instance store. This article describes the steps to mount an instance store on your AWS EC2 instance and how to set it up as a disk cache for ObjectiveFS. If your EC2 instance has multiple instance stores, see this guide for how to use multiple instance stores for disk cache.

What you need: an EC2 instance with an instance store 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
    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   4G  0 disk /media/ephemeral0
    
    The example above shows the instance store block device xvdb is already formatted and mounted on /media/ephemeral0

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

    $ sudo umount /media/ephemeral0

  4. If the instance store is not formatted, you can format it with the following command (assuming the block device name is xvdb).

    $ mkfs.ext3 /dev/xvdb
    For NVMe SSD:
    $ mkfs.ext4 -E nodiscard /dev/nvme0n1

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

    $ mkdir /var/cache/objectivefs
    $ mount /dev/xvdb /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.1G  6.6G  14% /
    devtmpfs        1.9G   60K  1.9G   1% /dev
    tmpfs           1.9G     0  1.9G   0% /dev/shm
    /dev/xvdb       3.9G  8.1M  3.7G   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, September 30, 2015
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 support@objectivefs.com

Get updates about ObjectiveFS