Reduce size of volume

Hi Daniel,

I was able to use a smaller EBS by following the following steps:

  1. Stop and terminate all EC2 instances. Then go to the EBS section and delete/detach all volumes.
  2. Get the latest scripts from the fastai github directory onto your local machine with git. This depends on how exactly you got the scripts from the fastai github in the first place. I use mobaterm to ssh into a permanently running linux VM, and used git fetch to update the repo. You could just re-download the zip from github if you are using windows.
  3. Copy either setup_p2.sh or setup_t2.sh to setup.sh (I did cp setup_t2.sh setup.sh on linux)
  4. Open setup.sh and change two lines – change ami to the new ami that @vshets created, and change the VolumeSize to 30.

See below for the diff (the lines starting with < are from the new setup file I created):

ubuntu@ip-172-31-13-157:~/courses/setup$ diff setup.sh setup_t2.sh
12d11
<    export ami="ami-9c54f4fc" # Oregon
56c55
< export instanceId=`aws ec2 run-instances --image-id $ami --count 1 --instance-type t2.xlarge --key-name aws-key-$name --security-group-ids $securityGroupId --subnet-id $subnetId --associate-public-ip-address --block-device-mapping "[ { \"DeviceName\": \"/dev/sda1\", \"Ebs\": { \"VolumeSize\": 30, \"VolumeType\": \"gp2\" } } ]" --query 'Instances[0].InstanceId' --output text`
---
> export instanceId=`aws ec2 run-instances --image-id $ami --count 1 --instance-type t2.xlarge --key-name aws-key-$name --security-group-ids $securityGroupId --subnet-id $subnetId --associate-public-ip-address --block-device-mapping "[ { \"DeviceName\": \"/dev/sda1\", \"Ebs\": { \"VolumeSize\": 128, \"VolumeType\": \"gp2\" } } ]" --query 'Instances[0].InstanceId' --output text`
ubuntu@ip-172-31-13-157:~/courses/setup$

The final step is to run bash setup.sh

Hope this helps you. The VM needs a minimum EBS of 30GB. I am in the us-west-2 region and it costs $3 USD a month.

8 Likes