INC-3060 · P2 · AWS · Amazon EC2 · Stockage d'instance NVMe · Amazon S3 · systemd · nginx · AWS CLI v2

Step-by-step fix: Since last night's maintenance, every course image and PDF returns 404

A production incident replayed in a simulated terminal, with its complete resolution: the commands the on-call engineer ran, what they printed, the root cause and the fix. This is exactly the reasoning expected in a DevOps, SRE or Linux administrator job interview.

Try it yourself first in the terminal (free)

The ticket

The MasterLinux school serves the images, diagrams and PDFs of its courses from medias.masterlinux.lab, hosted on a single EC2 instance, ml-medias-01 (nginx). Trainers upload their files to /mnt/medias. A cron job copies this folder every night at 02:00 to the S3 bucket masterlinux-medias-sauvegarde.

Last night (Monday 19 October, 22:10), the operations team stopped and then started the instance to move it from c5d.large to c5d.xlarge (resize). The restart went fine, the instance shows "2/2 checks passed".

This morning, students report that course pages no longer display any diagram and that PDFs return 404. Only a few files uploaded by trainers since 07:00 are displayed. Today's sessions start at 09:30.

You are the on-call administrator, connected over SSH to ml-medias-01 (account ops, sudo, AWS CLI v2 with the instance role).

Step by step: the commands and their output

These are the commands the engineer typed, in order, with what the machine answered.

  1. ops@ml-medias-01:~$ curl -I https://medias.masterlinux.lab/cours/linux-101/schema-boot.png
    HTTP/2 404
    server: nginx/1.24.0 (Ubuntu)
    date: Tue, 20 Oct 2026 07:21:44 GMT
    content-type: text/html
    content-length: 162
  2. ops@ml-medias-01:~$ df -h
    Filesystem       Size  Used Avail Use% Mounted on
    /dev/root         19G  7.9G   11G  42% /
    tmpfs            3.8G     0  3.8G   0% /dev/shm
    tmpfs            1.6G  1.1M  1.6G   1% /run
    tmpfs            5.0M     0  5.0M   0% /run/lock
    /dev/nvme0n1p16  881M   76M  744M  10% /boot
    /dev/nvme0n1p15  105M  6.1M   99M   6% /boot/efi
    tmpfs            768M   12K  768M   1% /run/user/1001
  3. ops@ml-medias-01:~$ cat /etc/fstab
    LABEL=cloudimg-rootfs	/	 ext4	discard,commit=30,errors=remount-ro	0 1
    LABEL=BOOT	/boot	ext4	defaults	0 2
    LABEL=UEFI	/boot/efi	vfat	umask=0077	0 1
    # Disque des medias (ajoute le 12/03/2026)
    UUID=5b0d2e8a-71c4-4f3e-9a6d-c2e81f0b7d49  /mnt/medias  ext4  defaults,nofail  0 2
  4. ops@ml-medias-01:~$ journalctl -b -u mnt-medias.mount
    Oct 19 22:13:22 ml-medias-01 systemd[1]: Expecting device dev-disk-by\x2duuid-5b0d2e8a\x2d71c4\x2d4f3e\x2d9a6d\x2dc2e81f0b7d49.device - /dev/disk/by-uuid/5b0d2e8a-71c4-4f3e-9a6d-c2e81f0b7d49...
    Oct 19 22:14:52 ml-medias-01 systemd[1]: dev-disk-by\x2duuid-5b0d2e8a\x2d71c4\x2d4f3e\x2d9a6d\x2dc2e81f0b7d49.device: Job dev-disk-by\x2duuid-5b0d2e8a\x2d71c4\x2d4f3e\x2d9a6d\x2dc2e81f0b7d49.device/start timed out.
    Oct 19 22:14:52 ml-medias-01 systemd[1]: Timed out waiting for device dev-disk-by\x2duuid-5b0d2e8a\x2d71c4\x2d4f3e\x2d9a6d\x2dc2e81f0b7d49.device - /dev/disk/by-uuid/5b0d2e8a-71c4-4f3e-9a6d-c2e81f0b7d49.
    Oct 19 22:14:52 ml-medias-01 systemd[1]: Dependency failed for mnt-medias.mount - /mnt/medias.
    Oct 19 22:14:52 ml-medias-01 systemd[1]: mnt-medias.mount: Job mnt-medias.mount/start failed with result 'dependency'.
    Oct 19 22:14:52 ml-medias-01 systemd[1]: dev-disk-by\x2duuid-5b0d2e8a\x2d71c4\x2d4f3e\x2d9a6d\x2dc2e81f0b7d49.device: Job dev-disk-by\x2duuid-5b0d2e8a\x2d71c4\x2d4f3e\x2d9a6d\x2dc2e81f0b7d49.device/start failed with result 'timeout'.
  5. ops@ml-medias-01:~$ lsblk -f
    NAME          FSTYPE FSVER LABEL           UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
    nvme0n1
    ├─nvme0n1p1   ext4   1.0   cloudimg-rootfs 9c1e6b2a-4d7f-48e3-a05b-3f8d2c6e1a97   10.6G    42% /
    ├─nvme0n1p14
    ├─nvme0n1p15  vfat   FAT32 UEFI            7A1C-3E5B                              98.6M     6% /boot/efi
    └─nvme0n1p16  ext4   1.0   BOOT            0f6b8d2a-1c3e-4a5f-9b7d-e2c4a6f8b013  743.8M     9% /boot
    nvme1n1
  6. ops@ml-medias-01:~$ sudo nvme list
    Node                  Generic               SN                   Model                                    Namespace Usage                      Format           FW Rev
    --------------------- --------------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
    /dev/nvme0n1          /dev/ng0n1            vol0a3f5c7e9b1d24680 Amazon Elastic Block Store               1          21.47  GB /  21.47  GB    512   B +  0 B   2.0
    /dev/nvme1n1          /dev/ng1n1            AWS2B4D6F8A1C3E5079  Amazon EC2 NVMe Instance Storage         1         100.00  GB / 100.00  GB    512   B +  0 B   0
  7. ops@ml-medias-01:~$ aws ec2 describe-volumes --volume-ids vol-0a3f5c7e9b1d24680
    {
        "Volumes": [
            {
                "Attachments": [ { "AttachTime": "2026-03-12T10:41:27+00:00", "Device": "/dev/sda1", "InstanceId": "i-0b7e4c91d2a35f816", "State": "attached", "VolumeId": "vol-0a3f5c7e9b1d24680", "DeleteOnTermination": true } ],
                "AvailabilityZone": "eu-west-3a",
                "CreateTime": "2026-03-12T10:41:27.118000+00:00",
                "Encrypted": true,
                "Size": 20,
                "SnapshotId": "snap-07c1e3a5b9d2f4680",
                "State": "in-use",
                "VolumeId": "vol-0a3f5c7e9b1d24680",
                "Iops": 3000,
                "VolumeType": "gp3",
                "Throughput": 125
            }
        ]
    }
  8. ops@ml-medias-01:~$ sudo mkfs.ext4 /dev/nvme1n1
    mke2fs 1.47.0 (5-Feb-2023)
    Discarding device blocks: done
    Creating filesystem with 24413696 4k blocks and 6103040 inodes
    Filesystem UUID: e41a9c7d-2b6f-4d08-8e35-71f0c3a9b2d6
    Superblock backups stored on blocks:
    	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
    	4096000, 7962624, 11239424, 20480000, 23887872
    
    Allocating group tables: done
    Writing inode tables: done
    Creating journal (131072 blocks): done
    Writing superblocks and filesystem accounting information: done
  9. ops@ml-medias-01:~$ sudo mount /dev/nvme1n1 /mnt/medias
  10. ops@ml-medias-01:~$ sudo aws s3 sync s3://masterlinux-medias-sauvegarde/medias/ /mnt/medias/
    download: s3://masterlinux-medias-sauvegarde/medias/cours/linux-101/schema-boot.png to /mnt/medias/cours/linux-101/schema-boot.png
    download: s3://masterlinux-medias-sauvegarde/medias/cours/linux-101/support-module-1.pdf to /mnt/medias/cours/linux-101/support-module-1.pdf
    download: s3://masterlinux-medias-sauvegarde/medias/cours/aws/vpc-schema.svg to /mnt/medias/cours/aws/vpc-schema.svg
    download: s3://masterlinux-medias-sauvegarde/medias/cours/reseau/tcp-handshake.png to /mnt/medias/cours/reseau/tcp-handshake.png
    download: s3://masterlinux-medias-sauvegarde/medias/cours/docker/support-docker.pdf to /mnt/medias/cours/docker/support-docker.pdf
    [...]
    (Simulation: 48,213 files, 61.4 GiB restored in 11 minutes from the 20/10 02:00 backup.)
  11. ops@ml-medias-01:~$ curl -I https://medias.masterlinux.lab/cours/linux-101/schema-boot.png
    HTTP/2 200
    server: nginx/1.24.0 (Ubuntu)
    date: Tue, 20 Oct 2026 07:48:09 GMT
    content-type: image/png
    content-length: 184362
    last-modified: Thu, 08 Oct 2026 14:02:11 GMT
    accept-ranges: bytes

