③linux Gdisk

5.磁盘的基本分区Gdisk

前面我们已经了解到fdisk分区,但fdisk不支持给高于2TB的磁盘进行分区。如果有单块盘高于2TB,建议使用Gdisk进行分区。

1.使用gdisk进行磁盘分区

#1.安装gdisk分区工具
[root@xuliangwei ~]# yum install gdisk -y

#2.创建一个新分区,500MB大小
[root@xuliangwei ~]# gdisk /dev/sdb
Command (? for help): n     #创建新分区
Partition number (1-128, default 1):
First sector (34-2097118, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-2097118, default = 2097118) or {+-}size{KMGTP}: +500M #分配500M大小

Command (? for help): p #打印查看
Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1026047   500.0 MiB   8300  Linux filesystem

Command (? for help): w #保存分区
Do you want to proceed? (Y/N): y    #确认
OK; writing new GUID partition table (GPT) to /dev/sdb.
The operation has completed successfully.

#3.创建完成后,可以尝试检查磁盘是否为gpt格式
[root@xuliangwei-node1 /]# fdisk /dev/sdb -l|grep type
Disk label type: gpt

#4.安装parted, 刷新内核立即生效,无需重启
[root@xuliangwei ~]# yum -y install parted
[root@xuliangwei ~]# partprobe /dev/sdb

2.使用mkfs进行格式化磁盘。前面已经介绍过,此处不反复介绍。

[root@xuliangwei ~]# mkfs.xfs  /dev/sdb

3.使用mount命令将某个目录挂载该分区,进行使用。

[root@xuliangwei ~]# mkdir /data_gdisk
[root@xuliangwei ~]# mount /dev/sdb /data_gdisk
原文地址:https://www.cnblogs.com/yangtao416/p/14515736.html