Bug 20265

Summary: fdisk won't use full 1TB disk (or anywhere near it)
Product: Mageia Reporter: Frank Griffin <ftg>
Component: RPM PackagesAssignee: Thomas Backlund <tmb>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Normal CC: basesystem, marja11, pterjan
Version: Cauldron   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Source RPM: util-linux CVE:
Status comment:

Description Frank Griffin 2017-02-11 22:01:08 CET
I took a new 1TB laptop disk and fired up an MGA cauldron repair disk to write an MSDOS MBR and then do the following partition assignments:

50G primary ext4
50G primary ext4
50G primary ext4
extended
24G swap
16G ext4
128G ext4
rest (about 613G) ext4

When it came to the last partition, fdisk would only give it 8GB.  Using anything larger cause a value out of range error.  The total that fdisk would allow was 326GB, which isn't anywhere near the 1TB capacity, and well under the 2TB limit of the MSDOS partition table architecture.

For anyone with a 1 TB disk, this ought to be easy to reproduce.  Just do what I did and be damn careful not to issue a "w" command :-)
Comment 1 Frank Griffin 2017-02-11 22:28:27 CET
Also of interest, diskdrake had no problem taking the resulting disk, deleting the 8GB partition, and defining a partition to use the entire rest of the disk.
Comment 2 Marja Van Waes 2017-02-12 11:46:36 CET
Assigning to maintainer and CC'ing "basesystem group" maintainers

CC: (none) => basesystem, marja11
Assignee: bugsquad => tmb
Source RPM: fdisk => util-linux

Comment 3 David Walser 2017-02-12 16:50:19 CET
fdisk has some known limitations.  For this disk you should probably use something like parted (or diskdrake which is based on the same underlying code).
Comment 4 Frank Griffin 2017-02-12 19:23:28 CET
I made it work by using fdisk to write the MSDOS MBR and then diskdrake to create the partitions.  The problem is that diskdrake won't write an MBR and fdisk (which I think is all we supply on the rescue disk) won't create all of the partitions.  Not intuitive.
Comment 5 Pascal Terjan 2017-02-12 22:08:12 CET
What size did you use for the extended partition? That seems to be the problem


$ dd if=/dev/zero of=1T.img bs=1M seek=$(expr 1024 '*' 1023 + 1023) count=1
1+0 records in
1+0 records out
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.000761003 s, 1.4 GB/s

$ /sbin/fdisk 1T.img

Welcome to fdisk (util-linux 2.28.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x5ff93de7.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (1-4, default 1): 
First sector (2048-2147483647, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-2147483647, default 2147483647): +50G

Created a new partition 1 of type 'Linux' and of size 50 GiB.

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 
First sector (104859648-2147483647, default 104859648): 
Last sector, +sectors or +size{K,M,G,T,P} (104859648-2147483647, default 2147483647): +50G

Created a new partition 2 of type 'Linux' and of size 50 GiB.

Command (m for help): 


Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (3,4, default 3): 
First sector (209717248-2147483647, default 209717248): 
Last sector, +sectors or +size{K,M,G,T,P} (209717248-2147483647, default 2147483647): +50G

Created a new partition 3 of type 'Linux' and of size 50 GiB.

Command (m for help): n
Partition type
   p   primary (3 primary, 0 extended, 1 free)
   e   extended (container for logical partitions)
Select (default e): e

Selected partition 4
First sector (314574848-2147483647, default 314574848): 
Last sector, +sectors or +size{K,M,G,T,P} (314574848-2147483647, default 2147483647): 

Created a new partition 4 of type 'Extended' and of size 874 GiB.

Command (m for help): n
All primary partitions are in use.
Adding logical partition 5
First sector (314576896-2147483647, default 314576896): 
Last sector, +sectors or +size{K,M,G,T,P} (314576896-2147483647, default 2147483647): +24G

Created a new partition 5 of type 'Linux' and of size 24 GiB.

Command (m for help): n
All primary partitions are in use.
Adding logical partition 6
First sector (364910592-2147483647, default 364910592): 
Last sector, +sectors or +size{K,M,G,T,P} (364910592-2147483647, default 2147483647): +16G

Created a new partition 6 of type 'Linux' and of size 16 GiB.

Command (m for help): n
All primary partitions are in use.
Adding logical partition 7
First sector (398467072-2147483647, default 398467072): 
Last sector, +sectors or +size{K,M,G,T,P} (398467072-2147483647, default 2147483647): +128G

Created a new partition 7 of type 'Linux' and of size 128 GiB.

Command (m for help): n
All primary partitions are in use.
Adding logical partition 8
First sector (666904576-2147483647, default 666904576): 
Last sector, +sectors or +size{K,M,G,T,P} (666904576-2147483647, default 2147483647): 

Created a new partition 8 of type 'Linux' and of size 706 GiB.

Command (m for help): p
Disk 1T.img: 1 TiB, 1099511627776 bytes, 2147483648 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
Disklabel type: dos
Disk identifier: 0x5ff93de7

Device     Boot     Start        End    Sectors  Size Id Type
1T.img1              2048  104859647  104857600   50G 83 Linux
1T.img2         104859648  209717247  104857600   50G 83 Linux
1T.img3         209717248  314574847  104857600   50G 83 Linux
1T.img4         314574848 2147483647 1832908800  874G  5 Extended
1T.img5         314576896  364908543   50331648   24G 83 Linux
1T.img6         364910592  398465023   33554432   16G 83 Linux
1T.img7         398467072  666902527  268435456  128G 83 Linux
1T.img8         666904576 2147483647 1480579072  706G 83 Linux

Command (m for help):

CC: (none) => pterjan

Comment 6 Frank Griffin 2017-02-13 01:17:20 CET
Hmm, possibly, but I don't remember giving a size for the extended and I don't see why fdisk would max out at 365G (or so) on a 1TB disk.  The first extended partition was the 24G swap, and I don't see the correlation.  But if you can't reproduce, I'll close as WORKSFORME and wait till the next time.
Comment 7 Frank Griffin 2020-01-10 00:58:10 CET
Closing, since there hasn't been a "next time".

Status: NEW => RESOLVED
Resolution: (none) => FIXED