parted分区大于2T大小的磁盘–技术流ken

在使用fdisk建立分区时,我们最大只能建立2TB大小的分区。如需建立超过2T的分区需要采用GPT磁盘模式。下文补充一下GPT和MBR的基础知识和分超过2T分区的方法。
MBR
1、MBR,该磁盘模式是我们常用的模式,英文全称为Master Boot Record,缩写:MBR,中文名称为主引导记录,又称为主引导扇区。
2、采用MBR型分区结构的硬盘(其磁盘卷标类型为MS-DOS),最多只能识别4个主要分区。所以对于一个采用此种分区结构的硬盘来说,想要得到4个以上的主要分区是不可能的。这里就需要引出扩展分区了。扩展分区也是主分区(Primary partition)的一种,但它与主分区的不同在于理论上可以划分为无数个逻辑分区,每一个逻辑分区都有一个和MBR结构类似的扩展引导记录(EBR)。在MBR分区表中最多4个主分区或者3个主分区+1个扩展分区,也就是说扩展分区只能有一个,然后可以再细分为多个逻辑分区。
3、在Linux系统中,硬盘分区命名为sda1-sda4或者hda1-hda4(其中a表示硬盘编号可能是a、b、c等等)。在MBR硬盘中,分区号1-4是主分区(或者扩展分区),逻辑分区号只能从5开始。 在MBR分区表中,一个分区最大的容量为2T,且每个分区的起始柱面必须在这个disk的前2T内。你有一个3T的硬盘,根据要求你至少要把它划分为2个分区,且最后一个分区的起始扇区要位于硬盘的前2T空间内。如果硬盘太大则必须改用GPT。
GPT
1、GPT,英文全称为GUID Partition Table,缩写:GPT,中文名称为全局唯一标识分区表。它是EFI(可扩展固件接口标准)的一部分,用来替代BIOS中的主引导记录分区表。
2、在MBR硬盘中,分区信息直接存储于主引导记录(MBR)中(主引导记录中还存储着系统的引导程序)。但在GPT硬盘中,分区表的位置信息储存在GPT头中。但出于兼容性考虑,硬盘的第一个扇区仍然用作MBR,之后才是GPT头。
GPT分区
第一步:使用parted进行分区
[root@ken ~]# parted /dev/sdb
第二步:查看选择帮助信息
[root@ken ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help
align-check TYPE N check partition N for TYPE(min|opt) alignment
help [COMMAND] print general help, or help on COMMAND
mklabel,mktable LABEL-TYPE create a new disklabel (partition table)
mkpart PART-TYPE [FS-TYPE] START END make a partition
name NUMBER NAME name partition NUMBER as NAME
print [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all found
partitions, or a particular partition
quit exit program
rescue START END rescue a lost partition near START and END
rm NUMBER delete partition NUMBER
select DEVICE choose the device to edit
disk_set FLAG STATE change the FLAG on selected device
disk_toggle [FLAG] toggle the state of FLAG on selected device
set NUMBER FLAG STATE change the FLAG on partition NUMBER
toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER
unit UNIT set the default unit to UNIT
version display the version number and copyright information of GNU Parted
第三步:开始创建分区
(parted) mklabel gpt #将MBR磁盘格式化为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?
Yes/No? yes
(parted) mkpart /dev/sdb1 #创建分区
File system type? [ext2]? xfs #指定文件类型
Start? 0 #指定从0开始
End? 5G #分区结束位置
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore #选择忽略
(parted) print #打印分区信息
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 5000MB 5000MB xfs /dev/sdb1
(parted) mkpart /dev/sdb2 #创建第二个分区
File system type? [ext2]? xfs
Start? 5G
End? 10G
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 5000MB 5000MB xfs /dev/sdb1
2 5001MB 10.0GB 5000MB xfs /dev/sdb2
(parted) mkpart #创建第三个分区
Partition name? []? /dev/sdb10 #指定分区编号是/dev/sdb10,但是会按照顺序排序
File system type? [ext2]? xfs
Start? 10G
End? 11g
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 5000MB 5000MB xfs /dev/sdb1
2 5001MB 10.0GB 5000MB xfs /dev/sdb2
3 10.0GB 11.0GB 999MB /dev/sdb10
(parted) quit
Information: You may need to update /etc/fstab.
第四步:查看识别到的磁盘分区
[root@ken ~]# ls /dev/sdb*
/dev/sdb /dev/sdb1 /dev/sdb2 /dev/sdb3
注意:上面创建的/dev/sdb10被有顺序的识别为/dev/sdb3
第五步:格式化分区并使用
[root@ken ~]# mkfs.xfs /dev/sdb3
[root@ken ~]# mount /dev/sdb3 /ken3
[root@ken ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 17G 6.7G 11G 40% /
devtmpfs 478M 0 478M 0% /dev
tmpfs 489M 0 489M 0% /dev/shm
tmpfs 489M 6.7M 482M 2% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sda1 1014M 139M 876M 14% /boot
tmpfs 98M 0 98M 0% /run/user/0
/dev/sdb3 950M 33M 918M 4% /ken3
Good post. I learn one thing tougher on completely different blogs everyday. It can at all times be stimulating to learn content from different writers and practice somewhat something from their store. I抎 want to use some with the content material on my weblog whether or not you don抰 mind. Natually I抣l offer you a link in your net blog. Thanks for sharing.
I am also writing to make you know what a amazing experience my friend’s girl went through viewing your site. She came to understand a lot of pieces, with the inclusion of what it is like to have a very effective giving nature to let the others just know a variety of impossible subject areas. You really surpassed our own desires. Many thanks for producing such important, healthy, explanatory not to mention cool tips about this topic to Lizeth.
I am commenting to make you understand of the excellent experience my wife’s princess developed going through the blog. She discovered a good number of issues, which include what it’s like to possess a marvelous helping nature to get other individuals with no trouble learn about various complicated topics. You really surpassed our own expectations. I appreciate you for presenting those productive, safe, edifying as well as easy tips about the topic to Evelyn.
I just wanted to jot down a quick note to be able to say thanks to you for some of the remarkable ways you are writing here. My long internet research has at the end of the day been recognized with extremely good tips to talk about with my contacts. I ‘d admit that most of us visitors are extremely fortunate to be in a really good network with many perfect professionals with interesting things. I feel quite fortunate to have seen your web pages and look forward to so many more awesome moments reading here. Thanks again for everything.
I not to mention my friends happened to be examining the best recommendations on the blog and then all of a sudden got a horrible suspicion I never expressed respect to you for those techniques. These young men were for this reason very interested to study them and have definitely been enjoying them. Appreciate your being indeed thoughtful and also for having this kind of fantastic tips most people are really wanting to be aware of. My sincere regret for not expressing appreciation to you sooner.
I enjoy you because of all of your efforts on this blog. Betty loves engaging in investigations and it’s really easy to see why. I notice all relating to the dynamic medium you deliver advantageous ideas via your web blog and as well as encourage response from people about this situation while our girl is actually becoming educated a whole lot. Have fun with the rest of the new year. You have been doing a terrific job.
I want to express some appreciation to you for rescuing me from this issue. Because of exploring throughout the search engines and seeing proposals which are not beneficial, I was thinking my entire life was done. Being alive without the approaches to the problems you have resolved by way of your entire report is a serious case, as well as those that might have adversely affected my entire career if I hadn’t encountered your website. Your own personal skills and kindness in taking care of all the stuff was helpful. I’m not sure what I would’ve done if I hadn’t come upon such a thing like this. I am able to at this moment look ahead to my future. Thanks a lot so much for the specialized and results-oriented help. I will not be reluctant to refer your web page to any individual who should have guidance about this topic.
I really wanted to jot down a quick remark so as to thank you for all the pleasant recommendations you are writing at this website. My time intensive internet lookup has at the end been compensated with really good concept to talk about with my family. I would claim that we website visitors actually are truly endowed to live in a really good place with so many lovely individuals with very helpful things. I feel truly blessed to have used your site and look forward to tons of more excellent times reading here. Thank you once more for everything.
I simply wanted to say thanks all over again. I am not sure the things I would have gone through in the absence of these basics contributed by you about such subject matter. It truly was a very intimidating problem in my opinion, however , seeing a new expert style you solved that forced me to leap over joy. I am just grateful for the assistance and then pray you are aware of a powerful job you’re doing training others through your websites. Most probably you haven’t encountered all of us.