What is the maximum No. of hard disk partitions after kernel 2.6.28


Results 1 to 5 of 5

Thread: What is the maximum No. of hard disk partitions after kernel 2.6.28

Threaded View

  1. #1
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,978

    What is the maximum No. of hard disk partitions after kernel 2.6.28

    Introduction

    A few years ago the Linux kernel used to support a Pata or IDE disk with 63 partitions and a SCSI/Sata/USB disk with 15 partitions. Later this was standardised that every hard disk was to have 15 partitions maximum.

    Well just like an old woman Linux could not make up its mind and now with the new 2.6.28 kernel the maximum number of partition in a hard disk has been changed again. It is so bad that no one seems to know what is the current limit.

    The old limit was set by two parameters known as the major and minor numbers where together provide 256 block devices for each type of controller. The IDE channels have 4 devices of hda, hdb, hdc and hdd so each hard disk plus it disk name make up 64 devices names (hda, hda1 to hda63). A maximum 4 hard disks give a total of 256 devices names.

    Sata/SCSI/USB hard disks achieve this by a maximum of 16 disks. Again the 256 is a product of 16 disk x16 device names.

    The current break through apparent is due to the major and minor numbers no longer static but can be dynamically changed according to the user usage.

    The pain with partitioning

    The pain is due to the change being so new that Linux basic partitioning tools like fdisk, cfdisk and sfdisk do not know what to do and so they respond in different ways. The new change can play havoc with some installers that have not yet been modified to match the new change.

    Here are a few reactions I have encountered

    (i) sfdisk can apparently handle a maximum 130 partitions in a hard disk but the created partition table is rejected by cfdisk.

    (ii) fdisk has never been able to show more than 60 partitions. The Red Hat version family distros used to display only 15 but now all of them will display 60 maximum.

    (iii) cfdisk used to be able to partition up to 63 partitions but the last 3 may not be reliable. It is still the same.

    The safest number of partitions that can be accepted by all three partitioning tools are around 56 partitions. This is from trial and error with the current kernel. I expect the situation will improve with time.

    Fun with partitioning

    I think it is fun to generate a large number of partitions in a hard disk by a script. First I tried with Python with this script
    Code:
    f=file('try','w')
    f.write('sfdisk /dev/sdb << EOF\n')
    f.write(',1000,L\n')
    f.write(',1000,L\n')
    f.write(',1000,L\n')
    f.write(',,E\n')
    i=0
    y=',1000,L\n'
    cylin=182041
    while cylin > 1000:
    	cylin=cylin-1000
    	f.write(y)
    	i=i+1
    f.write(',,L\n')
    f.write('EOF\n')
    print 'No. of partitions = ',i
    f.close()
    Basicall I bought a 1.5Tb hard disk hooked up as sdb. It has 182041 cylinders so I just make up commands in sfdisk to create 182 partition each 1000 cylinder large (about 8Gb). The above script generate an output file called "try" which I ran as a Bash script.

    Sfdisk only accepted the instructions for the first 130 partitions and ignore the rest of the commands.

    As reported earlier cfdisk and fdisk didn't like this partition table with 130 partitions but I managed get Ubuntu to format the 130th partition and put files in it. Thus I know it works.

    To play safe I decided to use fdisk and wrote a script for it. Funny enough the partition table generation works only for cfdisk if the number of partition terminates at 56 and not beyond. Here I wrote in Python script to generate an output file called "gen56" list as follow
    Code:
    d
    1
    d
    2
    d
    3
    d
    4
    n
    p
    1
    1
    10000
    n
    p
    2
    10001
    20000
    n
    p
    3
    20001
    30000
    n
    e
    4
    
    
    n
    30001
    32000
    n
    32001
    34000
    n
    34001
    36000
    n
    36001
    38000
    n
    38001
    40000
    n
    40001
    42000
    n
    42001
    44000
    n
    44001
    46000
    n
    46001
    48000
    n
    48001
    50000
    n
    50001
    52000
    n
    52001
    54000
    n
    54001
    56000
    n
    56001
    58000
    n
    58001
    60000
    n
    60001
    62000
    n
    62001
    64000
    n
    64001
    66000
    n
    66001
    68000
    n
    68001
    70000
    n
    70001
    72000
    n
    72001
    74000
    n
    74001
    76000
    n
    76001
    78000
    n
    78001
    80000
    n
    80001
    82000
    n
    82001
    84000
    n
    84001
    86000
    n
    86001
    88000
    n
    88001
    90000
    n
    90001
    92000
    n
    92001
    94000
    n
    94001
    96000
    n
    96001
    98000
    n
    98001
    100000
    n
    100001
    102000
    n
    102001
    104000
    n
    104001
    106000
    n
    106001
    108000
    n
    108001
    110000
    n
    110001
    112000
    n
    112001
    114000
    n
    114001
    116000
    n
    116001
    118000
    n
    118001
    120000
    n
    120001
    122000
    n
    122001
    124000
    n
    124001
    126000
    n
    126001
    128000
    n
    128001
    130000
    n
    130001
    132000
    n
    132001
    134000
    w
    q
    To run it I just issue the command
    Code:
    fdisk /dev/sdb < gen56
    The code actually deletes all the previous 4 primaries and regenerate 3 primaries and one extended partition to put in 2000 cylinders each. I have increased the 3 primaries (first 3 partitions) to 10,000 cylinders. If a user deletes an extended partition all the logical partition inside will be gone so nuking the 4 primaries will clear a hard disk completely.

    The partition table now looks like this
    Code:
    root@DL:/media/16GB_1STFAT/Sam-office/office cabinet/Linux/64partitions# fdisk -l /dev/sdb
    
    Disk /dev/sdb: 1500.3 GB, 1500301910016 bytes
    255 heads, 63 sectors/track, 182401 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x58e84b8a
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1       10000    80324968+  83  Linux
    /dev/sdb2           10001       20000    80325000   83  Linux
    /dev/sdb3           20001       30000    80325000   83  Linux
    /dev/sdb4           30001      182401  1224161032+   5  Extended
    /dev/sdb5           30001       32000    16064968+  83  Linux
    /dev/sdb6           32001       34000    16064968+  83  Linux
    /dev/sdb7           34001       36000    16064968+  83  Linux
    /dev/sdb8           36001       38000    16064968+  83  Linux
    /dev/sdb9           38001       40000    16064968+  83  Linux
    /dev/sdb10          40001       42000    16064968+  83  Linux
    /dev/sdb11          42001       44000    16064968+  83  Linux
    /dev/sdb12          44001       46000    16064968+  83  Linux
    /dev/sdb13          46001       48000    16064968+  83  Linux
    /dev/sdb14          48001       50000    16064968+  83  Linux
    /dev/sdb15          50001       52000    16064968+  83  Linux
    /dev/sdb16          52001       54000    16064968+  83  Linux
    /dev/sdb17          54001       56000    16064968+  83  Linux
    /dev/sdb18          56001       58000    16064968+  83  Linux
    /dev/sdb19          58001       60000    16064968+  83  Linux
    /dev/sdb20          60001       62000    16064968+  83  Linux
    /dev/sdb21          62001       64000    16064968+  83  Linux
    /dev/sdb22          64001       66000    16064968+  83  Linux
    /dev/sdb23          66001       68000    16064968+  83  Linux
    /dev/sdb24          68001       70000    16064968+  83  Linux
    /dev/sdb25          70001       72000    16064968+  83  Linux
    /dev/sdb26          72001       74000    16064968+  83  Linux
    /dev/sdb27          74001       76000    16064968+  83  Linux
    /dev/sdb28          76001       78000    16064968+  83  Linux
    /dev/sdb29          78001       80000    16064968+  83  Linux
    /dev/sdb30          80001       82000    16064968+  83  Linux
    /dev/sdb31          82001       84000    16064968+  83  Linux
    /dev/sdb32          84001       86000    16064968+  83  Linux
    /dev/sdb33          86001       88000    16064968+  83  Linux
    /dev/sdb34          88001       90000    16064968+  83  Linux
    /dev/sdb35          90001       92000    16064968+  83  Linux
    /dev/sdb36          92001       94000    16064968+  83  Linux
    /dev/sdb37          94001       96000    16064968+  83  Linux
    /dev/sdb38          96001       98000    16064968+  83  Linux
    /dev/sdb39          98001      100000    16064968+  83  Linux
    /dev/sdb40         100001      102000    16064968+  83  Linux
    /dev/sdb41         102001      104000    16064968+  83  Linux
    /dev/sdb42         104001      106000    16064968+  83  Linux
    /dev/sdb43         106001      108000    16064968+  83  Linux
    /dev/sdb44         108001      110000    16064968+  83  Linux
    /dev/sdb45         110001      112000    16064968+  83  Linux
    /dev/sdb46         112001      114000    16064968+  83  Linux
    /dev/sdb47         114001      116000    16064968+  83  Linux
    /dev/sdb48         116001      118000    16064968+  83  Linux
    /dev/sdb49         118001      120000    16064968+  83  Linux
    /dev/sdb50         120001      122000    16064968+  83  Linux
    /dev/sdb51         122001      124000    16064968+  83  Linux
    /dev/sdb52         124001      126000    16064968+  83  Linux
    /dev/sdb53         126001      128000    16064968+  83  Linux
    /dev/sdb54         128001      130000    16064968+  83  Linux
    /dev/sdb55         130001      132000    16064968+  83  Linux
    /dev/sdb56         132001      134000    16064968+  83  Linux
    /dev/sdb57         134001      182401   388781001   83  Linux
    The last partition I created in cfdisk manually to store my personal data.

    To demonstrate the change of major and minor numbers I post the following terminal commands/output
    Code:
    root@DL:/media/16GB_1STFAT/Sam-office/office cabinet/Linux/64partitions# ls -l /dev/sdb
    brw-rw---- 1 root disk 8, 16 2009-03-08 22:15 /dev/sdb
    root@DL:/media/16GB_1STFAT/Sam-office/office cabinet/Linux/64partitions# ls -l /dev/sdb1
    brw-rw---- 1 root disk 8, 17 2009-03-08 22:15 /dev/sdb1
    root@DL:/media/16GB_1STFAT/Sam-office/office cabinet/Linux/64partitions# ls -l /dev/sdb15
    brw-rw---- 1 root disk 8, 31 2009-03-08 22:15 /dev/sdb15
    root@DL:/media/16GB_1STFAT/Sam-office/office cabinet/Linux/64partitions# ls -l /dev/sdb16
    brw-rw---- 1 root disk 259, 0 2009-03-08 22:15 /dev/sdb16
    root@DL:/media/16GB_1STFAT/Sam-office/office cabinet/Linux/64partitions# ls -l /dev/sdb57
    brw-rw---- 1 root disk 259, 41 2009-03-08 22:15 /dev/sdb57
    The red and purple figures are the major and minor numbers. In kernels older than 2.6.28 the major number does not change for a hard disk. Now a switch is done after the 15th partition.

    How to use the 15+ partitions

    The Linux with 2.6.28 kerenl seems to be able to cope with it.

    I first tried an old distro Fedora 10 with a 2.6.27 kernel. The installer claimed it cannot seek partitions beyond sdb15. A forced installation beyond this point resulted in an error so I eventually installed it in sdb15.

    DreamLinux 3.5 has a 2.6.28.5 kernel. Its installer was quite happy to let me specifying sdb56 for its installation. That works perfectly. I am using it to post this thread.

    I also downloaded Zenwalk 6.0 but its installer refused to allow me to use sdb for installation. However when it offered sda partitions for installation I found sdb partitions also listed so I selected sdb55 for its installation. Zenwalk is based on Slackware which is a die-hard believer in Lilo that failed to get installed (as usual). I actually left with Zenwalk installed but without a boot loader. However Slackware is the easiest distro to boot. I fired it up with these commands in a Grub prompt
    Code:
    root (hd1,54)
    kernel /boot/vmlinuz ro root=/dev/sdb55
    boot
    So if Linux can be installed in sdb55 and sdb56 then we are back to the good old days with at least 63 partition possible in each hard disk.

    Conclusions

    Don't think I have found the maximum number of partitions supported by kernel 2.6.28 and later but 60 should be a safe number to work with as it is recognised by all the partitioning tools. I stopped at sdb56 because I used a script to create the partitions. Manually I have done it to 63 partition before.

    This is uncharted territory so proceed with caution. The developer of turning the major/minor numbers from static to dynamic also is apparently unsure what could happen.

    Have fun in breaking free from the 15-partition barrier!
    Last edited by saikee; 03-08-2009 at 09:10 PM.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •