Linux格式化大于2TB方法

作者: admin 分类: Linux 发布时间: 2019-10-18 10:31 浏览:1,458 次    

fdisk默认只能格式小于2T的磁盘,工作中经常会碰到大于2T的磁盘,需要用parted 来的格式化

1、安装parted

yum install -y parted

2、查看磁盘名称

[root@VM_0_16_centos ~]# fdisk -l

Disk /dev/vda: 536.9 GB, 536870912000 bytes, 1048576000 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: 0x000c5e30

Device Boot Start End Blocks Id System
/dev/vda1 * 2048 1048575966 524286959+ 83 Linux

Disk /dev/vdb: 2201.2 GB, 2201170739200 bytes, 4299161600 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

3、使用parted 格式化

[root@VM_0_16_centos ~]# parted /dev/vdb
GNU Parted 3.1
Using /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel                        # 创建标签
New disk label type? gpt                # 格式化为GPT 
(parted) mkpart                         # 创建分区
Partition name? []? vdb1                # 分区名称
File system type? [ext2]? ext4          # 文体系统类型
Start? 0                                # 开始位置
End? 2201GB                             # 分区大小
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore                   # 忽视
(parted) p                              # 查看分区
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 2201GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 17.4kB 2201GB 2201GB ext4 vdb1

(parted) quit                             #退出

4、挂载磁盘

[root@VM_0_16_centos ~]# echo "/dev/vdb1 /data ext4 defaults 0 0" >>/etc/fstab
[root@VM_0_16_centos ~]# mount -a
[root@VM_0_16_centos ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 493G 1.4G 471G 1% /
devtmpfs 63G 0 63G 0% /dev
tmpfs 63G 24K 63G 1% /dev/shm
tmpfs 63G 380K 63G 1% /run
tmpfs 63G 0 63G 0% /sys/fs/cgroup
tmpfs 13G 0 13G 0% /run/user/0
/dev/vdb1 2.0T 81M 1.9T 1% /data
  • 自动脚本(大于2T)
#!/bin/bash

parted -s /dev/vdb mklabel gpt
parted -s /dev/vdb mkpart primary 0% 100%
mkfs.xfs  /dev/vdb1
mkdir /data
echo "`blkid |grep vdb1|awk '{print $2}'` /data xfs defaults 0 0" >> /etc/fstab 
mount -a

注:以上例子为vdb磁盘,请根据实际情况修改后使用


温馨提示:如无特殊说明,本站文章均为作者原创,转载时请注明出处及相应链接!

发表评论