[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Strange MBR CHS partition values created by debian-installer



On 09.07.2023 00:02, Steve McIntyre wrote:
Nothing should be caring about C/H/S at all in the 21st century. Using
C/H/S only allows you to access 515MB of disk [1]. *Everything* these
days uses LBA instead.

What makes you think that the BIOS on this old machine cares about
C/H/S?

My machine is old, it's a 32-bit CPU from 2006 in a machine from 2008.

My BIOS reports disk CHS geometry based on the values of CHS end of boot MBR partition. Debian installer sets the amount of sectors to 2 in CHS end.

GRUB2, for some reason, follows disk geometry even for LBA reads, which results in reading only up to 1 KB of data for each int13h call. It takes about 5 seconds to show GRUB menu (GRUB loading... for 5 seconds), the kernel (4.5 MB) is loaded in 27 seconds, and initrd takes ages to load.

Relevant GRUB2 issue description here (contains incorrect MBR CHS values, I took the first mbr parser found online which was incorrect):
https://lists.gnu.org/archive/html/grub-devel/2023-07/msg00001.html

My patches to ignore CHS geometry for LBA reads:
https://lists.gnu.org/archive/html/grub-devel/2023-07/msg00020.html

I found some information in Russian sources that some BIOSes do not implement out-of-geometry reads internally for int13h, but that is for very old PCs like IBM AT/XT, and GRUB is 32-bit 386+.

What happens if you tweak the partitioning by hand when
installing?

Nothing happens, Debian Installer still ends with 2 sector layout. Note that I'm using disk sizes less than 8 GB, the partition sizes are respectively less than 8 GB.


I've tried to install Debian 12 i386 to a 8G disk, using qemu, with guided
automatic partitioning. Testdisk data right after the installation:

Disk testz.img - 8589 MB / 8192 MiB - CHS 1045 255 63
Current partition structure:
      Partition                  Start        End    Size in sectors

  1 P Linux                    0  32 33   919 199 48   14774272

Bad relative sector.
  2 E extended               919 232 16  1044  52 32    1996802

Bad relative sector.
No partition is bootable
  5 L Linux Swap             919 232 18  1044  52 32    1996800

Bad relative sector.


It seems that testdisk automatically recalculates C/H/S values and shows
corrected data (in the table above).

Here's what really is present in the MBR (data of the first partition entry):

$ ./mbr_my.py testz.img Status:                  0x0
C/H/S start:             4 4 1
Part type:               0x83
C/H/S end:               1023 254 2
LBA of first sector:     2048
Sector count:            14774272


fdisk/cfdisk and parted all create partitions for which testdisk does not
complain.

d-i drives parted to make partitions...

[1] https://forums.tomshardware.com/threads/lba-chs-bios-prob.685748/


Attachment: OpenPGP_signature
Description: OpenPGP digital signature


Reply to: