主要使用两个命令:fdisk
和mkfs.ext4
查看硬盘信息
1 2 3 4 5 6 7 8 9 10 11 12 13
| root@OpenWrt:~
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
的话寻址最多只能到2T
,gpt
才能正确识别到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
|
添加卷标
上文的显示可看到少了/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
|
最后保存退出即可。
格式化