MacBook Air crashes, restarts and gives this error

It keeps crashing and this is the newest one:

Anonymous UUID:       0BCEAA1D-32A3-1735-AF5F-607108F40027

Wed Jun 13 18:53:02 2018

*** Panic Report ***
panic(cpu 0 caller 0xffffff8016f154f0):  initproc exited -- exit reason namespace 2 subcode 0xa description: none

Thread 1 crashed

RAX: 0x0000000000000010, RBX: 0x00000001047f4f28, RCX: 0x00000001047a6a80, RDX: 0x00000001047f2000
RSP: 0x0000700003560250, RBP: 0x00007000035602f0, RSI: 0x000000000004b000, RDI: 0x00000001047f7410
R8:  0x0000000000000000, R9:  0x0000000000000e20, R10: 0x00000001047a6a10, R11: 0x0000000000000001
R12: 0x0000000000000001, R13: 0x0000000000001cf0, R14: 0x0000000000000001, R15: 0x0000000000000001
RFL: 0x0000000000010202, RIP: 0x00007fff6e9497c4, CS:  0x000000000000002b, SS:  0x0000000000000023

Thread 0: 0xffffff80258a8000
0x00007fff6ea9402a
0x00007fff6e915cc0
0x0000000000000000

Thread 1: 0xffffff802683f290
0x00007fff6e9497c4
0x00007fff6e94aa8d
0x00007fff6e94aca5
0x00007fff6e9521c4
0x00007fff6e9a45b1
0x00000001047c8c95
0x00000001047d89ea
0x00007fff6e909db8
0x00007fff6e91ce81
0x00007fff6e90c081
0x00007fff6e91e07a
0x00007fff6e911166
0x00007fff6e91ef0d
0x00007fff6e922d21
0x00007fff6ec5afd2
0x00007fff6ec5abe9
0x0000000000000000

Thread 2: 0xffffff8029432c70
0x00007fff6ea955b2
0x00007fff6e91ce81
0x00007fff6e90c081
0x00007fff6e91e07a
0x00007fff6e911166
0x00007fff6e91ef0d
0x00007fff6e922d21
0x00007fff6ec5afd2
0x00007fff6ec5abe9
0x0000000000000000

Thread 3: 0xffffff802c2c54f0
0x00007fff6ec5abdc

Thread 4: 0xffffff8027d56650
0x00007fff6ec5abdc


Mac OS version:
17F77

Kernel version:
Darwin Kernel Version 17.6.0: Tue May  8 15:22:16 PDT 2018; root:xnu-4570.61.1~1/RELEASE_X86_64
Kernel UUID: CC1699EE-71B5-3AF1-AAA3-6DBD16222B92
System model name: MacBookAir7,2 (Mac-937CB26E2E02BB01)
Root disk errors: "Could not recover SATA HDD after 5 attempts. Terminating."

EOF
Model: MacBookAir7,2, BootROM MBA71.0177.B00, 2 processors, Intel Core i5, 1.6 GHz, 4 GB, SMC 2.27f2
Graphics: Intel HD Graphics 6000, Intel HD Graphics 6000, Built-In
Memory Module: BANK 0/DIMM0, 2 GB, DDR3, 1600 MHz, 0x80AD, 0x483943434E4E4E384A544D4C41522D4E544D
Memory Module: BANK 1/DIMM0, 2 GB, DDR3, 1600 MHz, 0x80AD, 0x483943434E4E4E384A544D4C41522D4E544D
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x117), Broadcom BCM43xx 1.0 (7.77.37.31.1a9)
Bluetooth: Version 6.0.6f2, 3 services, 27 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
Serial ATA Device: APPLE SSD SM0256G, 251 GB
USB Device: USB 3.0 Bus
USB Device: BRCM20702 Hub
USB Device: Bluetooth USB Host Controller
Thunderbolt Bus: MacBook Air, Apple Inc., 27.2

Your drive is failing.

The key to this diagnosis is this error message in the panic report:

> Root disk errors: "Could not recover SATA HDD after 5 attempts.
> Terminating."

To fully diagnose this, install macOS to an external drive. If your MBA starts to function normally, you've narrowed it down to your drive. (It can be a USB flash disk - it's only for testing purposes).

Luckily (as "lucky" as one can get in this scenario) the drive isn't soldered to the logic board so you do have the opportunity to replace it with another (128GB: PN# 656-0021A or 256GB PN# 661-02396). It's not too difficult a fix, you just have to remove the back cover and disconnect the SSD. ifixit.com has a good walk through.

Now, you DO have a backup, right?

If not, the good news is you can buy a sled or cable and attempt data transfer after you put a new drive in. Since reading data often works after writes to a failing drive are not happening. Sooner you power off and start data transfer the better.