投稿には、fdisk コマンドを使用してディスク パーティションを削除する手順が記載されています。プライマリ パーティションと拡張パーティションを削除する手順は同じであることに注意してください。この投稿の例では、ディスク /dev/sdc を使用しており、削除するパーティションは /dev/sdc1 です。
ファイルシステムをアンマウント
削除するパーティションを使用してファイルシステムをアンマウントしたことを確認してください。パーティションがマウントされているかどうかを表示するには、次のコマンドを使用します。
# cat /proc/mounts
マウント ポイントをアンマウントするには、次のコマンドを使用します。
# umount /data
削除するパーティションの一覧表示
現在のパーティション スキームのリストを取得するには、「fdisk -/dev/sdc」を使用します 」。印刷コマンド (p ) パーティション テーブルを一覧表示するには:
# 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. Command (m for help): p Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 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 Disk label type: dos Disk identifier: 0x085579f4 Device Boot Start End Blocks Id System /dev/sdc1 2048 2099199 1048576 83 Linux /dev/sdc2 2099200 4196351 1048576 83 Linux
コマンド「fdisk -l」を使用することもできます 」をクリックして、システムで利用可能なすべてのパーティションを表示します。
Linux ディスク パーティションを表示する方法 (パーティション テーブル)パーティションの削除
削除コマンド (d ) パーティションを削除するには、パーティション番号の入力を求められます。この例では、/dev/sdc1 を削除します。そのため、パーティション番号を削除するよう求められたら、番号 1 を使用してください。
Command (m for help): d Partition number (1,2, default 2): 1 Partition 1 is deleted削除する最後のパーティションが残っている場合、deleted コマンドを使用すると、削除するパーティション番号を求めるプロンプトが表示されず、最後のパーティションが直接削除されます。
パーティション テーブルを保存して確認する
印刷コマンド (p ) パーティション テーブルを再度一覧表示し、パーティション 1 が削除されているかどうかを確認します。
Command (m for help): p Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 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 Disk label type: dos Disk identifier: 0x085579f4 Device Boot Start End Blocks Id System /dev/sdc2 2099200 4196351 1048576 83 Linux
最後に、書き込み/終了コマンド (w) で fdisk を保存して終了します。このコマンドの実行後、変更は永続的になります。
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.