Search This Blog

Monday, July 22, 2013

Using instance storage in Amazon EC2

Some Amazon EC2 instances provide instance store. You may lose data once you stop the instance, but it does not charge against your account. EBS costs around 1 cent per GB. Thus, if you want to spend your money when you only use the instance, instance storage would be the option to be considered.

In order to use the instance storage, we need to partition and format it. Additionally, we may consider to create LVM over them since some instances provide multiple instance stores and we often want to consolidate them.

1.Find instance stores:
ls /dev/xvd[b-g]

2.unmount them (by default, they are mounted /mnt)
umount /mnt

3. delete the primary partition
parted /dev/xvdb rm 1

4. make new label, gpt (dos is default)
parted /dev/xvdb mklabel gpt

5.Partition and format them:
parted /dev/xvdb mkpart primary xfs 1 -1

6.Create volume group with the name of vg for /dev/xvdb1 and /dev/xvdg1
vgcreate vg /dev/xvdb1 /dev/xvdg1

7. Create logical volume group with the name of docker on vg for the entire free space.
lvcreate -l 100%Free -n docker vg

8. Format as xfs filesystem
mkfs.xfs /dev/vg/docker

9. edit /etc/fstab
vi /etc/fstab
add
/dev/vg/docker /docker defaults 0 0

10. mount
mount -a


No comments:

Post a Comment