分区表MBR与GPT的说明:

MBR:主引导记录,是传统的分区机制,应用于绝大多数使用BIOS的PC设备,MBR+BIOS,MBR支持32位和64位系统,支持的分区数量有限,MBR只支持不超过2T的硬盘,超过2T的硬盘将只能用2T空间

GPT:全局唯一标识分区表,是一个较新的分区机制,解决了MBR很多缺点,支持超过2T的磁盘(64位寻址空间),fdisk最大只能建立2TB大小的分区,创建一个大于2TB的分区使用parted。向后兼容MBR,必须在支持UEFI的硬件上才能使用(Intel提出,用于取代BIOS),GPT+UEFI,必须使用64位系统,Mac、Linux系统都能支持GPT分区格式。Windows 7/8 64bit、Windows Server 2008 64bit支持GPT,当 GPT 分区的盘在老的只支持 mbr 的工具下查看时,也会读到分区信息,只不过看到的是只有一个分区,这是为了防止用户误认为盘是空盘。

以上就是Linux系统MBR和GPT分区的区别,总得来说GPT比MBR更先进,但MBR的兼容性比GPT要更好。

 

1.在Azure虚拟机中附加两块4TB的数据磁盘

 

 

2.系统版本信息:

[root@hlmcent74n ~]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core)

 

3.使用命令"parted -l"或"fdisk -l"查看新附加磁盘的信息

 

 4.使用命令"parted"对两块磁盘创建GPT类型的分区表,并进行分区

备注:由于parted内嵌的mkfs还不够完善,所以完成后,我们需要使用quit命令退出parted,并使用系统的mkfs命令对分区进行格式化,此时如果使用fdisk -l命令打印分区表会出现警告信息,这是正常的 

[root@hlmcent74n ~]# parted /dev/sdc
GNU Parted 3.1
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel                                                          
New disk label type? gpt                                                  
(parted) mkpart                                                           
Partition name?  []? sdc1
File system type?  [ext2]? ext4                                           
Start? 0GB                                                                
End? 4397GB                                                               
(parted) p                                                                
Model: Msft Virtual Disk (scsi)
Disk /dev/sdc: 4397GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  4397GB  4397GB               sdc1

(parted) q                                                                
Information: You may need to update /etc/fstab.

[root@hlmcent74n ~]# parted /dev/sdd
GNU Parted 3.1
Using /dev/sdd
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel                                                          
New disk label type? gpt
(parted) mkpart 
Partition name?  []? sdd1
File system type?  [ext2]? ext4                                           
Start? 0GB                                                                
End? 4397GB                                                               
(parted) p                                                                
Model: Msft Virtual Disk (scsi)
Disk /dev/sdd: 4397GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  4397GB  4397GB               sdd1

(parted) q                                                                
Information: You may need to update /etc/fstab.

 

5. 再次使用命令"parted -l"查看磁盘分区信息,可以看到磁盘"/dev/sdc""/dev/sdd"已经成功分区

[root@hlmcent74n ~]# parted -l                                            
Model: Msft Virtual Disk (scsi)
Disk /dev/sda: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  525MB   524MB   primary  xfs          boot
 2      525MB   32.2GB  31.7GB  primary  xfs

Model: Msft Virtual Disk (scsi)
Disk /dev/sdb: 75.2GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  75.2GB  75.2GB  primary  ext4

Model: Msft Virtual Disk (scsi)
Disk /dev/sdc: 4397GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  4397GB  4397GB               sdc1

Model: Msft Virtual Disk (scsi)
Disk /dev/sdd: 4397GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  4397GB  4397GB               sdd1

 

6.使用命令"blkid"查看分区设备信息

[root@hlmcent74n ~]# blkid
/dev/sdb1: UUID="03a52d9e-d3e3-49ab-abd1-894d1b74ce00" TYPE="ext4" 
/dev/sda1: UUID="e6a6edce-cf86-4b3c-a1f7-06dc28e9ba8c" TYPE="xfs" 
/dev/sda2: UUID="27a53870-f773-44d3-83b0-a18dfc3dd672" TYPE="xfs" 
/dev/sdc1: PARTLABEL="sdc1" PARTUUID="c18865a0-122e-46c6-8ea4-4bc750db3419" 
/dev/sdd1: PARTLABEL="sdd1" PARTUUID="2d402179-0590-4b61-b32d-a341f781958b" 

 

7.使用命令"mdadm"创建Raid0

[root@hlmcent74n ~]# mdadm -C /dev/md127 -l 0 -n 2 /dev/sdc1 /dev/sdd1
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md127 started.

 

8.使用命令"parted -l"或"fdisk -l"查看md127的大小

 

 9.为/dev/md127创建ext4的文件系统

备注:为加快磁盘的格式化,加入参数"-T largefile"

[root@hlmcent74n ~]# mkfs.ext4 -T largefile /dev/md127
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=128 blocks, Stripe width=256 blocks
8386304 inodes, 2146892800 blocks
107344640 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
65518 block groups
32768 blocks per group, 32768 fragments per group
128 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
    102400000, 214990848, 512000000, 550731776, 644972544, 1934917632

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done       

 

10.创建挂载点,并挂载Raid0使用

[root@hlmcent74n ~]# mkdir /mnt/md127
[root@hlmcent74n ~]# mount /dev/md127 /mnt/md127/

 

11.查看挂载情况及Raid设备的大小

[root@hlmcent74n ~]# mount | tail
/dev/sda2 on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=24,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=12701)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel)
mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
/dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/sdb1 on /mnt/resource type ext4 (rw,relatime,seclabel,data=ordered)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=170680k,mode=700,uid=1000,gid=1000)
/dev/md127 on /mnt/md127 type ext4 (rw,relatime,seclabel,stripe=256,data=ordered)

[root@hlmcent74n
~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 30G 1.5G 29G 5% / devtmpfs 823M 0 823M 0% /dev tmpfs 834M 0 834M 0% /dev/shm tmpfs 834M 8.4M 826M 1% /run tmpfs 834M 0 834M 0% /sys/fs/cgroup /dev/sda1 497M 79M 419M 16% /boot /dev/sdb1 69G 53M 66G 1% /mnt/resource tmpfs 167M 0 167M 0% /run/user/1000 /dev/md127 8.0T 93M 7.6T 1% /mnt/md127

 

参考链接:

http://blog.csdn.net/z_yttt/article/details/53020797

http://blog.sina.com.cn/s/blog_6d55a74b0102xcip.html

 

posted on 2018-03-14 12:05  铭的随记  阅读(955)  评论(0编辑  收藏  举报