Linuxにおけるストレージの専門用語と概念の紹介

以下の文章を日本語で自然に言い換えてください。1つのオプションでかまいません。

イントロダクション

Linuxは、ストレージドライブを含むハードウェアデバイスを管理するための堅牢なシステムとツールを備えています。この記事では、Linuxがこれらのデバイスをどのように表現し、生のストレージをサーバー上の利用可能なスペースに変換するかについて、基本的なレベルで説明します。

ブロックストレージとは何ですか?

ブロックストレージは、Linuxカーネルがブロックデバイスと呼ぶものの別名です。ブロックデバイスは、従来の回転式ハードディスクドライブ(HDD)、ソリッドステートドライブ(SSD)、フラッシュメモリスティックなどのように、データを保存するために使用できるハードウェアの一部です。カーネルは、固定サイズのブロックまたはスペースのチャンクを参照することによってハードウェアと通信するため、ブロックデバイスと呼ばれています。

言い換えると、ブロックストレージとはコンピュータ上の通常のディスクストレージのことを指します。一度設定されると、現在のファイルシステムツリーの拡張として機能し、各ドライブに書き込みまたは情報を読み込むことができるはずです。

ディスクパーティションとは何ですか?

ディスクのパーティションは、ストレージドライブをより小さな使用可能な単位に分割する方法です。パーティションとは、ドライブそのものとほぼ同じように扱うことができるストレージドライブのセクションです。

パーティション分割によって、利用可能なスペースをセグメント化し、各パーティションを異なる目的で使用することができます。これにより、ユーザーは柔軟性が増し、1つのディスクを複数のオペレーティングシステム、スワップスペース、または専用のファイルシステムに分割することができます。

ディスクはパーティションなしでフォーマットして使用することもできますが、オペレーティングシステムは通常、パーティションテーブルが存在することを期待しています。ディスクに単一のパーティションしか書き込まれていなくても、一般的には新しいドライブをパーティションに分割することが推奨されています。

MBRとGPTの比較

ディスクをパーティションに分割する際には、どのパーティション形式を使用するかを知ることが重要です。一般的には、MBR(マスターブートレコード)とGPT(GUIDパーティションテーブル)の選択肢から選ぶことになります。

MBRは30年以上の歴史があります。その歳月のため、いくつかの深刻な制限が存在します。例えば、2TB以上のディスクには使用できず、最大で主要パーティションを4つしか持つことができません。

GPTはMBRに内在するいくつかの問題を解決する、より最新のパーティションスキームです。GPTを実行するシステムは、ディスクごとにより多くのパーティションを持つことができます。これは通常、オペレーティングシステム自体によって課される制限によってのみ制約されます。さらに、GPTではディスクサイズの制限が存在せず、パーティションテーブル情報は破損を防ぐために複数の場所に利用できます。GPTはまた、「保護MBR」を書き込むこともでき、MBRのみ対応のツールとの互換性を確保します。

ほとんどのケースでは、GPTが最善の選択ですが、オペレーティングシステムが使用を妨げている場合には選択肢に含まれません。

フォーマッティングとファイルシステム

Linuxカーネルは、生のディスクを認識できますが、使用するためにはフォーマットする必要があります。フォーマットとは、ファイルシステムをディスクに書き込んで、ファイル操作に備えるプロセスです。ファイルシステムとは、データを構造化し、基礎となるディスクから情報を書き込んだり取得したりする方法を制御するシステムです。ファイルシステムがなければ、ストレージデバイスを標準的なファイルシステム操作には使用できません。

様々なファイルシステム形式が存在し、それぞれがオペレーティングシステムのサポートを含めてトレードオフを持っています。全てのファイルシステムはユーザーにディスクの類似した表現を提供していますが、それらがサポートする機能やプラットフォームは非常に異なる場合があります。

