4TB-SATA-format-to-ext4

主要使用两个命令:fdiskmkfs.ext4

查看硬盘信息

1
2
3
4
5
6
7
8
9
10
11
12
13
root@OpenWrt:~# fdisk /dev/sda

Welcome to fdisk (util-linux 2.24.1).
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/sda: 3.7 TiB 4000787030016 bytes, 7814037168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: C6994F92-8CF2-49B4-AC75-3F756C0C678A

注意类型要gpt,如果是dos的话寻址最多只能到2Tgpt才能正确识别到4T

添加GPT分区表

上面查看信息时显示是gpt的话就可以略过本步骤

1
2
3
4
5
6
7
8
9
10
Command (m for help): m # 命令列表

Help:

......
Create a new label
g create a new empty GPT partition table
......

Command (m for help): g # 新建GPT分区表

添加卷标

上文的显示可看到少了/dev/sda1卷标,添加命令如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Command (m for help): m # 命令列表

Help:

Generic
......
n add a new partition
......

Command (m for help): n # 新建分区
Partition number (1-128, default 1): # 回车即可
First sector (34-7814037134, default 2048): # 回车即可
Last sector, +sectors or +size{K,M,G,T,P} (2048-7814037134, default 7814037134): # 回车即可

Created a new partition 1 of type 'Linux filesystem' and of size 3.7 TiB.

Command (m for help): p # 再次查看信息
Disk /dev/sda: 3.7 TiB 4000787030016 bytes, 7814037168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: C6994F92-8CF2-49B4-AC75-3F756C0C678A

Device Start End Size Type
/dev/sda1 2048 7814037134 3.7T Linux filesystem

可看到这里生成了/dev/sda1卷标。

修改分区类型

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Command (m for help): m # 命令列表

Help:

Generic
......
t change a partition type
......

Command (m for help): t # 修改类型

Selected partition 1
Partition type (type L to list all types): L # 查看支持的类型
......
13 Linux filesystem
......

Partition type (type L to list all types): 13 # 选择13

最后保存退出即可。

格式化

1
mkfs.ext4 /dev/sda1

注意是sda1