Red Hat Bugzilla – Bug 723352
cfdisk cannot read default installer partitioning
Last modified: 2014-11-09 17:53:57 EST
Description of problem: After installing RHEL6.1 with the default full-disk partitioning, cfdisk reports: FATAL ERROR: Bad primary partition 1: Partition ends in the final partial cylinder fdisk reports the partitioning without complaint. Version-Release number of selected component (if applicable): util-linux-ng-2.17.2-12.el6.x86_64 How reproducible: Always Steps to Reproduce: 1. 2. 3. Actual results: [root@redhat ~]# cfdisk -P s /dev/sda FATAL ERROR: Bad primary partition 1: Partition ends in the final partial cylinder Expected results: cfdisk displays the partitions. Additional info: <<From one of our engineers>> The numbers you are seeing overlap (7616) is normal, albeit misleading. That is a cylinder number, and is the default display when using dos-compatible fdisk modes, and viewing the units in terms of cylinders. Here is another example from my computer: Disk /dev/sda: 64.0 GB, 64023257088 bytes 255 heads, 63 sectors/track, 7783 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000a077f Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 64 7784 62009344 83 Linux *Note that I'm using newer fdisk, so it now is capable of recognizing when a partition isn't optimized geometrically. This is one reason fdisk's default output now shows sectors, rather than cylinders. To see the actual boundaries, you need to switch fdisk into the newer "sectors" display: fdisk -l -c nondos -u sectors /dev/sda Disk /dev/sda: 64.0 GB, 64023257088 bytes 255 heads, 63 sectors/track, 7783 cylinders, total 125045424 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 identifier: 0x000a077f Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 125044735 62009344 83 Linux See how there is no overlap? cfdisk has a bug because it still expects to deal with cylinders.
This bug is already fixed in Fedora (bug #630340) and upstream.
I guess I'd need some help verifying this ... how to create disk schema which triggers the bug? - I mean, is there any easier method than going through the actual install? I've tried to create two partitions across the whole disk (just 16 MiB for testing purposes) by both fdisk and parted, and cfdisk haven't complained about that ...
# modprobe scsi_debug dev_size_mb=512 sector_size=512 (or try to use loop device, not sure) # fdisk -c -u /dev/sdb (create one partition on whole disk (default sectors: first=2048, last=1048575) Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0xb06e6c19. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First sector (2048-1048575, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-1048575, default 1048575): Using default value 1048575 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. # cfdisk /dev/sdb <--- ERROR without the patch
fdisk doesn't seem to like loop devices ... it seems that sector_size doesn't need to be specified dev_size_mb=512 is what matters - it doesn't work (reproduce the bug) with 513 ... and more important, it doesn't work with anything smaller than 512, which would make it a bit troublesome to test but there seems to be a workaround - size 1024 triggers the bug too ... so creating the device of the same size with virtual_gb=1 does the job without consuming so much memory
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHSA-2011-1691.html