跳转至

大于2T硬盘分区

在Linux系统中,对于大于2TB的硬盘,推荐使用GPT分区表(GUID Partition Table,简称GPT)来进行分区,因为传统的MBR分区表(Master Boot Record,简称MBR)仅支持最大2TB的存储空间,而GPT则支持最大18EB(1EB=1024TB)的存储空间,且每个磁盘最多支持128个分区。对于大于2TB的硬盘,使用MBR分区表会导致无法使用全部存储空间。因此,将硬盘转换为GPT格式是必要的步骤。

查看硬盘信息

使用lsblk或fdisk命令查看

lsblk
[root@quantum opt]# lsblk 
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    0 14.6T  0 disk 
nvme0n1     259:0    0  1.8T  0 disk 
├─nvme0n1p1 259:1    0  512M  0 part /boot/efi
├─nvme0n1p2 259:2    0    1G  0 part /boot
└─nvme0n1p3 259:3    0  1.8T  0 part 
  ├─rl-root 253:0    0  1.8T  0 lvm  /
  └─rl-swap 253:1    0    4G  0 lvm  [SWAP]
fdisk -l
[root@quantum ~]# fdisk -l
Disk /dev/nvme0n1: 1.8 TiB, 2000398934016 bytes, 3907029168 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
Disklabel type: gpt
Disk identifier: 2DA9EFC9-F455-4547-A4CA-D382DA2DF0DF

Device           Start        End    Sectors  Size Type
/dev/nvme0n1p1    2048    1050623    1048576  512M EFI System
/dev/nvme0n1p2 1050624    3147775    2097152    1G Linux filesystem
/dev/nvme0n1p3 3147776 3907028991 3903881216  1.8T Linux LVM


Disk /dev/sda: 14.6 TiB, 16000900661248 bytes, 31251759104 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: 865B7F81-697B-457E-9674-D9DB5C106CA9

Device     Start         End     Sectors  Size Type
/dev/sda1     34       32767       32734   16M Microsoft reserved
/dev/sda2  32768 31251755007 31251722240 14.6T Microsoft basic data

Partition 1 does not start on physical sector boundary.


Disk /dev/mapper/rl-root: 1.8 TiB, 1994488020992 bytes, 3895484416 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/rl-swap: 4 GiB, 4294967296 bytes, 8388608 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

parted分区

[root@quantum ~]# parted /dev/sda
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt                                                      
Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes                                                               
(parted) mkpart primary 0% 100%                                           
(parted) print                                                            
Model: ATA ST16000NM001G-2K (scsi)
Disk /dev/sda: 16.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  16.0TB  16.0TB               primary

(parted) quit                                                             
Information: You may need to update /etc/fstab.
再用fdisk确认
[root@quantum ~]# fdisk -l /dev/sda
Disk /dev/sda: 14.6 TiB, 16000900661248 bytes, 31251759104 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: F7A3C624-02E0-476C-9D75-99C5AAB4DB2A

Device     Start         End     Sectors  Size Type
/dev/sda1   2048 31251757055 31251755008 14.6T Linux filesystem

格式化

[root@quantum ~]# mkfs.xfs /dev/sda1
meta-data=/dev/sda1              isize=512    agcount=15, agsize=268435455 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1    bigtime=0 inobtcount=0
data     =                       bsize=4096   blocks=3906469376, imaxpct=5
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=521728, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

挂载

使用blkid查看UUID号

[root@quantum ~]# blkid /dev/sda1
/dev/sda1: UUID="a03e9e0e-7281-4244-8cab-e72e280350ee" BLOCK_SIZE="4096" TYPE="xfs" PARTLABEL="primary" PARTUUID="c5fb905b-666c-45b4-9551-5b3c42f80d49"

修改fstab配置文件

[root@quantum ~]# vi /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Tue Sep 10 09:08:03 2024
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/rl-root     /                       xfs     defaults        0 0
UUID=f78bbea0-463d-478d-8925-564a92808dae /boot                   ext4    defaults        1 2
UUID=C6E3-6EF2          /boot/efi               vfat    defaults,uid=0,gid=0,umask=077,shortname=winnt 0 2
UUID=a03e9e0e-7281-4244-8cab-e72e280350ee /home                   xfs     defaults        0 0
/dev/mapper/rl-swap     none                    swap    defaults        0 0
修改保存后,使用systemctl daemon-reload更新systemd单元。

使用mount命令挂载为/home分区

[root@quantum ~]# mount /dev/sda1 /home
[root@quantum ~]# df -hl
Filesystem           Size  Used Avail Use% Mounted on
devtmpfs             252G     0  252G   0% /dev
tmpfs                252G     0  252G   0% /dev/shm
tmpfs                252G   35M  252G   1% /run
tmpfs                252G     0  252G   0% /sys/fs/cgroup
/dev/mapper/rl-root  1.9T   35G  1.8T   2% /
/dev/nvme0n1p2       974M  229M  678M  26% /boot
/dev/nvme0n1p1       511M  5.8M  506M   2% /boot/efi
tmpfs                 51G     0   51G   0% /run/user/0
/dev/sda1             15T  104G   15T   1% /home

本文阅读量  次
本站总访问量  次