From the course: AWS Essential Training for Developers

Hard drives with Elastic Block Store (EBS) - Amazon Web Services (AWS) Tutorial

From the course: AWS Essential Training for Developers

Hard drives with Elastic Block Store (EBS)

- Computers and servers use hard drives to store data, and virtual servers need hard drives as well because this is where they store their operating systems, server configuration files, and the source code that you'll create and upload to them to run your applications. But unlike physical hard drives in the real world, virtual drives can grow and shrink in size. You can even snapshot them at any point in time and you can easily clone them. Amazon's primary storage service for EC2 servers is called Elastic Block Store, elastic because it can stretch in size when you need it to. Let's take a look at Elastic Block Store in the EC2 console. Switch back over to the EC2 console. On the left, underneath Elastic Block Store, click on Snapshots. When we made our AMI, you'll see that it created an EBS snapshot of your server's main drive. Now, this snapshot is a little different than the AMI snapshot. The AMI includes everything you'll need to relaunch the instance. The EBS volume is just a snapshot of its hard drive. In the left hand menu, click on volumes. These are the hard drives that are connected to your instances. You can create additional EBS volumes and mount them to your running instance, and this is like adding a second hard drive to your computer. At the top, you would click create volume, and then decide how big you want this drive to be. Select the availability zone of the instance you're going to attach it to, and then click create volume. Click on the new EBS volume that you just created and scroll over to the volume state column. Periodically click the refresh button until the volume state changes to available. Once the volume state is set to available, click on the volume, and then click the actions pull down, and then click the attach volume option. Under instance, select your running instance in this availability zone. At the bottom, click attach volume. This is just like buying a hard drive at the store and plugging it into your computer. Your computer will see that a new device was attached, but the drive is completely blank. There's no file system on the drive, so you need to connect to your instance and format the drive so that you can use this. If you want to do this under Linux or Windows Operating Systems, the AWS Docs has a guide that'll help you. Some of the other things you can do with EBS volumes is that you can also detach the drive and move it to another computer. With your volume selected, click on actions and click on modify volume. You'll notice here that you can also increase the size of the volume. If you do this, take note that the new space that you add to the drive must also be formatted. If you click the info button next to the size label and scroll down in the Learn more section on the right, you'll see some links to the AWS Docs and they'll tell you how to expand a volume in Linux and in Windows. Click Cancel, because we aren't going to modify this drive at this time. For backups of your server, the best thing to do is to take an AMI image periodically because this can be easily relaunched to restore the server to a point in time. If you have an application where you need to take a lot of snapshots of a data volume that frequently changes, such as a database server, you can create a second EBS volume for your instance and configure your database to store its data files on this new volume. Then you can set a higher interval for when you want snapshots of this volume to occur. EBS volumes are fast, which is why they are the default for new EC2 instances, but let's look at some options for sharing a drive between several instances.

Contents