Linuxでよく使われるファイルシステムのいくつかは以下の通りです。

  • Ext4: The most popular default filesystem is Ext4, a successor to Ext2 and Ext3. The Ext4 filesystem is journaled, backwards compatible with legacy systems, stable, and has mature support and tooling. It is a good choice if you have no specialized needs.
  • XFS: XFS specializes in performance and large data files. It formats quickly and has good throughput characteristics when handling large files and when working with large disks. It also has live snapshotting features. XFS uses metadata journaling as opposed to journaling both the metadata and data. This leads to fast performance, but can potentially lead to data corruption in the event of an abrupt power loss.
  • Btrfs: Btrfs is a modern, feature-rich copy-on-write filesystem. This architecture allows for some volume management functionality to be integrated within the filesystem layer, including snapshots and cloning. It is used by default on some consumer and commercial NAS (networked-attached storage) hardware, and is popular for dedicated, multi-disk arrays
  • ZFS: ZFS is another copy-on-write filesystem and volume manager with a robust and mature feature set. It competes fairly directly with Btrfs, has data integrity features, can handle large filesystem sizes, has typical volume features like snapshotting and cloning, and can organize volumes into RAID and RAID-like arrays for redundancy and performance purposes. ZFS has a controversial history due to licensing concerns, but it is not much more or less popular than Btrfs when taking into account commercial support.

また、Windowsでは主にNTFSとExFATを使用していますし、macOSでは主にHFS+とAPFSを使用しています。これらのファイルシステム形式は異なるプラットフォームでも読み取ることは通常可能ですが、書き込むには追加の互換性ツールが必要な場合もあります。

Linuxは、ストレージデバイスをどのように管理していますか?

「/dev」内のデバイスファイル

Linuxでは、ファイルシステムの階層のどこかにほぼすべてのものがファイルとして表されます。これには、ストレージドライブなどのハードウェアも含まれますが、システム上では/devディレクトリのファイルとして表されます。通常、ストレージデバイスを表すファイルは、sdまたはhdの後に文字が続く形で始まります。例えば、サーバー上の最初のドライブは通常/dev/sdaなどのようなものです。

これらのドライブのパーティションも、/dev内にファイルが含まれています。ドライブ名の末尾にパーティション番号を追加して表されます。たとえば、前の例のドライブの最初のパーティションは/dev/sda1となります。

「/dev/sd*」および「/dev/hd*」デバイスファイルは、ドライブやパーティションを参照する伝統的な方法を表していますが、これらの値だけを使用することには重大な欠点があります。Linuxカーネルは、各起動時にどのデバイスがどの名前を取得するかを決定するため、デバイスノードが変更される可能性があると、混乱を招くシナリオが発生することがあります。

この問題を回避するために、/dev/diskディレクトリには、システム上のディスクやパーティションをより永続的に識別するためのサブディレクトリが含まれています。これらは、起動時に正しい/dev/[sh]da*ファイルにバックリンクが作成されるシンボリックリンクが含まれています。これらのリンクは、ディレクトリの識別特性に基づいて名前が付けられます(たとえば、/dev/disk/by-partlabelディレクトリではパーティションのラベルに基づいています)。これらのリンクは常に正しいデバイスを指し示すため、ストレージスペースの静的な識別子として使用することができます。

「/dev/disk」ディレクトリの下には、以下のいずれかまたはすべてのサブディレクトリが存在する可能性があります。

  • by-label: Most filesystems have a labeling mechanism that allows the assignment of arbitrary user-specified names for a disk or partition. This directory consists of links named after these user-supplied labels.
  • by-uuid: UUIDs, or universally unique identifiers, are a long, unique string of letters and numbers that can be used as an ID for a storage resource. These are generally not very human-readable, but are almost always unique, even across systems. As such, it might be a good idea to use UUIDs to reference storage that may migrate between systems, since naming collisions are less likely.
  • by-partlabel and by-partuuid: GPT tables offer their own set of labels and UUIDs, which can also be used for identification. This functions in much the same way as the previous two directories, but uses GPT-specific identifiers.
  • by-id: This directory contains links generated by the hardware’s own serial numbers and the hardware they are attached to. This is not entirely persistent, because the way that the device is connected to the system may change its by-id name.
  • by-path: Like by-id, this directory relies on a storage device’s connection to the system itself. The links here are constructed using the system’s interpretation of the hardware used to access the device. This has the same drawbacks as by-id as connecting a device to a different port can alter this value.

通常、特定のデバイスの永続的な識別のためには、通常、ラベルまたはUUIDによる方法が最適な選択肢です。

Note

注意:Silicon Cloudのブロックストレージボリュームは、オペレーティングシステムに報告されるデバイスシリアル番号を制御します。これにより、このプラットフォーム上でのby-idカテゴリへの一貫した永続性が可能となります。これは、Silicon Cloudのボリュームを参照するための推奨される方法であり、初回起動時に一貫して予測可能です。

ブロックデバイスのマウント

