diff --git a/sim_disk.c b/sim_disk.c index 4b9d0dfa..f0bc3264 100644 --- a/sim_disk.c +++ b/sim_disk.c @@ -5758,7 +5758,7 @@ if (1) { /* CHS Calculation */ cylinderTimesHeads = totalSectors / sectorsPerTrack; } } - cylinders = cylinderTimesHeads / heads; + cylinders = (totalSectors + sectorsPerTrack * heads - 1) / (sectorsPerTrack * heads); Footer.DiskGeometry = NtoHl ((cylinders<<16)|(heads<<8)|sectorsPerTrack); } Footer.Checksum = NtoHl (CalculateVhdFooterChecksum(&Footer, sizeof(Footer)));