centos7-分区2T以上大硬盘
centos7-分区2T以上大硬盘
1. centos7-分区2T以上大硬盘
-
由于使用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, --help 显示此帮助消息 -l, --list 列出所有块设备上的分区布局 -m, --machine 显示机器可解析的输出 -s, --script 不给用户输出提示信息 -v, --version 显示版本 -a, --align=[none|cyl|min|opt] 新分区的对齐
-
先使用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 # # 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 # /dev/mapper/centos-root / xfs defaults 0 0 UUID=c1543849-6ce7-46be-b796-8587fed64908 /boot xfs defaults 0 0 #/dev/mapper/centos-swap swap swap defaults 0 0 # 配置自动挂载硬盘 /dev/sdb1 /test xfs defaults 0 0