ntsk

Arch LinuxでHDDの認識・パーティション作成・フォーマット

September 23, 2021

毎回忘れるので手順をまとめておく。

認識されているか確認

sudo fdisk -l でパーティションテーブルの一覧を表示する。

以下は実行結果の一部。

Disk /dev/sde: 5.46 TiB, 6001175126016 bytes, 11721045168 sectors
Disk model: 003-2CY186      
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 /dev/loop23: 65.21 MiB, 68378624 bytes, 133552 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 /dev/sdf: 5.46 TiB, 6001175126016 bytes, 11721045168 sectors
Disk model: ST6000DM003-2CY1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

容量やDisk model から接続したHDDを特定する。 今回新たに追加したHDDは、Seagate ST6000DM003 であることから デバイスが、/dev/sdf として認識されていることが分かる。

同じようなHDDが複数あって本当にこれか確信が持てない場合には、df などを実行して使用量をチェックすると良い。

ちなみに /dev/loopX のように表示されているのは、ループバックデバイスなので無視して良い。

GPTパーティションの作成

fdiskではGPT対応のパーティションが作成できないため、gdiskを利用する。

sudo gdisk /dev/sdf を実行。/dev/sdf は先程調べたデバイス名。

-l オプションを利用せずに gdiskを実行すると、インタラクティブモードで起動する。

GPT fdisk (gdisk) version 1.0.7

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries in memory.

Command (? for help):

コマンドを求められる。ヘルプを確認するとコマンドは以下のようになっている。

Command (? for help): ?
b	back up GPT data to a file
c	change a partition's name
d	delete a partition
i	show detailed information on a partition
l	list known partition types
n	add a new partition
o	create a new empty GUID partition table (GPT)
p	print the partition table
q	quit without saving changes
r	recovery and transformation options (experts only)
s	sort partitions
t	change a partition's type code
v	verify disk
w	write table to disk and exit
x	extra functionality (experts only)
?	print this menu

今回は新規作成のため、o -> n -> w の順に実行して作成する。 すべてデフォルト値を利用。

Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y

Command (? for help): n       
Partition number (1-128, default 1): 
First sector (34-11721045134, default = 2048) or {+-}size{KMGTP}: 
Last sector (2048-11721045134, default = 11721045134) or {+-}size{KMGTP}: 
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): 
Changed type of partition to 'Linux filesystem'

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdf.
The operation has completed successfully.

フォーマット

今回はexFATでフォーマットするため、sudo mkfs.exfat /dev/sdf1 を実行。sdf1は先程作成したパーティション。

mkexfatfs 1.3.0
Creating... done.
Flushing... done.
File system created successfully.

各ファイルシステムと、実行コマンドは以下を見ると良い。 https://wiki.archlinux.org/title/file_systems

あとはmountするなりして利用できる。


© 2020-2024 ntsk.