


















由于使用fdisk进行分区默认在2T内,大于2T后fdisk就无法进行大硬盘进行分区,需要对大于2TB进行分区,使用parted进行分区
且ext4不支持16TB以上的磁盘格式化,如果磁盘大于16TB或以上,就使用xfs格式化磁盘
查看parted 命令详解
[root@test ~]# parted --help
Usage: parted [OPTION]... [DEVICE [COMMAND [PARAMETERS]...]...]
Apply COMMANDs with PARAMETERS to DEVICE. If no COMMAND(s) are given, run in
interactive mode.
OPTIONs:
-h,
先使用fdisk -l 查看磁盘大小
[root@test ~]# fdisk -l
Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 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: dos
Disk identifier: 0x000ad154
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 104857599 51379200 8e Linux LVM
Disk /dev/sdb: 8796.1 GB, 8796093022208 bytes, 17179869184 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/centos-root: 48.4 GB, 48444211200 bytes, 94617600 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/centos-swap: 4160 MB, 4160749568 bytes, 8126464 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
我们可以看到/dev/sdb是8T数据盘,我们使用parted进行一个分区的大硬盘
使用parted进行分区或管理操作
[root@test ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)
定义分区表格式
[root@test ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt # 定义分区表格式
创建分区
(parted) mkpart part1 # 执行开始创建分区, mkpart执行分区命令, part1为分区名称
File system type? [ext2]? xfs # 文件系统类型,也可以后期通过mkfs.xfs格式化成xfs格式
Start? 1 # 分区开始值 1
End? 8T # 分区结束值 8T
使用print命令进行查看创建是否成功
(parted) print
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 8796GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 8000GB 8000GB part1
执行退出
(parted) quit
Information: You may need to update /etc/fstab.
格式磁盘
[root@test ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=8, agsize=268435455 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=1953124864, 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=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
使用mount 进行挂载测试
[root@test ~]# mkdir -p /test
[root@test ~]# mount -t xfs /dev/sdb1 /test/
验证是否挂载
[root@test ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 8.9M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/centos-root 46G 7.6G 38G 17% /
/dev/sda1 1014M 151M 864M 15% /boot
tmpfs 379M 0 379M 0% /run/user/0
/dev/sdb1 7.3T 33M 7.3T 1% /test
配置开机自动挂载
[root@test ~]# vim /etc/fstab
[root@test ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Nov 29 00:48:53 2021
#
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。