fdisk? gdisk解决磁盘分区2T限制

##提示,磁盘操作先进行备份哦

扩展1:
Linux centos系统如何查看磁盘分区类型时MBR还是GPT:
执行 fdisk -l 或者 parted -l 命令查看,如果是msdos 或者dos 则是MBR分区;如果是gpt,毋庸置疑是GPT分区

fdisk? gdisk解决磁盘分区2T限制_第1张图片

扩展2:

(parted) mkpart primary 17.2GB 100%
Error: partition length of 6257901568 sectors exceeds the msdos-partition-table-imposed maximum of 4294967295

报错原因:分区格式为MBR,最大支持2TB,实际剩余空间大于2TB

今天对一个3T的磁盘进行分区,出现以下提示:

[root@localhost ~]# fdisk /dev/sda

WARNING: The size of this disk is 3.2 TB (3221225472000 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
partition table format (GPT)

当利用fdisk 进行磁盘分区时,由于MBR分区类型的磁盘最大支持2TB,当大于2TB,只会分配2T的空间,此时会面临以下问题:
1.将剩余空间再进行分区,这样方法可行,但是管理起来麻烦
2.将MBR分区转化为GPT分区,然后利用 parted 命令(parted /dev/sdb mklabel gpt)可修改磁盘分区格式,对于新增的磁盘来说这样方式似乎可行,但是我这里服务器只有一个盘 /dev/sda,直接进行数据将重置磁盘数据具有数据丢失风险

进行了一大堆百度后发现gdisk 这个命令完美解决fdisk 命令的缺点,

yum install  -y gdisk  

直接贴操作如下,

[root@localhost ~]# gdisk /dev/sda
GPT fdisk (gdisk) version 0.8.10

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present


***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************


Command (? for help): p
Disk /dev/sda: 6291456000 sectors, 2.9 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): CB05B9CF-BD96-44B8-924A-24A0F0C50E0F
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 6291455966
Partitions will be aligned on 2048-sector boundaries
Total free space is 2385207229 sectors (1.1 TiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         2099199   1024.0 MiB  8300  Linux filesystem
   2         2099200        33554431   15.0 GiB    8E00  Linux LVM
   3        33554432      3906250751   1.8 TiB     8300  Linux filesystem

Command (? for help): d
Partition number (1-3): 3

Command (? for help): p
Disk /dev/sda: 6291456000 sectors, 2.9 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): CB05B9CF-BD96-44B8-924A-24A0F0C50E0F
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 6291455966
Partitions will be aligned on 2048-sector boundaries
Total free space is 6257903549 sectors (2.9 TiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         2099199   1024.0 MiB  8300  Linux filesystem
   2         2099200        33554431   15.0 GiB    8E00  Linux LVM

Command (? for help): n
Partition number (3-128, default 3):
First sector (34-6291455966, default = 33554432) or {+-}size{KMGTP}:
Last sector (33554432-6291455966, default = 6291455966) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): p
Hex code or GUID (L to show codes, Enter = 8300): 8e
Exact type match not found for type code 008E; assigning type code for
'Linux filesystem'
Changed type of partition to 'Linux filesystem'

Command (? for help): p
Disk /dev/sda: 6291456000 sectors, 2.9 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): CB05B9CF-BD96-44B8-924A-24A0F0C50E0F
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 6291455966
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         2099199   1024.0 MiB  8300  Linux filesystem
   2         2099200        33554431   15.0 GiB    8E00  Linux LVM
   3        33554432      6291455966   2.9 TiB     8300  Linux filesystem

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
[root@ITP172023017249 ~]# gdisk  -l
GPT fdisk (gdisk) version 0.8.10

Problem opening -l for reading! Error is 2.
The specified file does not exist!
[root@ITP172023017249 ~]# fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sda: 3221.2 GB, 3221225472000 bytes, 6291456000 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


#         Start          End    Size  Type            Name
 1         2048      2099199      1G  Linux filesyste Linux filesystem
 2      2099200     33554431     15G  Linux LVM       Linux LVM
 3     33554432   6291455966    2.9T  Linux filesyste Linux filesystem

Disk /dev/mapper/cl-root: 14.4 GB, 14382268416 bytes, 28090368 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/mapper/cl-swap: 1719 MB, 1719664640 bytes, 3358720 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

[root@localhost~]#

你可能感兴趣的:(linux,linux,磁盘分区)