Setup Amazon AWS EC2

Updated: 2019-01-07

Amazon AWS is providing this awesome free tier, which allows you to play with a micro instance for 12 months. Simply create a new account on, and create a new t2.micro instance. A few things to note:

SSH: Hop on the box

$ ssh -i key.pem [email protected]

where key.pem is the private key generated when you spin up a box, and xx.xx.xx.xx is the IP of your box.

Another way is to add these lines to ~/.git/config

Host aws
    HostName xx.xx.xx.xx
    User ubuntu
    IdentityFile /path/to/key.pem

Next time you can do simply

$ ssh aws

Mount EBS

If you created some storage in Volumns tab and correctly attached it to a instance, you should see that from lsblk(a 20G EBS is created and attached in this example):

$ lsblk
xvda    202:0    0   8G  0 disk
└─xvda1 202:1    0   8G  0 part /
xvdb    202:16   0  20G  0 disk

And check

$ sudo file -s /dev/xvdb
/dev/xvdb: data

It is showing as data since it is not formatted yet

$ sudo mkfs -t ext4 /dev/xvdb
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

Now check again:

$ sudo file -s /dev/xvdb
/dev/xvdb: Linux rev 1.0 ext4 filesystem data, UUID=d5c0662f-fa1d-4a0f-b695-f8bac4a95879 (needs journal recovery) (extents) (large files) (huge files)

Mount it to a folder:

$ mkdir data
$ sudo mount /dev/xvdb data

$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/xvda1       8115168 2478228   5201664  33% /
/dev/xvdb       20511356   44992  19401404   1% /home/ubuntu/data