sarah-walker-pcem / pcem

PCem
http://pcem-emulator.co.uk
GNU General Public License v2.0
1.55k stars 216 forks source link

Cylinders, Heads and Sectors are reported incorrectly on hard disks #273

Closed jimjamz closed 2 months ago

jimjamz commented 2 months ago

Describe the bug When I create a new Hard disk And I specify the type (e.g. 45) Then I expect the sectors (17), heads (15) and cylinders (917) to be correct when starting the machine But they are not correct

To Reproduce

  1. Create a new machine with a hard disk and floppy controllers, and a floppy drive.
  2. Create a new hard disk with a type (e.g. 45).
  3. Start the machine with a bootable diskette (e.g. Debian 1.1. Boot diskette)
  4. Boot Debian 1.1 boot disk. Before it asks for the root disk, Debian reports details about the hard disk. Notice the Cylinders, Heads and Sectors reported (CHS). The heads of the disk are set to 32. See attached screenshot. Screenshot from 2024-09-20 13-34-10

You can also see that the same information is reported about the disk during the Debian 1.1 setup: Screenshot from 2024-09-20 14-30-10

Expected behavior

  1. Repeat steps 1 - 4 in 86Box. Notice the CHS parameters are the same as those specified when creating the hard disk: Monitor_1_20240920-143438-472

Screenshots Attached in-line above.

Emulator configuration

Host machine

Additional context If I move the hard disk image created in 86Box (which is correctly reporting the cylinders, heads and sectors in 86Box) over to my machine in PCem, the disk attributes are once again incorrect. It doesn't appear to be an issue with the creation of the hard disk image, but when such an image (created by either PCem or 86Box) is being used by PCem.

ruben-balea commented 2 months ago

Have you configured the hard drive in the BIOS? It seems that the BIOS is using LARGE or maybe LBA instead of CHS/NORMAL I don't have PCem at hand right now, but assuming it's an Award BIOS enter the BIOS setup and run the hard disk autodetection, then the red box will show you the number of heads, sectors and cylinders for each mode, instead of Y (for Yes) press 1 for CHS (I think 2 is for LBA and 3 for large)

All drives under 504 MB can be accessed using CHS. A drive formatted under one mode won't work if the BIOS is using another mode.

jimjamz commented 2 months ago

Hi @ruben-balea That's it! I was experimenting with AMI BIOS machines earlier (where I was setting the HDD to type 45) then switched to AWARD (where I did not set the HDD type in the BIOS). I completely forgot about it. Only after the BIOS switch, did I notice the incorrect readings of the cylinders, heads and sectors. Your instructions were correct and pressing '1' allowed me to select CHS. Debian now reports the correct disk attributes on boot up. You've solved it once again! :) Many thanks!