OnCallReadyStart learning

AWS Lesson 38.17 · AWS V: Data, Resilience & the Edge · 13 min read

Block, file and object: EBS, instance store, EFS and when each fits

In plain words

There are three ways to keep files. Block storage is a hard drive bolted into one computer: fast, private, and stuck in one room. File storage is the shared network drive in an office: everybody can open the same folder at once. Object storage is a warehouse with a counter: you hand over a whole box with a label and get the whole box back later.

On AWS those are EBS, EFS and S3. Instance store is a fourth kind: a whiteboard in a rented room, wiped when you hand the room back.

Block, file and object: EBS, instance store, EFS and when each fits

AWS has three storage shapes, and picking the wrong one is a design bug that shows up later as an outage or a bill. Block storage (EBS, instance store) is a disk for one instance. File storage (EFS, FSx) is a shared file system many instances mount at once. Object storage (S3) is an HTTP API for whole objects at any scale. AWS III grew an EBS volume; this lesson puts the three side by side and mounts an EFS file system on two instances in two AZs.

Need to know: an EBS volume lives in one AZ and attaches to one instance (io2 Multi-Attach aside); snapshots go to S3 and can be restored in any AZ. Instance store disks are physically attached and lost when the instance stops. EFS is NFS v4.1, regional (data in several AZs), elastic in size, mounted through a mount target per AZ (port 2049, security groups), with access points for per-application views and lifecycle policies that move cold files to cheaper classes.

The three shapes

EBSinstance storeEFSS3
shapeblock (a disk)blockfile (NFS)object (HTTP)
shared?one instanceone instancethousands of clientsany client
scopeone AZthe hostRegion (or One Zone)Region
survives stop?yesnoyesyes
growsmodify-volumenoby itselfby itself
typicalboot disks, databasescaches, scratch, buffersshared uploads, home dirs, CMSbackups, assets, data lakes

FSx adds managed file systems with other protocols: FSx for Windows File Server (SMB, AD), FSx for Lustre (HPC, linked to S3), FSx for NetApp ONTAP and OpenZFS. EFS is the Linux default.

An EFS file system, from the API

$ aws efs describe-file-systems --query 'FileSystems[?Name==`shop-uploads`].{id: FileSystemId, state: LifeCycleState, mode: PerformanceMode, throughput: ThroughputMode, encrypted: Encrypted, size: SizeInBytes.Value}'
[
    {
        "id": "fs-76585636963748398",
        "state": "available",
        "mode": "generalPurpose",
        "throughput": "elastic",
        "encrypted": true,
        "size": 4096
    }
]
$ FS=$(aws efs describe-file-systems --query 'FileSystems[?Name==`shop-uploads`].FileSystemId' --output text)
$ aws efs describe-mount-targets --file-system-id $FS --query 'MountTargets[].[MountTargetId,AvailabilityZoneName,IpAddress,LifeCycleState]' --output text
fsmt-15477d31887f6b151	eu-central-1a	10.30.10.67	available
fsmt-1b6829153a1868451	eu-central-1b	10.30.11.56	available
$ aws efs describe-mount-target-security-groups --mount-target-id $(aws efs describe-mount-targets --file-system-id $FS --query 'MountTargets[0].MountTargetId' --output text)
{
    "SecurityGroups": [
        "sg-0017e216c35063843"
    ]
}

One mount target per AZ, each an ENI with an address in a private subnet and a security group. That group must allow TCP 2049 from the clients: the most common EFS problem is a mount that hangs and then fails with Connection timed out because it does not. Elastic throughput (the default now) scales with the workload and bills per GB transferred. Bursting and provisioned are the older modes.

Mount it on two instances in two AZs

$ echo $FS
fs-76585636963748398
$ aws ssm start-session --target $(aws ec2 describe-instances --filters Name=tag:Name,Values=app-1 Name=instance-state-name,Values=running --query 'Reservations[0].Instances[0].InstanceId' --output text)

Starting session with SessionId: learner-01403a097e3540e4f
$ sudo mkdir -p /mnt/uploads
$ sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport fs-76585636963748398.efs.eu-central-1.amazonaws.com:/ /mnt/uploads
$ df -h /mnt/uploads
Filesystem                                             Size  Used Avail Use% Mounted on
fs-76585636963748398.efs.eu-central-1.amazonaws.com:/  8.0E  4.0K  8.0E   1% /mnt/uploads
$ echo 'product 4711 photo' | sudo tee /mnt/uploads/4711.jpg
product 4711 photo
$ exit


Exiting session with sessionId: learner-01403a097e3540e4f.
$ aws ssm start-session --target $(aws ec2 describe-instances --filters Name=tag:Name,Values=app-2 Name=instance-state-name,Values=running --query 'Reservations[0].Instances[0].InstanceId' --output text)

Starting session with SessionId: learner-025f0818175918bb3
$ sudo mkdir -p /mnt/uploads && sudo mount -t nfs4 -o nfsvers=4.1,hard,noresvport fs-76585636963748398.efs.eu-central-1.amazonaws.com:/ /mnt/uploads
$ cat /mnt/uploads/4711.jpg
product 4711 photo
$ exit


Exiting session with sessionId: learner-025f0818175918bb3.

The DNS name <fs-id>.efs.<region>.amazonaws.com resolves, inside the VPC, to the mount target in the client's own AZ. That avoids cross-AZ traffic and keeps working if another AZ fails. df shows 8.0E: EFS has no fixed size and you pay for what is stored. The options are AWS's recommended ones (hard so writes are not silently dropped, noresvport so a reconnect after a network event uses a new port). The amazon-efs-utils helper (mount -t efs fs-id:/ /mnt) adds TLS in transit (-o tls) and IAM authorization. For a permanent mount, add the line to /etc/fstab with _netdev,nofail, so a boot does not hang when the network or EFS is not there.

Access points and lifecycle

$ aws efs create-access-point --file-system-id $FS --posix-user Uid=1001,Gid=1001 --root-directory 'Path=/thumbnails,CreationInfo={OwnerUid=1001,OwnerGid=1001,Permissions=750}' --tags Key=Name,Value=try-thumbnails --query '[AccessPointId,RootDirectory.Path,PosixUser]' --output json
[
    "fsap-0412214847364950a",
    "/thumbnails",
    {
        "Uid": 1001,
        "Gid": 1001
    }
]
$ aws efs put-lifecycle-configuration --file-system-id $FS --lifecycle-policies TransitionToIA=AFTER_30_DAYS TransitionToArchive=AFTER_90_DAYS TransitionToPrimaryStorageClass=AFTER_1_ACCESS
{
    "LifecyclePolicies": [
        {
            "TransitionToIA": "AFTER_30_DAYS"
        },
        {
            "TransitionToArchive": "AFTER_90_DAYS"
        },
        {
            "TransitionToPrimaryStorageClass": "AFTER_1_ACCESS"
        }
    ]
}
$ aws efs describe-file-systems --file-system-id $FS --query 'FileSystems[0].SizeInBytes'
{
    "Value": 8192,
    "Timestamp": "2026-09-22T19:00:04.000000+00:00",
    "ValueInIA": 0,
    "ValueInStandard": 8192,
    "ValueInArchive": 0
}
  • An access point gives one application its own view: a root directory (created with an owner and mode on first use) and a forced POSIX user and group, whatever the client claims. Together with an EFS file system policy (elasticfilesystem:ClientMount, ClientWrite, aws:SecureTransport) that is how several teams share one file system safely. EKS and ECS mount through access points.
  • Lifecycle: files not read for 30 days move to Infrequent Access, after 90 to Archive, and back to Standard on the next access. Reads from IA and Archive cost per GB, so this fits data that is mostly cold. SizeInBytes shows what sits in each class.
  • One Zone file systems keep data in one AZ for about half the price. They suit dev and data you can rebuild, not data that must survive an AZ outage.
  • Backups: put-backup-policy --backup-policy Status=ENABLED puts the file system in AWS Backup's default plan (daily, 35 days). EFS replication copies it to another Region.

On the exam (SOA-C03 1.3, SAA-C03 3.1, CLF-C02 3.6): "shared file system for Linux instances across AZs" = EFS; "Windows / SMB" = FSx for Windows File Server; "HPC, high throughput, S3 integration" = FSx for Lustre; "temporary, fastest local disk, data can be lost" = instance store; "boot volume / database on one instance" = EBS (gp3, io2 for guaranteed IOPS). "Lower EFS cost for rarely read files" = lifecycle to IA / Archive. "Mount hangs" = the mount target security group and port 2049.

In an interview: "EFS or EBS for a database?" - "EBS. A database wants a block device with low, predictable latency on one host, and replicates at the database level (or RDS does it). EFS fits files that many hosts share: uploads, shared configuration, home directories, build caches. NFS latency and locking semantics are a poor fit for a database's data files."

You can now: choose between EBS, instance store, EFS, FSx and S3 by access pattern and durability, read an EFS file system's mount targets and their security groups, mount it on instances in two AZs with the recommended options, and use access points and lifecycle policies.

Why it helps

Picking the wrong shape is a design bug that shows up later: data on instance store gone after a stop, an EBS volume that cannot follow an instance into another AZ, a database on NFS with poor latency.

EFS has its own usual incident, a mount that hangs and then fails because the mount target's security group does not allow port 2049. The lesson mounts one file system on two instances in two AZs, so the shared-files pattern and its pitfalls are clear before you build it for real.

Commands in this lesson

aws echo mkdir mount df exit cat

FAQ

Why does my EFS mount hang and then fail?

Almost always the mount target's security group does not allow TCP 2049 from the client, so the mount waits and ends with "Connection timed out". Every AZ has its own mount target, an ENI with its own security group; check that group with describe-mount-target-security-groups and allow the clients' security group on 2049.

Why does df show 8.0E for an EFS file system?

EFS has no fixed size. It grows and shrinks with the data, and you pay for what is stored, so df shows a huge number. SizeInBytes from describe-file-systems tells you what is really stored, split per storage class once lifecycle policies have moved files.

Which mount options should I use?

AWS's recommended ones: nfsvers=4.1, rsize and wsize of 1048576, hard, timeo=600, retrans=2 and noresvport. hard means writes are not silently dropped, noresvport lets a reconnect use a new port. The amazon-efs-utils helper (mount -t efs) adds TLS and IAM authorization. In /etc/fstab add _netdev,nofail so a boot does not hang.

What is an EFS access point?

A per-application view of the file system: its own root directory, created with an owner and mode on first use, and a forced POSIX user and group, whatever the client claims. Combined with a file system policy (ClientMount, ClientWrite, aws:SecureTransport), it lets several teams share one file system safely.

How can I make EFS cheaper?

Lifecycle policies move files not read for 30 days to Infrequent Access and after 90 to Archive, and back to Standard on the next access; reads from the cheaper classes cost per GB, so this fits mostly cold data. One Zone file systems cost about half, but keep data in one AZ: fine for dev and data you can rebuild.

In an interview Mid

Would you put a database on EFS or EBS?

EBS. A database wants a block device with low, predictable latency on one host, and it replicates at the database level, or RDS does it for you. An EBS volume lives in one AZ and attaches to one instance, which is exactly that shape. EFS fits files that many hosts share at once: uploads, shared configuration, home directories, build caches, mounted through a mount target in each AZ. NFS latency and locking semantics are a poor fit for a database's data files.

Also asked: What happens to data on an instance store volume when the instance stops? · How would you share files between instances in different Availability Zones? · When would you use FSx instead of EFS?

Practise this lesson in the terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.