Ubuntu 16.04 parted 对 GPT 格式硬盘 (12 TB) 分区
1. sudo fdisk -l
strong@foreverstrong:~$ fdisk -l
fdisk: cannot open /dev/loop1: Permission denied
fdisk: cannot open /dev/loop2: Permission denied
fdisk: cannot open /dev/loop3: Permission denied
fdisk: cannot open /dev/loop4: Permission denied
fdisk: cannot open /dev/loop5: Permission denied
fdisk: cannot open /dev/loop6: Permission denied
fdisk: cannot open /dev/loop7: Permission denied
fdisk: cannot open /dev/sda: Permission denied
fdisk: cannot open /dev/sdb: Permission denied
fdisk: cannot open /dev/loop8: Permission denied
fdisk: cannot open /dev/loop9: Permission denied
fdisk: cannot open /dev/loop10: Permission denied
fdisk: cannot open /dev/loop11: Permission denied
fdisk: cannot open /dev/loop12: Permission denied
fdisk: cannot open /dev/sdc: Permission denied
strong@foreverstrong:~$
strong@foreverstrong:~$ sudo fdisk -l
[sudo] password for strong:
Disk /dev/loop1: 4.2 MiB, 4403200 bytes, 8600 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/loop2: 160.2 MiB, 167931904 bytes, 327992 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/loop3: 4.2 MiB, 4403200 bytes, 8600 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/loop4: 54.7 MiB, 57294848 bytes, 111904 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/loop5: 54.7 MiB, 57294848 bytes, 111904 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/loop6: 44.2 MiB, 46325760 bytes, 90480 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/loop7: 140.7 MiB, 147501056 bytes, 288088 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/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 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: 02D8963C-32B7-44B4-AD89-432B577BA326
Device Start End Sectors Size Type
/dev/sda1 2048 2000895 1998848 976M Linux filesystem
/dev/sda2 2000896 66000895 64000000 30.5G Linux swap
/dev/sda3 66000896 1953523711 1887522816 900G Linux filesystem
Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 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: ABA07FFE-B957-4A2C-B228-22D2C7DEB439
Device Start End Sectors Size Type
/dev/sdb1 2048 206847 204800 100M EFI System
/dev/sdb2 206848 468991 262144 128M Microsoft reserved
/dev/sdb3 468992 536872959 536403968 255.8G Microsoft basic data
/dev/sdb4 536872960 1342179327 805306368 384G Microsoft basic data
/dev/sdb5 1342179328 1953523711 611344384 291.5G Microsoft basic data
Disk /dev/loop8: 156.7 MiB, 164290560 bytes, 320880 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/loop9: 44.9 MiB, 47063040 bytes, 91920 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/loop10: 91.3 MiB, 95748096 bytes, 187008 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/loop11: 140.7 MiB, 147501056 bytes, 288088 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/loop12: 91.4 MiB, 95805440 bytes, 187120 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/sdc: 10.9 TiB, 12000138625024 bytes, 23437770752 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: dos
Disk identifier: 0x2052474d
strong@foreverstrong:~$
2. Disks -> 12 TB Hard Disk - /dev/sdc
3. +
-> Create Partition
2.0 TB
3.0 TB
Error creating partition
4. Error: partition length of 5859373056 sectors exceeds the msdos-partition-table-imposed maximum of 4294967295
全局唯一标识分区表 (GUID Partition Table,GPT) 是一个实体硬盘分区表的结构布局标准。
GPT 是可扩展固件接口 (Extensible Firmware Interface,EFI) 标准的一部分,被用于替代 BIOS 系统中的一 32bits 来存储逻辑块地址和大小信息的主引导记录 (Master Boot Record,MBR) 分区表。对于扇区为 512 字节的磁盘,MBR 分区表不支持容量大于 2.2 TB 的分区。GPT 分配 64bits 给逻辑块地址,对于每个扇区大小为 512 字节的磁盘,可以有 9.4 ZB 或 8 ZiB 个 512 字节。
在 MBR 硬盘中,分区信息直接存储于主引导记录 (Master Boot Record,MBR) 中 (主引导记录中还存储着系统的引导程序)。但在 GPT 硬盘中,分区表的位置信息储存在 GPT 头中。出于兼容性考虑,硬盘的第一个扇区仍然用作 MBR,之后才是 GPT 头。
- 如果需要分区大于 2.2 TB,则需要使用磁盘的全局唯一标识分区表 (GUID Partition Table,GPT) 格式重新建立 GPT 分区表
(parted) mklabel gpt
。 - fdisk 分区最大能到 2.2 TB。fdisk 命令针对 MBR 分区进行操作,MBR 分区因为自身设计原因,不能处理大于 2.2 TB 的硬盘。
- 如果需要分区大于 2.2 TB,则需要使用 parted 来分区。
- GPT 磁盘没有四个主分区的限制。
Partition Table: msdos
必须修改为(parted) mklabel gpt
。
strong@foreverstrong:~$ sudo parted /dev/sdc
[sudo] password for strong:
GNU Parted 3.2
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
(parted)
(parted) mkpart primary 0TB 3TB
Error: partition length of 5859373056 sectors exceeds the msdos-partition-table-imposed maximum of
4294967295
(parted)
(parted) quit
strong@foreverstrong:~$
sudo parted /dev/sdc
- 使用 parted 为 /dev/sdc 分区
(parted) print
- 查看硬盘详情,打印当前分区
(parted) mklabel gpt
- 建立 gpt 分区表,将分区设置成 gpt 格式
(parted) mkpart primary 0TB 3TB
- 建立主分区,从 0TB 到 3TB
strong@foreverstrong:~$ sudo parted /dev/sdc
GNU Parted 3.2
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
(parted)
(parted) mklabel gpt
Warning: The existing disk label on /dev/sdc will be destroyed and all data on this disk will be lost.
Do you want to continue?
Yes/No? Yes
(parted)
(parted) print
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted)
(parted) mkpart primary 0TB 3TB
(parted)
(parted) print
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 3000GB 3000GB primary
(parted)
(parted) mkpart extended 3TB 6TB
(parted)
(parted) print
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 3000GB 3000GB primary
2 3000GB 6000GB 3000GB extended
(parted)
(parted) mkpart extended 6TB 9TB
(parted)
(parted) print
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 3000GB 3000GB primary
2 3000GB 6000GB 3000GB extended
3 6000GB 9000GB 3000GB extended
(parted)
(parted) mkpart extended 9TB 12TB
(parted)
(parted) print
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 3000GB 3000GB primary
2 3000GB 6000GB 3000GB extended
3 6000GB 9000GB 3000GB extended
4 9000GB 12.0TB 3000GB extended
(parted)
5. (parted) rm 4
(parted) print free
- 检查硬盘空闲空间
(parted) print free
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
17.4kB 1049kB 1031kB Free Space
1 1049kB 3000GB 3000GB primary
2 3000GB 6000GB 3000GB extended
3 6000GB 9000GB 3000GB extended
4 9000GB 12.0TB 3000GB extended
12.0TB 12.0TB 1032kB Free Space
(parted)
(parted) rm 4
(parted)
(parted) print
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 3000GB 3000GB primary
2 3000GB 6000GB 3000GB extended
3 6000GB 9000GB 3000GB extended
(parted)
(parted) print free
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
17.4kB 1049kB 1031kB Free Space
1 1049kB 3000GB 3000GB primary
2 3000GB 6000GB 3000GB extended
3 6000GB 9000GB 3000GB extended
9000GB 12.0TB 3000GB Free Space
(parted)
(parted) rm 3
(parted) rm 2
(parted) rm 1
(parted)
(parted) print
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted)
6. (parted) mkpart extended 9TB 100%
(parted) mkpart extended 9TB 100%
- 将 9TB 后的剩余空间全部创建成一个扩展分区
(parted) quit
- 退出
(parted) print
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted)
(parted) mkpart primary 0 3TB
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Cancel
(parted)
(parted) print
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted)
(parted) mkpart primary 0TB 3TB
(parted)
(parted) print
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 3000GB 3000GB primary
(parted)
(parted) mkpart extended 3TB 6TB
(parted)
(parted) print
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 3000GB 3000GB primary
2 3000GB 6000GB 3000GB extended
(parted)
(parted) mkpart extended 6TB 9TB
(parted)
(parted) print
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 3000GB 3000GB primary
2 3000GB 6000GB 3000GB extended
3 6000GB 9000GB 3000GB extended
(parted)
(parted) mkpart extended 9TB 100%
(parted)
(parted) print
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 3000GB 3000GB primary
2 3000GB 6000GB 3000GB extended
3 6000GB 9000GB 3000GB extended
4 9000GB 12.0TB 3000GB extended
(parted)
(parted) print free
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
17.4kB 1049kB 1031kB Free Space
1 1049kB 3000GB 3000GB primary
2 3000GB 6000GB 3000GB extended
3 6000GB 9000GB 3000GB extended
4 9000GB 12.0TB 3000GB extended
12.0TB 12.0TB 1032kB Free Space
(parted)
(parted)
(parted) quit
Information: You may need to update /etc/fstab.
strong@foreverstrong:~$
7. 格式化分区
mkfs.ntfs 使用 0 填充了所有存储单元。
strong@foreverstrong:~$ sudo parted /dev/sdc print
[sudo] password for strong:
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 3000GB 3000GB ntfs primary
2 3000GB 6000GB 3000GB extended
3 6000GB 9000GB 3000GB extended
4 9000GB 12.0TB 3000GB extended
strong@foreverstrong:~$
strong@foreverstrong:~$ sudo mkfs.ntfs /dev/sdc1
Cluster size has been automatically set to 4096 bytes.
Initializing device with zeroes: 100% - Done.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.
strong@foreverstrong:~$
strong@foreverstrong:~$ sudo mkntfs -f /dev/sdc2
[sudo] password for strong:
The partition start sector was not specified for /dev/sdc2 and the automatically determined value is too large (5859375104). It has been set to 0.
Cluster size has been automatically set to 4096 bytes.
To boot from a device, Windows needs the 'partition start sector', the 'sectors per track' and the 'number of heads' to be set.
Windows will not be able to boot from this device.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.
strong@foreverstrong:~$
strong@foreverstrong:~$ sudo mkntfs -f /dev/sdc3
The partition start sector was not specified for /dev/sdc3 and the automatically determined value is too large (11718750208). It has been set to 0.
Cluster size has been automatically set to 4096 bytes.
To boot from a device, Windows needs the 'partition start sector', the 'sectors per track' and the 'number of heads' to be set.
Windows will not be able to boot from this device.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.
strong@foreverstrong:~$
strong@foreverstrong:~$ sudo mkntfs -f /dev/sdc4
The partition start sector was not specified for /dev/sdc4 and the automatically determined value is too large (17578125312). It has been set to 0.
Cluster size has been automatically set to 4096 bytes.
To boot from a device, Windows needs the 'partition start sector', the 'sectors per track' and the 'number of heads' to be set.
Windows will not be able to boot from this device.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.
strong@foreverstrong:~$
sudo mkfs.ext4 /dev/sdb1
sudo mkfs.ext4 /dev/sdb2
sudo mkfs.ext4 /dev/sdb3
sudo mkfs.ext4 /dev/sdb4
快速格式化 - -f
参数
sudo mkntfs -f /dev/sdc1
sudo mkntfs -f /dev/sdc2
sudo mkntfs -f /dev/sdc3
sudo mkntfs -f /dev/sdc4
8. parted 命令
启动 parted,选择 /dev/sdc
strong@foreverstrong:~$ sudo parted
[sudo] password for strong:
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) select /dev/sdc
Using /dev/sdc
(parted)
(parted) quit
strong@foreverstrong:~$
strong@foreverstrong:~$ sudo parted /dev/sdc
GNU Parted 3.2
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help
align-check TYPE N check partition N for TYPE(min|opt)
alignment
help [COMMAND] print general help, or help on
COMMAND
mklabel,mktable LABEL-TYPE create a new disklabel (partition
table)
mkpart PART-TYPE [FS-TYPE] START END make a partition
name NUMBER NAME name partition NUMBER as NAME
print [devices|free|list,all|NUMBER] display the partition table,
available devices, free space, all found partitions, or a particular
partition
quit exit program
rescue START END rescue a lost partition near START
and END
resizepart NUMBER END resize partition NUMBER
rm NUMBER delete partition NUMBER
select DEVICE choose the device to edit
disk_set FLAG STATE change the FLAG on selected device
disk_toggle [FLAG] toggle the state of FLAG on selected
device
set NUMBER FLAG STATE change the FLAG on partition NUMBER
toggle [NUMBER [FLAG]] toggle the state of FLAG on partition
NUMBER
unit UNIT set the default unit to UNIT
version display the version number and
copyright information of GNU Parted
(parted) quit
strong@foreverstrong:~$
parted 允许用户创建主分区或拓展分区。创建这两种类型的分区的步骤一样,primary (主分区) 或 extended (扩展分区)。
strong@foreverstrong:~$ sudo parted -l
[sudo] password for strong:
Model: ATA ST1000DM010-2EP1 (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 1024MB 1023MB ext4
2 1024MB 33.8GB 32.8GB linux-swap(v1)
3 33.8GB 1000GB 966GB ext4
Model: ATA ST1000DM010-2EP1 (scsi)
Disk /dev/sdb: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 106MB 105MB fat32 EFI system partition boot, esp
2 106MB 240MB 134MB Microsoft reserved partition msftres
3 240MB 275GB 275GB ntfs Basic data partition msftdata
4 275GB 687GB 412GB ntfs Basic data partition msftdata
5 687GB 1000GB 313GB ntfs Basic data partition msftdata
Model: ATA ST12000NM0008-2H (scsi)
Disk /dev/sdc: 12.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
strong@foreverstrong:~$