# mdadm

`mdadm` command, which is used for managing software RAID (Redundant Array of Independent Disks) configurations in Linux. Here’s an overview of its usage and functionality:

### `mdadm` Command

1. **Purpose**:
   * **RAID Management**: `mdadm` is used to create, manage, and monitor software RAID arrays in Linux.
   * **Device Administration**: It allows for various operations such as assembling, reassembling, and managing RAID devices and arrays.
2. **Basic Usage**:
   * **Create RAID Array**:

     ```
     mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
     ```

     * Creates a RAID 1 (mirror) array named `/dev/md0` using `/dev/sdb1` and `/dev/sdc1`.
   * **Assemble RAID Array**:

     ```
     mdadm --assemble /dev/md0 /dev/sdb1 /dev/sdc1
     ```

     * Assembles the RAID array `/dev/md0` using specified devices.
   * **Manage Arrays**:
     * `--detail`: Display detailed information about RAID arrays.
     * `--monitor`: Monitor RAID arrays for changes and events.
     * `--stop`: Stop (deactivate) a running RAID array.
     * `--fail` and `--remove`: Mark a device as failed and remove it from the array.
   * **Configuration**:
     * `--detail --scan`: Outputs configuration details suitable for `mdadm.conf`.
     * `--examine`: Examine RAID metadata on devices.
3. **Monitoring and Maintenance**:
   * **Monitoring**: Use `mdadm --monitor` to monitor arrays for failures or changes.
   * **Maintenance**: Replace failed disks with `--manage --replace`.
4. **Examples**:
   * **Create RAID 5 Array**:

     ```
     mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1
     ```

     * Creates a RAID 5 array named `/dev/md0` with three devices.
   * **Assemble All Arrays**:

     ```
     mdadm --assemble --scan
     ```

     * Assembles all RAID arrays listed in `mdadm.conf`.
5. **Additional Options**:
   * `-v, --verbose`: Provides detailed output.
   * `-Q, --brief`: Provides brief output suitable for scripting.
   * `-h, --help`: Displays help information.

### Conclusion

`mdadm` is a powerful command-line tool for managing software RAID arrays on Linux systems. It offers flexibility in creating different RAID levels (0, 1, 5, 10, etc.), monitoring array health, and handling device failures. Always refer to the `mdadm` documentation (`man mdadm`) for comprehensive details and advanced usage scenarios. This ensures efficient management and maintenance of RAID configurations to enhance data reliability and availability.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://linux-tutorial-cli.gitbook.io/linux-cli-tutorial/txt-files/file-systems-cocepts/lpic2-201/mdadm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