What the commands revealed

Root cause

The media lived on the c5d's NVMe instance store, wiped by the stop: at restart the disk is new, the nofail mount fails silently and nginx reads an empty folder on the root disk

c5d instances (the "d") have an NVMe instance store physically attached to the host. It is fast and free, but ephemeral: a stop, a hibernation or a termination releases the host and the disk is wiped. A resize requires a stop: the instance restarts on another host with a brand-new, blank nvme1n1 disk. nvme list shows it clearly: "Amazon EC2 NVMe Instance Storage".

/etc/fstab still looks for the old UUID, which no longer exists. Because of nofail, systemd waits 90 s and then boots anyway, without the mount: /mnt/medias becomes a plain folder on the root disk again, where nginx only finds the 37 files uploaded since.

The security group is healthy (nginx answers 404, no timeout), the root disk is at 42% and the root EBS volume is intact: only the ephemeral disk was lost.

Analysis and fix

Repair (classes start at 09:30):

  1. set aside the 37 files uploaded since the restart (sudo cp -a /mnt/medias /root/medias-depuis-redemarrage), because the mount will hide them;
  2. format the instance store: sudo mkfs.ext4 /dev/nvme1n1;
  3. mount it: sudo mount /dev/nvme1n1 /mnt/medias;
  4. restore from the backup: sudo aws s3 sync s3://masterlinux-medias-sauvegarde/medias/ /mnt/medias/, then copy back the 37 files set aside and give ownership back to www-data;
  5. check: curl -I on a diagram returns 200, df -h shows /dev/nvme1n1 on /mnt/medias.

Files uploaded between the 19/10 02:00 backup and the 22:10 stop must be requested again from the trainers (check the 20/10 backup, which ran after the restart and fortunately deleted nothing, because the job does not use --delete).

Prevention:

  • never keep unique data on an instance store: put the media on a dedicated EBS volume (gp3), or better directly in S3 (served by CloudFront);
  • keep the instance store for cache and temporary files, recreated by a script at boot (format + mount by device name, not by UUID);
  • monitor the mount point (mountpoint -q /mnt/medias in the health probe): a failing nofail mount must not go unnoticed;
  • write into the resize procedure: "stop = loss of the instance store".

In a job interview

This kind of outage often comes up in technical interviews ("the site returns an error, what do you do?"). What is assessed: start from the symptoms, check each layer with the right command, prove the cause before fixing it, then prevent it from happening again. MasterLinux trains you on 195 incidents like this one, from beginner to expert.

Try it yourself first in the terminal (free)

Unlock every production simulation

AWS, Azure, Google Cloud, on-premise and multi-cloud, from Beginner to Extreme: the real incidents of IT service companies and large IT organisations, available for a year.

Other free walkthroughs