Linux系统中一个磁盘最多能创建多少个分区?
一、MBR磁盘类型
如果我们在Linux中使用MBR磁盘类型,使用MBR分区表的硬盘最多只能划分4个主分区磁盘,并且MBR最大仅支持2TB的硬盘,但拥有很好的兼容性,如
分区完全取决于磁盘类型格式。 一、MBR磁盘类型 如果我们在Linux中使用MBR磁盘类型,使用MBR分区表的硬盘最多只能划分4个主分区磁盘,并且MBR最大仅支持2TB的硬盘,但拥有很好的兼容性,如果需要分区的硬盘容量超过2TB了,则需要使用GPT分区表类型,此分区表类型不受分区个数,硬盘大小的限制,最大支持18EB,且是一种新的硬盘分区标准。如下所示: 1)所有四个分区仅为主分区。 2)三个分区是主分区,其余一个分区是扩展的。 如果我们考虑以上两个步骤,那么在扩展分区下,我们可以创建将近65536个新的逻辑分区并使用它们,但是这个逻辑分区有一定的局限性,它取决于OS到OS。 我们可以在扩展分区下创建多少个分区? 答:假设您将MBR中的最后一个分区创建为扩展分区,并在其下创建一个1GB的分区作为逻辑分区。 Command (m for help): p Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 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: 0x85e466f5 Device BootStartEndBlocks Id System /dev/sdb12048 20973567 10485760 83 Linux /dev/sdb220973568 41945087 10485760 83 Linux /dev/sdb341945088 62916607 10485760 83 Linux /dev/sdb462916608 650137591048576 5 Extended /dev/sdb562918656 650137591047552 83 Linux 在创建上面的1GB逻辑分区之后,我们可以计算扩展分区下的逻辑分区的总数。 我们知道MBR支持1扇区空间=512字节 /dev/sdb5和/dev/sdb1启动扇区值之间的差异如下:62918656-62916608=2048 2048是扩展分区中存储逻辑分区信息的一个保留空间的差分值。 如果我们用512个字节乘2048,那么扩展分区中存在的总字节支持逻辑分区,即2048*512=1048576字节。 在MBR中,使用64个字节的总大小来将分区信息存储在分区表中。它意味着分区表存储每个分区信息,其中每个分区大小为16个字节。每个分区可以使用16个字节的空间,因此在MBR中总共提供了4个分区,包括扩展。如果我们看到最后一个分区大小,它是扩展分区,那么它们使用16字节的空间。 这意味着unix磁盘限额,如果将1048576字节除以16,则得到扩展分区下的逻辑分区总数,即1048576/16=65536(最大逻辑分区)。 我们可以在它下面使用最多65536个逻辑分区。但是这个分区的使用取决于OS到OS。所以在Linux中,MBR在扩展分区下使用最多60个逻辑分区。 因此,我们可以在MBR下创建的分区总数为3(主)、1(扩展),60(逻辑分区标识号)=60-5+1=56个逻辑分区。 下方是我做的测试: Command (m for help): n All primary partitions are in use Adding logical partition 60 First sector (23013477-41943039, default 23031808): Using default value 23031808 Last sector, +sectors or +size{K,M,G} (23031808-24035327, default 24035327): +100 Partition 60 of type Linux and of size 50.5 KiB is set Command (m for help): n The maximum number of partitions has been created 下面是我写了个简单的shell创建的最终分区数: [root@localhost Desktop]# fdisk -l /dev/sdb Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 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: 0x85e466f5 Device BootStartEndBlocks Id System /dev/sdb12048 209715199 104856576 5 Extended /dev/sdb5409621012471048576 83 Linux /dev/sdb6210329642004471048576 83 Linux /dev/sdb7420249662996471048576 83 Linux /dev/sdb8630169683988471048576 83 Linux /dev/sdb98400896 104980471048576 83 Linux /dev/sdb1010500096 125972471048576 83 Linux /dev/sdb1112599296 146964471048576 83 Linux /dev/sdb1214698496 167956471048576 83 Linux /dev/sdb1316797696 188948471048576 83 Linux /dev/sdb1418896896 209940471048576 83 Linux /dev/sdb1520996096 230932471048576 83 Linux /dev/sdb1623095296 251924471048576 83 Linux /dev/sdb1725194496 272916471048576 83 Linux /dev/sdb1827293696 293908471048576 83 Linux /dev/sdb1929392896 314900471048576 83 Linux /dev/sdb2031492096 335892471048576 83 Linux /dev/sdb2133591296 356884471048576 83 Linux /dev/sdb2235690496 377876471048576 83 Linux /dev/sdb2337789696 398868471048576 83 Linux /dev/sdb2439888896 419860471048576 83 Linux /dev/sdb2541988096 440852471048576 83 Linux /dev/sdb2644087296 461844471048576 83 Linux /dev/sdb2746186496 482836471048576 83 Linux /dev/sdb2848285696 503828471048576 83 Linux /dev/sdb2950384896 524820471048576 83 Linux /dev/sdb3052484096 545812471048576 83 Linux /dev/sdb3154583296 566804471048576 83 Linux /dev/sdb3256682496 587796471048576 83 Linux /dev/sdb3358781696 608788471048576 83 Linux /dev/sdb3460880896 629780471048576 83 Linux /dev/sdb3562980096 650772471048576 83 Linux /dev/sdb3665079296 671764471048576 83 Linux /dev/sdb3767178496 692756471048576 83 Linux /dev/sdb3869277696 713748471048576 83 Linux /dev/sdb3971376896 734740471048576 83 Linux /dev/sdb4073476096 755732471048576 83 Linux /dev/sdb4175575296 776724471048576 83 Linux /dev/sdb4277674496 797716471048576 83 Linux /dev/sdb4379773696 818708471048576 83 Linux /dev/sdb4481872896 839700471048576 83 Linux /dev/sdb4583972096 860692471048576 83 Linux /dev/sdb4686071296 881684471048576 83 Linux /dev/sdb4788170496 902676471048576 83 Linux /dev/sdb4890269696 923668471048576 83 Linux /dev/sdb4992368896 944660471048576 83 Linux /dev/sdb5094468096 965652471048576 83 Linux /dev/sdb5196567296 986644471048576 83 Linux /dev/sdb5298666496 1007636471048576 83 Linux /dev/sdb53100765696 1028628471048576 83 Linux /dev/sdb54102864896 1049620471048576 83 Linux /dev/sdb55104964096 1070612471048576 83 Linux /dev/sdb56107063296 1091604471048576 83 Linux /dev/sdb57109162496 1112596471048576 83 Linux /dev/sdb58111261696 1133588471048576 83 Linux /dev/sdb59113360896 1154580471048576 83 Linux /dev/sdb60115460096 1175572471048576 83 Linux 从测试结果来看,我们只能创建到逻辑分区到分区号为60就再没法创建新逻辑分区了,所以真正能使用的分区仅有3(主分区)+56(逻辑分区)=59个分区 二、GPT分区类型 如果我们在Linux中使用GPT分区类型,则在Linux系统中最多可以创建128个分区,如下所示: 创建第129个分区报错: [root@localhost Desktop]# fdisk /dev/sdb WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): d Partition number (1-128, default 128): Partition 128 is deleted Command (m for help): n Selected partition 128 First sector (262144-209715166, default 262144): Last sector, +sectors or +size{K,M,G,T,P} (262144-209715166, default 209715166): +1M Created partition 128 Command (m for help): n No free partition available! 虽然使用GPT分区表类型,此分区表类型不受分区个数,硬盘大小的限制,最大支持18EB,且是一种新的硬盘分区标准。但是由于OS限制,不管还有没有剩下磁盘空间。第129个分区无法创建,所以GPT分区类型在Linux下最多可以创建128个,可以使用的磁盘个数也为128个。 (编辑:成都站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |