使用parted 对大容量盘进行分区及挂载
MBR分区表:(MBR含义:主引导记录)
所支持的最大卷:2T (T; terabytes,1TB=1024GB)
对分区的设限:最多4个主分区或3个主分区加一个扩展分区。
GPT分区表:(GPT含义:GUID分区表)
支持最大卷:18EB,(E:exabytes,1EB=1024TB)
每个磁盘最多支持128个分区
1.分区
使用 parted 建立大小超过2T的分区步骤如下:
[root@Node01 /]# parted /dev/sdh
GNU Parted 3.1
Using /dev/sdh
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Error: /dev/sdh: unrecognised disk label
Model: DGC VRAID (scsi)
Disk /dev/sdh: 2684GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
(parted) mklabel gpt #设置分区类型为gpt
Error: Input/output error during read on /dev/sdh
Retry/Ignore/Cancel? Ignore #忽略错误
# 整个分区流程如下:
[root@Node01 /]# parted /dev/sdh
(parted) p #可以输入p或print打印磁盘信息,查看分区的情况,找到起始和结束位置。
(parted) mklabel gpt #设置分区类型为gpt
(parted) mkpart primary 0% 100% #primary指分区类型为主分区,0是分区开始位置,100%是分区结束位置。相同的命令为:mkpart primary 0 XXXXXX结束的空间
(parted) quit #完成后用quit命令退出。
------20211210-----
[root@localhost mnt]# parted /dev/vdb
GNU Parted 3.1
使用 /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
错误: /dev/vdb: unrecognised disk label
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 644GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
(parted)
(parted)
(parted)
(parted)
(parted)
(parted)
(parted) mklabel gpt
(parted) p
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 644GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
(parted) mkpart primary 0% 100%
(parted) p
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 644GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
1 1049kB 644GB 644GB primary
(parted) quit
信息: You may need to update /etc/fstab.
在退出之前可以先print一下,打印当前分区,查看分区设置是否正确。
2.格式化磁盘:
操作完以上,即可对新分区进行格式化操作,
mkfs.xfs /dev/sdb1
格式化完成后即可进行挂载。
通过使用blkid命令可以查看到当前的硬盘分区信息:
[root@Nerc ~]# mkfs.xfs /dev/sdb1
mkfs.xfs: /dev/sdb1 appears to contain a partition table (gpt).
mkfs.xfs: Use the -f option to force overwrite.
[root@Nerc ~]# mkfs.xfs -f /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=2147483387, 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
[root@Nerc ~]#
挂载及查看信息:
mount /dev/sdb1 /mnt/Storage/
df -hl
修改Fstab,实现开机自动挂载:
vim /etc/fstab
UUID="c4d7c3fc-262b-425c-a46a-13d2c5da14e6 /mnt/Data xfs defaults 0 0
评论区