linux大于2T的磁盘使用GPT分区方式

时间:2022-03-17 15:41:56
MBR(Master Boot Record)(主引导记录)和GPT(GUID Partition Table)(GUID意为全局唯一标识符)是在磁盘上存储分区信息的两种不同方式

对于传统的MBR分区方式,有很多的限制:

1:最多4个主分区,无法创建大于2TB的分区,而GPT分区方式不受这样的限制:
2:GPT分区方式将不会有这种限制,使用的工具是parted;
操作步骤:
1:修改分区表类型
[root@localhost ~]# parted /dev/sdb mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you
want to continue?
parted: invalid token: gpt
Yes/No? yes
New disk label type? [msdos]? gpt
Information: Don't forget to update /etc/fstab, if necessary. (不是错误)
2:查看修改结果
[root@localhost ~]# parted /dev/sdb print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
3:创建与删除分区
(1)命令格式:
parted {磁盘} mkpart 分区类型 文件系统格式 开始 结束
分区类型:primary logical extended
文件系统:ext2 ext3 swap
注:ext4文件系统不支持(操作环境:CentOS5.5)
[root@localhost ~]# parted /dev/sdb mkpart primary ext3 1 2G
(2)查看分区表信息:
[root@localhost ~]# parted /dev/sdb print Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt Number Start End Size File system Name Flags
1 17.4kB 2000MB 2000MB primary
(3)删除分区
[root@localhost ~]# parted /dev/sdb rm 1
4:格式化挂在文件系统
如果出现:-bash: mkfs.ext4: command not found
安装:yum -y install e4fsprogs
[root@localhost ~]# mkfs.ext4 /dev/sdb1
mke4fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
122160 inodes, 488277 blocks
24413 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=503316480
15 block groups
32768 blocks per group, 32768 fragments per group
8144 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune4fs -c or -i to override.
5:挂载
[root@localhost ~]# mkdir /data1
[root@localhost ~]# mount /dev/sdb1 /data1
[root@localhost ~]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
none on /proc/fs/vmblock/mountPoint type vmblock (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/sdb1 on /data1 type ext4 (rw)
6:修改系统文件,开机自动挂载
[root@localhost ~]# vi /etc/fstab
/dev/sdb1 /data1    ext4    defaults        0 0
注:第5列:表示:是否使用度,dump备份,“0”:表示不备份,“1”:表示备份
第6列:表示:是否需要磁盘检查,根文件系统指定为1,其他文件系统为2,不需要磁盘检查为0;
以上分区过程可以简化为以下几步:

    * parted /dev/sda mkpart primary ext4  2G
* parted /dev/sda print
* reboot(重启)
* mkfs.ext4 /dev/sda1
* 创建挂在点:mkdir /opt/data1
* 写入/etc/fstab中:/dev/sda1 /opt/data1 ext4 defaults
* 挂载:mount -a