Oracle Linux でパーティションを作成または管理するには、さまざまなオプションがあります。fdisk はその 1 つです。この投稿では、その使用法と、新しいパーティション テーブルを作成する際のユース ケースについて説明します。 fdisk は、パーティション テーブルを作成および操作するためのメニュー方式のプログラムです。 GPT (現時点では実験的)、MBR、Sun、SGI、および BSD パーティション テーブルを認識します。
ハードディスクは、パーティションと呼ばれる 1 つまたは複数の論理ディスクに分割できます。この分割は、ディスクのセクター 0 にあるパーティション テーブルに記録されます。 (BSD の世界では、「ディスク スライス」と「ディスクラベル」について話します。)
Linux には、ルート ファイル システム用に少なくとも 1 つのパーティションが必要です。スワップ ファイルやスワップ パーティションを使用できますが、後者の方が効率的です。そのため、通常、スワップ パーティション専用の 2 つ目の Linux パーティションが必要になります。 Intel 互換のハードウェアでは、システムを起動する BIOS は多くの場合、ディスクの最初の 1024 シリンダーにしかアクセスできません。このため、大容量のディスクを使用しているユーザーは、カーネル イメージとブート時に必要ないくつかの補助ファイルを格納するために、通常は /boot にマウントされるわずか数 MB の 3 番目のパーティションを作成することがよくあります。 BIOS にアクセスできます。セキュリティ、管理とバックアップの容易さ、またはテストの理由により、最小数よりも多くのパーティションを使用する場合があります。
必要な基本的な fdisk コマンドは次のとおりです。
- p パーティションテーブルを出力
- いいえ 新しいパーティションを作成
- d パーティションを削除
- q 変更を保存せずに終了
- w 新しいパーティション テーブルを書き込んで終了
パーティション テーブルに加えた変更は、書き込み (w) を発行するまで有効になりません。 ) コマンド。
詳細については、man ページを参照してください:
# man fdisk
fdisk によるディスクのパーティション分割
1. 目的のデバイス「/dev/device_name」に対して fdisk を実行します。
# fdisk /dev/sdc Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Command (m for help):
2. オプション「p」を選択して、ディスクのパーティション テーブルを印刷します。
Command (m for help): p Disk /dev/sdc: 4294 MB, 4294967296 bytes, 8388608 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
3. オプション「n」を選択して、新しいパーティションを作成します。
Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): First sector (2048-8388607, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-8388607, default 8388607): 4056 Partition 1 of type Linux and of size 1004.5 KiB is set注意 :別のパーティションを作成するには、オプション「n」を再度選択します。
以下は、同じディスクに別のパーティションを作成する例です:
Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p Partition number (2-4, default 2): First sector (4057-8388607, default 4096): Using default value 4096 Last sector, +sectors or +size{K,M,G} (4096-8388607, default 8388607): Using default value 8388607 Partition 2 of type Linux and of size 4 GiB is set
4. オプション「p」でパーティション テーブルを確認します。 「:
Command (m for help): p Disk /dev/sdc: 4294 MB, 4294967296 bytes, 8388608 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Device Boot Start End Blocks Id System /dev/sdc1 2048 4056 1004+ 83 Linux /dev/sdc2 4096 8388607 4192256 83 Linux
5. オプション「w」を選択して、新しいパーティションを書き込みます。
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
6. コマンド partprobe を実行して、パーティション テーブルの変更を OS に通知します。
# partprobe