# ストレージ、ディスク、およびボリュームの調査

### ディスク <a href="#investigatingstorage-disksandvolumes-disk" id="investigatingstorage-disksandvolumes-disk"></a>

ディスクとは、コンピュータの物理的なストレージデバイスを指します。 ただし、論理的なストレージデバイスを表すこともでき、これが1つ以上の物理ディスクにまたがる場合があります。 例えば、RAID（Redundant Array of Independent Disks）構成は、複数の物理ディスクを組み合わせて単一の論理ディスクを形成し、パフォーマンスの向上や冗長性、あるいはその両方を提供します。

**Windows**

Disk Managementアプリケーションでは、システムが物理ドライブをディスクと呼び、`Disk 0`、`Disk 1`、...というラベルを付けます。 このPCでは、システムがこれらのストレージデバイスにドライブ文字（`C:`、`D:`、...）を割り当てます。

これらのデバイスは、ローカルディスク、USBドライブ、または仮想ディスクなどの種類が異なることがあります。

<figure><img src="https://3549141153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeLm8O7QKZDn6z806e7Sv%2Fuploads%2Fgit-blob-640afe4e544bc38d2b79da9a12d032008a6e04f8%2Fscreenshot-2023-03-30-at-14-07-24.png?alt=media" alt="" width="544"><figcaption></figcaption></figure>

<figure><img src="https://3549141153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeLm8O7QKZDn6z806e7Sv%2Fuploads%2Fgit-blob-f8504b282debf81baa5f7db93c0b65a4e37bccfd%2Fscreenshot-2023-03-30-at-14-08-45.png?alt=media" alt="" width="340"><figcaption></figcaption></figure>

**macOS**

Disk Utilityアプリケーションでは、システムが物理ドライブをメディアと呼び、トップレベルのエントリとして表示されます。 システムはそれらを内部または外部として分類し、`disk0`、`disk1`、...というラベルを付けます。

<figure><img src="https://3549141153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeLm8O7QKZDn6z806e7Sv%2Fuploads%2Fgit-blob-fef041e38bebd81f4de58043e71b3a3d493214aa%2Fnxcheseaux-20230419-171420-2x-20230419-151421.png?alt=media" alt="" width="544"><figcaption></figcaption></figure>

`diskutil list`コマンドを使用して、すべてのデバイスを`/dev/disk0`、`/dev/disk1`、...のように表示できます。

<figure><img src="https://3549141153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeLm8O7QKZDn6z806e7Sv%2Fuploads%2Fgit-blob-bfcda09acaea0c1ee6f9bbc78a29aaad9e992960%2Fscreenshot-2023-03-30-at-14-11-19.png?alt=media" alt=""><figcaption></figcaption></figure>

### ボリューム <a href="#investigatingstorage-disksandvolumes-volume" id="investigatingstorage-disksandvolumes-volume"></a>

ボリュームは、データを整理および管理するためにディスク内の記憶単位を指します。 それは論理パーティションとして機能し、ファイルシステムでフォーマットすることができ、ユーザーがファイルを保存およびアクセス可能にします。 単一のディスクに複数のボリュームが含まれる場合がありますが、各ボリュームは独立して動作し、ストレージシステムに追加の柔軟性と整理を提供します。

**Windows**

Windowsでは、Disk Managementアプリケーションで、システムがボリュームをボリュームとして一覧表示します。

<figure><img src="https://3549141153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeLm8O7QKZDn6z806e7Sv%2Fuploads%2Fgit-blob-3cfffcc7a12b1fedb8956ac75ecc4b99b007c626%2Fnxcheseaux-20230419-170847-2x-20230419-150922.png?alt=media" alt=""><figcaption></figcaption></figure>

**macOS**

Disk Utilityアプリケーションでは、システムがそれらが属するメディアの下にボリュームを表示します。

<figure><img src="https://3549141153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeLm8O7QKZDn6z806e7Sv%2Fuploads%2Fgit-blob-1266062905c11f450121f7e5a98d5128b159deae%2Fnxcheseaux-20230419-171303-2x-20230419-151304.png?alt=media" alt="" width="544"><figcaption></figcaption></figure>

macOSでの`diskutil list`コマンドを使用すると、ボリュームがそれぞれのディスクドライブの下に表示され、`/dev/disk0s1`、`/dev/disk0s2`のような識別子が付けられます。

<figure><img src="https://3549141153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeLm8O7QKZDn6z806e7Sv%2Fuploads%2Fgit-blob-bfcda09acaea0c1ee6f9bbc78a29aaad9e992960%2Fscreenshot-2023-03-30-at-14-11-19.png?alt=media" alt=""><figcaption></figcaption></figure>

### NQL例 <a href="#investigatingstorage-disksandvolumes-nqlexamples" id="investigatingstorage-disksandvolumes-nqlexamples"></a>

<details>

<summary>デバイス上のシステムドライブ（ボリューム/パーティション）の空きスペースを一覧表示します。</summary>

{% code overflow="wrap" lineNumbers="true" %}

```
過去7日間のデバイス
| ボリュームを含む
| システム == true の場合
| system_drive_free_space = capacity.sum() * (1 - usage.sum()) を計算
| device.name, system_drive_free_space をリスト
```

{% endcode %}

</details>

<details>

<summary>デバイス上のシステムドライブの使用状況を一覧表示します。</summary>

{% code overflow="wrap" lineNumbers="true" %}

```
過去7日間のデバイス
| 過去7日間のデバイスパフォーマンスイベントを含む
| system_drive_used = event.system_drive_usage.avg() を計算
| device.name, system_drive_used をリスト
| system_drive_used を降順に並べ替え
```

{% endcode %}

</details>

<details>

<summary>システムドライブに空きが5GB未満のデバイスを一覧表示します。</summary>

{% code overflow="wrap" lineNumbers="true" %}

```
過去7日間のデバイス
| ボリュームを含む 
| system == true の場合 
| compute system_drive_free_space = capacity.sum() * (1 - usage.sum()) 
| system_drive_free_space < 5000000000 の場合 
| device.name と system_drive_free_space をリスト
```

{% endcode %}

</details>

<details>

<summary>デバイスのディスクとボリュームの概要を一覧表示します。</summary>

{% code overflow="wrap" lineNumbers="true" %}

```
過去7日間のデバイス
| device.name, disks, volumes をリスト
```

{% endcode %}

</details>

<details>

<summary>すべてのデバイスからのすべてのディスクのサイズ、起動可能状態、およびタイプ（SSDまたはHDD）を一覧表示します。</summary>

{% code overflow="wrap" lineNumbers="true" %}

```
ディスク
| device.name、name、is_bootable、capacity、type をリスト
```

{% endcode %}

</details>
