在非交互式parted命令中设置分区类型

在非交互式parted命令中设置分区类型

我在 Linux (Centos) 中有一个新磁盘:

# fdisk -l /dev/sdb

Disk /dev/sdb: 536 MB, 536870912 bytes, 1048576 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

我使用命令创建 GPT 分区表和新分区:

# parted -a optimal --script /dev/sdb mklabel gpt mkpart primary 0% 100%

fdisk -l显示:

# fdisk -l /dev/sdb
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sdb: 536 MB, 536870912 bytes, 1048576 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: gpt
Disk identifier: 332CB746-DE7D-4FB0-AE34-D9B5CB008473


#         Start          End    Size  Type            Name
 1         2048      1046527    510M  Microsoft basic primary

为什么parted命令将类型设置为“ Microsoft basic”?如何Linux filesystem使用上面的命令行(非交互式)parted命令将其设置为“”?

目前,要更改它,我需要手动运行“ gdisk /dev/sdb”,然后t选择 code 8300

Command (? for help): t
Using 1
Current type is 'Microsoft basic data'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'

另一个问题是,为什么当我使用上述命令创建分区parted并使用100%大小时,它最终比使用gdisk命令创建分区时小 1MB?

分手:

#         Start          End    Size  Type            Name
 1         2048      1046527    510M  Linux filesyste primary

g磁盘:

#         Start          End    Size  Type            Name
 1         2048      1048542    511M  Linux filesyste Linux filesystem

相关内容