Linuxとその他のUnixライクなオペレーティングシステムでは、物理デバイスの数に関係なく、システム全体が単一の統合されたファイルツリーで表されます。ドライブやパーティション上のファイルシステムを使用するためには、既存のツリーに接続する必要があります。マウントは、フォーマットされたパーティションやドライブをLinuxファイルシステム内のディレクトリに接続するプロセスです。そのディレクトリからドライブの内容にアクセスすることができます。

ほとんどの場合、ドライブは専用の空のディレクトリにマウントされます。既存のディレクトリにマウントすると、ドライブがアンマウントされるまでそのディレクトリの通常の内容にアクセスできなくなります。マウントされたデバイスの振る舞いを変更するために設定できる多くの異なるオプションがあります。例えば、ドライブは読み取り専用モードでマウントされることで、その内容が変更されないようになります。

ファイルシステム階層標準では、一時的にマウントされるファイルシステムには/mntまたはそのサブディレクトリを使用することを推奨しています。より永続的なストレージをマウントする場所については、推奨事項はありませんので、お好きな方法を選択できます。多くの場合、/mntや/mntのサブディレクトリはより永続的なストレージとしても使用されます。

/etc/fstabを使用して、マウントを永続的に設定する。

Linuxシステムは、ブートプロセス中にどのファイルシステムをマウントするかを決定するために、/etc/fstab(ファイルシステムテーブル)というファイルを使用します。このファイルにエントリーがないファイルシステムは、他のソフトウェアによってスクリプト化されていない限り、自動的にマウントされません。

/etc/fstabファイルの各行は、マウントする異なるファイルシステムを表します。この行はブロックデバイス、アタッチするマウントポイント、ドライブの形式、マウントオプション、およびいくつかのその他の情報を指定します。

より複雑なストレージ管理

これらの基本機能によって多くのユースケースを対応できますが、特にRAIDという複数のディスクを結合するためのより複雑な管理パラダイムも利用可能です。

RAIDとは何ですか?

RAIDは、独立したディスクの冗長配列(Redundant Array of Independent Disks)の略称です。RAIDは、ドライブをまとめて追加機能を持つ単一のユニットとして管理するためのストレージ管理および仮想化技術です。

RAIDアレイの特性は、アレイ内のディスク同士の関係を定義するRAIDレベルによって異なります。よく使用されるレベルのいくつかは次の通りです。

  • RAID 0: This level indicates drive striping. This means that as data is written to the array, it is split up and distributed linearly among the disks in the set. This offers a performance boost as multiple disks can be written to or read from simultaneously. The downside is that a single drive failure can lose all of the data in the entire array, since no one disk contains enough information about the contents to rebuild. RAID 0 is usually never used in production for this reason, though it can be useful as a point of comparison.
  • RAID 1: RAID 1 indicates drive mirroring. Anything written to a RAID 1 array is written to multiple disks. Its main advantage is data redundancy, which allows data to survive hard drive loss on either side of the mirror. Because multiple drives will contain the exact same data, your usable capacity is reduced by at least half.
  • RAID 5: RAID 5 stripes data across multiple drives, similar to RAID 0. However, this level also implements a distributed parity across the drives. This means that if a drive fails, the remaining drives can rebuild the array using the parity information shared between them. Usually, this is enough to rebuild one disk, meaning the array can survive any one disk loss. RAID 5 reduces the available space in an array by the capacity of one disk.
  • RAID 6: RAID 6 has the same properties as RAID 5, but provides double parity. This means that RAID 6 arrays can withstand the loss of any 2 drives. The capacity of the array is again affected by the parity amount, meaning that the usable capacity is reduced by two disks worth of space.
  • RAID 10: RAID 10 is a combination of levels 1 and 0. First, two sets of mirrored arrays are made. Then, data is striped across them. This creates an array that has some redundancy characteristics while providing good performance. This requires quite a few drives however, and total capacity is still less than half of the combined disk space.

次にどこに行くべきですか?
Tsugi ni doko ni iku beki desu ka?

もし新しいストレージデバイスをLinuxシステムで使用したい場合、この記事では新しいファイルシステムのパーティション分割、フォーマット、マウントのプロセスを案内します。これは、追加容量を主に心配している場合にはほとんどのユースケースに十分な情報となるでしょう。ストレージ管理タスクの実行方法を学びたい場合は、Linuxのストレージデバイスの基本的な管理タスクの実行方法を参照してください。

コメントを残す 0

Your email address will not be published. Required fields are marked *