liveBook · Manning

EBS volume

As explained in Amazon Web Services in Action, Third Edition: An in-depth guide to AWS

Amazon EBS is a block storage service that provides persistent virtual disks for compute instances.

An Amazon Elastic Block Store (EBS) volume is a persistent virtual disk for an EC2 instance. It provides block-level storage: the instance’s operating system can put a filesystem on the volume, then applications can read and write ordinary files. This makes EBS useful for operating-system disks, relational databases, and applications that require a filesystem rather than object storage. section 8.0 section 8.1

A volume is a resource separate from its EC2 instance and connects over the network. Its data survives an instance stop or hardware failure, and EBS replicates data across disks. Check the root volume’s DeleteOnTermination setting before terminating an instance, however: it is true by default, so termination deletes that volume. The setting defaults to false for other attached volumes. section 8.1

To give an EC2 application a persistent filesystem:

  • Create a volume with a chosen size and type in the instance’s availability zone, then attach it. CloudFormation represents these as AWS::EC2::Volume and AWS::EC2::VolumeAttachment resources. section 8.1.1 section 13.2.3
  • On the instance, run lsblk to identify the new device. For a newly created volume, create a filesystem—for example, sudo mkfs -t xfs /dev/xvdf—then mount it with sudo mkdir /data and sudo mount /dev/xvdf /data. Use df -h to check the mount. section 8.1.2
  • Before detaching a mounted volume, unmount it. After attaching and mounting it again, its files remain: detaching removes access from the instance, not the stored data. section 8.1.2

Moving a filesystem-dependent application

A legacy application stores business-critical files through filesystem calls. Run it on EC2 with an attached EBS volume so it can keep using those calls while its data remains on a separate resource. A database that reads and writes files has a similar need for block storage. section 8.0 section 8.1.1

Replication does not replace backups. EBS snapshots are incremental, block-level backups; create them regularly and restore one by creating a new volume from it. For a clean snapshot, stop the instance or detach the volume first. If writes must continue around snapshot creation, freeze filesystem writes, create the snapshot, and unfreeze once it reaches the pending state. Snapshot storage is billed by usage. section 8.1.4

Plan for availability-zone failures separately. A volume resides in one zone and cannot be attached to an instance in another; an outage can make it temporarily inaccessible without destroying its data. Snapshots can be used to create a replacement volume in another zone. If multiple instances need to share a filesystem, consider EFS instead. Instance store is an alternative for temporary data, but its data is lost when the instance stops or terminates. section 13.2.3 section 9.0 section 8.3

Choose volume size and type for the workload: the listed options include General Purpose SSD, Provisioned IOPS SSD, Throughput Optimized HDD, and Cold HDD. AWS charges for provisioned volume capacity even when it is unused, and an instance’s network bandwidth can affect access to its volume. You can increase volume size later. section 8.3

How Amazon Web Services in Action, Third Edition: An in-depth guide to AWS covers it

How deep it goes
Walks through creation, attachment, formatting, mounting, detachment, and snapshot recovery; does not detail filesystem internals.
Examples
Uses a legacy-application migration, a mounted 5 GB volume, snapshot commands, and an availability-zone recovery scenario.
What it assumes
Introduces block storage and filesystem access from first principles, while practical steps assume an EC2 instance and basic command-line access.
What you can do after
Operate/configure it with CloudFormation and Linux commands, then back it up and restore it using EBS snapshots.
How it connects
Connects EBS volumes to EC2, filesystems, EBS snapshots, availability zones, EFS, and instance store.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Amazon Web Services in Action, Third Edition: An in-depth guide to AWS. The section links point to the parts of the book it draws on.