You are not logged in.

#1 2012-10-10 21:55:44

cro
Member
From: Germany
Registered: 2006-01-02
Posts: 101

problems with fdisk on 2TB HDD

Hello,
sorry, I didn't know where else to post this.

I have a 2TB HDD (WD20EARX). A few months ago I made a primary partition with the whole size of the disk. Filesystem NTFS for data to access it both from Linux and Windows. (Big mistake but that's a different story ...)
Now I'm in the need of a rather small partition for my linux home directories, about 10 GiB. I thought I could put it at the end of the 2TB data HDD, but that doesn't seem to work.

First it seemed to me that fdisk shows incorrect size in its output:

# fdisk -l /dev/sdb

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x616b52fe

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048  3907029167  1953513560    7  HPFS/NTFS/exFAT

3907029168 - 2048 is obviously greater than 1953513560 ! It's about two times that, isn't it.

And that fdisk calculates wrong size when I try to create partitions:

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 
Using default value 1
First sector (2048-3907029167, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-3907029167, default 3907029167): 3886057647
Partition 1 of type Linux and of size 1024 GiB is set

Again: (3886057648 - 2048) * 512 is more than 1024 GiB !
But it turned out that fdisk really isn't able to create partitions of that kind (~ 1990GB + 10GB).

What is going wrong here? Could it be a bug of fdisk?

# fdisk -v
fdisk from util-linux 2.22

Is it a limitation of the old legacy bios partition table format? I researched a little bit but found nothing. According to wikipedia.de the LBA start sector and LBA size in each partition entry is each a 4 byte value. That should allow for partitions of size of 3886055600 sectors and the like.

Should I switch to GPT format partition table? Does this work while the filesystem stays on the disk while I reformat the partition table to GPT? Does it work with Windows 7? Does it work with Linux without any problems? wink What else can make problems with GPT?

The easier way seems to be to put the home partition on the SSD. But that's not where it belongs. It doesn't need the speed and it produces to much traffic for the SSD for my taste. Also, the space on the SSD is very limited.

Last edited by cro (2012-10-10 21:57:14)

Offline

#2 2012-10-10 22:35:53

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 723
Website

Re: problems with fdisk on 2TB HDD

Looks like a misinterpretation (blocks vs sectors and N sectors vs Last sector).

First your 2TB disk is 2000GB ~ 1863GiB, so if you want to create two partitions of ~ 1990GB/10GB  ~ (1853GiB + 10GiB)

all you need to do is set sdX1 to +1853G and accept default to sdX2


the result will be:

$ truncate -s 2000398934016 2T
$ fdisk 2T
Welcome to fdisk (util-linux 2.22).

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
Building a new DOS disklabel with disk identifier 0x890d122a.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 
Using default response p
Partition number (1-4, default 1): 
Using default value 1
First sector (2048-3907029167, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-3907029167, default 3907029167): +1853G
Partition 1 of type Linux and of size 1.8 TiB is set

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): 
Using default response p
Partition number (1-4, default 2): 
Using default value 2
First sector (3886024704-3907029167, default 3886024704): 
Using default value 3886024704
Last sector, +sectors or +size{K,M,G} (3886024704-3907029167, default 3907029167): 
Using default value 3907029167
Partition 2 of type Linux and of size 10 GiB is set

Command (m for help): p

Disk 2T: 2000.4 GB, 2000398934016 bytes, 3907029168 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: 0x890d122a

Device Boot      Start         End      Blocks   Id  System
   2T1            2048  3886024703  1943011328   83  Linux
   2T2      3886024704  3907029167    10502232   83  Linux

Offline

#3 2012-10-10 23:40:40

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,592
Website

Re: problems with fdisk on 2TB HDD

Will you be booting windows from this disk?  I believe win7 can read GPT but it cannot boot from a GPT formatted disk... I am not a win expert.  You will have no Linux issues booting to GPT with grub.  Not sure about syslinux but check the wiki.  If you can, I recommend formatting to GPT and partitioning with gdisk.  Remember that if you plan to boot off this disk using grub to create a 1 MB partition first (for grub bios) or a 200 MB partition first (grub efi).

Last edited by graysky (2012-10-10 23:45:44)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#4 2012-10-11 02:44:10

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: problems with fdisk on 2TB HDD

With syslinux and gpt, you don't need the small 1-2MB boot partition.  I think it is recommended that you create a separate /boot partition with syslinux, but it is not necessary.  I believe this is because syslinux depends on the legacy boot flag being set.  This is all stuff you don't really need to worry about though because it does it for you with the syslinux-install_update -iam command.

Offline

#5 2012-10-11 12:50:02

cro
Member
From: Germany
Registered: 2006-01-02
Posts: 101

Re: problems with fdisk on 2TB HDD

Thanks for all replies! smile


djgera wrote:

Looks like a misinterpretation (blocks vs sectors and N sectors vs Last sector).

Well, what is a block according to fdisk? Isn't it the logical sector size?
I deliberately used the last sector number to specify my partitions. That should work, too, after all. So it could still be a bug.


djgera wrote:

First your 2TB disk is 2000GB ~ 1863GiB, so if you want to create two partitions of ~ 1990GB/10GB  ~ (1853GiB + 10GiB)

all you need to do is set sdX1 to +1853G and accept default to sdX2


the result will be:

$ truncate -s 2000398934016 2T
$ fdisk 2T
Welcome to fdisk (util-linux 2.22).

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
Building a new DOS disklabel with disk identifier 0x890d122a.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 
Using default response p
Partition number (1-4, default 1): 
Using default value 1
First sector (2048-3907029167, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-3907029167, default 3907029167): +1853G
Partition 1 of type Linux and of size 1.8 TiB is set

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): 
Using default response p
Partition number (1-4, default 2): 
Using default value 2
First sector (3886024704-3907029167, default 3886024704): 
Using default value 3886024704
Last sector, +sectors or +size{K,M,G} (3886024704-3907029167, default 3907029167): 
Using default value 3907029167
Partition 2 of type Linux and of size 10 GiB is set

Command (m for help): p

Disk 2T: 2000.4 GB, 2000398934016 bytes, 3907029168 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: 0x890d122a

Device Boot      Start         End      Blocks   Id  System
   2T1            2048  3886024703  1943011328   83  Linux
   2T2      3886024704  3907029167    10502232   83  Linux

By specifying size it seems to work. Thank you.
Specifying last sector number seems broken.

Offline

#6 2012-10-11 12:56:20

cro
Member
From: Germany
Registered: 2006-01-02
Posts: 101

Re: problems with fdisk on 2TB HDD

graysky wrote:

Will you be booting windows from this disk?  I believe win7 can read GPT but it cannot boot from a GPT formatted disk... I am not a win expert.  You will have no Linux issues booting to GPT with grub.  Not sure about syslinux but check the wiki.  If you can, I recommend formatting to GPT and partitioning with gdisk.  Remember that if you plan to boot off this disk using grub to create a 1 MB partition first (for grub bios) or a 200 MB partition first (grub efi).

No, I won't boot from the 2TB disk. It's my data disk. GPT is surely nice, but I guess I stick to legacy bios format for now.

Offline

#7 2012-10-11 14:49:39

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 723
Website

Re: problems with fdisk on 2TB HDD

block = 1024 bytes

yup yup, there is a bug in fdisk, about entering last sector (and first sector). They does not work beyond value 2147483647 (2^30 * 2 - 1), should be reported to upstream. Indeed doing an invalid value does not report any error and always use 2147483647. I remember that some time ago I reported a bug but for +size.

Last edited by djgera (2012-10-11 14:50:43)

Offline

#8 2012-10-11 15:19:34

the.ridikulus.rat
Member
From: Indiana, USA
Registered: 2011-10-04
Posts: 765

Re: problems with fdisk on 2TB HDD

djgera wrote:

block = 1024 bytes

yup yup, there is a bug in fdisk, about entering last sector (and first sector). They does not work beyond value 2147483647 (2^30 * 2 - 1), should be reported to upstream. Indeed doing an invalid value does not report any error and always use 2147483647. I remember that some time ago I reported a bug but for +size.

Its not a bug. Its a limitation of MBR format. MBR stores sector values in 32-bit format, so then maximum sector that can be addressed by MBR is 2^32. Since sector size is 512 bytes in most systems, this translates to 2 TiB (tebibyte) or 2.2 TB (terabyte) (0 to 4294967296 512-byte sectors). That is one of the reasons why GPT was designed.

@cro: If its a data disk, then you can simply convert to GPT and use it in both Windows and Linux. Please don't mix BIOS and MBR. BIOS is the firmware and MBR is the partition scheme, both are different. You can perfectly use Linux in BIOS-GPT setup.

Offline

#9 2012-10-11 20:06:36

cro
Member
From: Germany
Registered: 2006-01-02
Posts: 101

Re: problems with fdisk on 2TB HDD

djgera wrote:

block = 1024 bytes

Where does this odd measure unit come from? Isn't the block size of the Linux's block layer 4096 bytes?


djgera wrote:

yup yup, there is a bug in fdisk, about entering last sector (and first sector). They does not work beyond value 2147483647 (2^30 * 2 - 1), should be reported to upstream. Indeed doing an invalid value does not report any error and always use 2147483647. I remember that some time ago I reported a bug but for +size.

Yes, +size in sectors is still broken, too.
I already wondered if I'm the only one in the world that would want to use sector values to specify partitions.

the.ridikulus.rat wrote:

Its not a bug. Its a limitation of MBR format. MBR stores sector values in 32-bit format, so then maximum sector that can be addressed by MBR is 2^32. Since sector size is 512 bytes in most systems, this translates to 2 TiB (tebibyte) or 2.2 TB (terabyte) (0 to 4294967296 512-byte sectors). That is one of the reasons why GPT was designed.

Well, it works when using +size with G, so why should it be a limitation of MBR? The whole disk is smaller than 2 TiB, so that limitation isn't the problem here.


the.ridikulus.rat wrote:

@cro: If its a data disk, then you can simply convert to GPT and use it in both Windows and Linux. Please don't mix BIOS and MBR. BIOS is the firmware and MBR is the partition scheme, both are different. You can perfectly use Linux in BIOS-GPT setup.

Yes, you're right, MBR format is what I meant.

Last edited by cro (2012-10-11 20:08:07)

Offline

#10 2012-10-11 23:18:50

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 723
Website

Re: problems with fdisk on 2TB HDD

@the.ridikulus.rat: yes its a bug, see the sizes again... wink 2^30 != 2^32 wink

@cro: 1024 bytes comes from what Linux defines as "Block" for internal purposes like caching and buffering, when you read "Block", you can automatically assume that refers to 1024 bytes

Offline

#11 2012-10-15 15:21:01

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 723
Website

Re: problems with fdisk on 2TB HDD

@cro: do you reported this to upstream? Otherwise I will report it...

Offline

Board footer

Powered by FluxBB