Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

Current FreeDOS fdisk utility (Users)

posted by tom Homepage, Germany (West), 10.01.2021, 19:10
(edited by tom on 11.01.2021, 00:25)

> I recently tried FreeDOS's fdisk utility on a real machine and, to say it
> carefully, IMO this tool needs to be improved.

definitively!

>
> There are currently 2 binaries delivered in the fdisk package:
>
> - FDISK.EXE, version 1.2.1, dated 4/2003
> - FDISK131.EXE, version 1.3.1, dated 11/2008

that's a bug by itself.
by what criteria are users expected to choose the right one? :-( :-( :-(

> On the machine was installed a "normal" WD SATA 1TB HD.
>
> Launching FDISK131, it just emits:
> "Error reading Hard DIsk! Addressed sector not found"
> and exits.
most likely due to
  VERSION W98
in the (missing) .INI file. if this is not set, during initialization

  if( (flags.version==W95) || (flags.version==W95B) || (flags.version==W98) )
   Check_For_INT13_Extensions();

and later it is not able to access some sectors above 2GB and (correctly) exits due to disk I/O error. better save than sorry.

>
> FDISK.EXE starts without error and allows to create a new (primary)
> partition ( I tried size 8192 MB), but it's unable to correctly calculate
> the starting sector, resulting in overlapping partitions:
>
> BI  Type                     Sector    Size         MB abs.
> Start-End
> -----------------------------------------------------------------------
> 80  83 Linux ext2fs                  2048 390701056 190772 2048-390703103
> 00  0c Prim. DOS (FAT32,LBA)    390703104  16777216   8192
> 390703104-407480319
> 00  0c Prim. DOS (FAT32,LBA)    407472660  16787925   8197
> 407472660-424260584

>
> As it can be seen, partition 2 and 3 do overlapp, sectors
> 407,472,660-407,480,319 are part of both partitions.

I still haven't found the precise bug location, but the problem seems to be:

FDISK does all inner computations with cylinders, and simply assumes heads=0 sector = 1.

even reading the partition table, head and sector are basically ignored

Read_Partition_Tables()
{
...
          pDrive->pri_part[index].start_sect=1;
          pDrive->pri_part[index].start_cyl
           =Extract_Cylinder_From_LBA_Value(
           pDrive->pri_part[index].rel_sect
           ,pDrive->pri_part[index].start_head
           ,pDrive->pri_part[index].start_sect
           ,pDrive->total_head
           ,pDrive->total_sect);

          pDrive->pri_part[index].end_head=pDrive->total_head;
          pDrive->pri_part[index].end_sect=pDrive->total_sect;
          pDrive->pri_part[index].end_cyl
           =Extract_Cylinder_From_LBA_Value(
           /* */
           (pDrive->pri_part[index].rel_sect
           +pDrive->pri_part[index].num_sect)
           ,pDrive->pri_part[index].end_head
           ,pDrive->pri_part[index].end_sect
           ,pDrive->total_head
           ,pDrive->total_sect);


now in your partition table,

BI Type                    Start-C/H/S   End-C/H/S     Sector     Size      MB  abs. Start/End
-----------------------------------------------------------------------------------------------
80 0e Prim. DOS,FAT16,LBA     0/  1/ 1  975/ 63/32         32    4096000   2000 32-4096031
00 0c Prim. DOS,FAT32,LBA   976/  0/ 1  534/ 63/32    4096000  120731648  58951
00 00 Free Entry              0/  0/ 0    0/  0/ 0          0          0      0
00 00 Free Entry              0/  0/ 0    0/  0/ 0          0          0      0


the FDISK cylinder is one larger than the ending cylinder of the first partition.

yes, this is a bug. unfortunately fixing this would probably require a major code change. should be possible.

the real problem here is that code changes in partition creating/deleting/whatever code is dangerous stuff as this risks losing data.

my recommendation: stop using FDISK. there are better alternatives anyway.

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 84 users online (0 registered, 84 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum