DOS 6.22 only recognizes 500MB disk instead of 2GB?

Discussions about using non Windows and Linux guests such as FreeBSD, DOS, OS/2, OpenBSD, etc.
notorab
Posts: 10
Joined: 6. Nov 2019, 07:48

DOS 6.22 only recognizes 500MB disk instead of 2GB?

Post by notorab »

I installed Dos 6.22 and FDISK is only recognizing total disk space of 500 MB. I used the Virtual Media Manager and extended the disk space to 2GB. I see the current filesystem is FAT16. Does anyone know why FDISK isn't seeing the extra disk space?
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: DOS 6.22 only recognizes 500MB disk instead of 2GB?

Post by mpack »

528MB would be the max for a DOS OS of that era limited to CHS sector addressing. You can however have multiple drives
ghr
Volunteer
Posts: 376
Joined: 25. May 2007, 22:46
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: DOS, Win3x, Win95, WinXP, Ubuntu, OS/2

Re: DOS 6.22 only recognizes 500MB disk instead of 2GB?

Post by ghr »

Eh mpack? Aren't you mistaken by BIOS limitations? I don't see any issue with a 2GB DOS 6.22 VM, in VirtualBox 6.1.26, so a pretty recent BIOS by all standards...
javispedro
Posts: 58
Joined: 29. Jan 2022, 15:31
Primary OS: openSUSE
VBox Version: OSE other
Guest OSses: Old & New Windows, Linux

Re: DOS 6.22 only recognizes 500MB disk instead of 2GB?

Post by javispedro »

What you can't do is resize from a 500GB to a 2GB disk and expect any DOS partitions to survive.
The problem is that the geometry of the virtual disk will need to be changed in order to remain compatible with DOS, but if the geometry of the disk changes all partitions would become invalid (since they are expressed in terms of CHS in the MBR).
I am assuming that to preserve compatibility (i.e. so that you can still see your partitions even if you resized) the VirtualBox BIOS will disable the translation when the virtual geometry does not match what is on the MBR.

Basically: create a new 2GB disk from scratch, don't resize.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: DOS 6.22 only recognizes 500MB disk instead of 2GB?

Post by mpack »

ghr wrote:Eh mpack? Aren't you mistaken by BIOS limitations?
I don't remember where the limitations are, I just remember that DOS did indeed have a ~500GB limit around then - and I remember shopping for additional hard drives back in the 486DX era...
ghr
Volunteer
Posts: 376
Joined: 25. May 2007, 22:46
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: DOS, Win3x, Win95, WinXP, Ubuntu, OS/2

Re: DOS 6.22 only recognizes 500MB disk instead of 2GB?

Post by ghr »

That was a BIOS limitation. DOS 6.22 allows a max partition size of 2GB, so the HDD can even (and easily) be larger than 2G.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: DOS 6.22 only recognizes 500MB disk instead of 2GB?

Post by mpack »

I made the mistake of believing the OP, sounds like his hitting a ~500GB limit was a coincidence.

Reviewing the text it seems to make little sense. Is this just that he's looking for an online partition manager for DOS? I don't remember that fdisk in that era allowed you to resize a partition. The drive would have to be attached to a more modern OS and the partitions resized there.

I've never heard that one about resizing from 500MB to 2048MB being a problem. The CHS addressing limit tops out at 8GB, so resizing above that is definitely a problem - but not the problem in play here.
javispedro
Posts: 58
Joined: 29. Jan 2022, 15:31
Primary OS: openSUSE
VBox Version: OSE other
Guest OSses: Old & New Windows, Linux

Re: DOS 6.22 only recognizes 500MB disk instead of 2GB?

Post by javispedro »

mpack wrote:I've never heard that one about resizing from 500MB to 2048MB being a problem. The CHS addressing limit tops out at 8GB, so resizing above that is definitely a problem - but not the problem in play here.
Resizing a _disk_ is the problem here, not the partition. You can resize the partition just fine using any modern tool you'd prefer. But when you try that disk DOS will, at best, fail to boot; at worst, boot correctly then corrupt everything on the disk (this happened to me, that's why I am mildly familiar with the topic).


(Details from Wikipedia https://en.wikipedia.org/wiki/Logical_b ... anced_BIOS )
"Physical" CHS adressing in DOS actually has a limit at 500ish MiB (corresponding to 1024 C × 16 H × 63 S). ATA/IDE doesn't physically support more than 16H and DOS doesn't support more than 1024 C, so formally that's your limit for an ATA disk on DOS.
A BIOS can workaround this by faking the number of heads given to DOS (while the physical ATA disk is limited to 16H, DOS can handle up to 255H) . If you can "fake" 255H, then you can make DOS support 8GiB (1024 C x 255 H x 63S). But your BIOS will have to translate from this "fake" geometry (called "logical", LCHS) into the real geometry of the disk (with only 16H, called "physical", PCHS).

You can actually find both LCHS and PCHS listed in the VirtualBox log (I think by default).

The other piece of the puzzle here is that the partition table in the MBR and the FAT BPB (among many on-disk data structures) will use CHS-adressing, and thus are sensible to the disk geometry. If you e.g. "change" the geometry of the disk from 16H to 32H then all these data structures become invalid because they will no longer point to the same real sector. This was never an issue in real hardware because obviously real disks don't change geometry, albeit it was an issue when you copied partitions from one disk to another with different geometry.

With both pieces, you can start to figure out the problem if you "resize" a VDI which already has DOS partitions.

From my memory if you start with a disk that is less than < 500MiB VirtualBox's BIOS will use 16 physical & logical heads. There is no translation whatsoever. This is likely for compatibility reasons.
When you suddenly enlarge the virtual disk to 2GB, VirtualBox would need to increase the number of logical heads, and therefore all partitions on your disk would appear to be in the wrong places (since the MBR describes them using CHS addresses for a 16H disk).
So VirtualBox doesn't do that. If you enlarge an existing disk, the number of heads is kept constant, and the number of cylinders is increased instead. Therefore DOS will only see up to 1024Cs, i.e. 500MiB. But at least it will see these first 500MiB consistently before/after the resize, and your legacy OSes will continue to boot.
FDISK will show you a 500MiB disk. This is the situation I'd bet notorab is currently on. Doesn't matter if you delete the 500MiB partition, FDISK only sees a 500MiB disk.

Now, however, if you create the 2GB disk from scratch, there is no problem about preserving your existing partitions, and so VirtualBox will create the disk with as many "logical" heads as required, and the BIOS will do the translation. In this case, DOS will see the full disk just fine, and FDISK will say you have a 2GiB disk.

All of the above is just a guess, so I could be wrong, but I remember trying the following experiment which shows this behavior. Get a DOS 6.22 bootdisk, a VM with a 500MiB disk. Boot DOS, run FDISK and create and format a 500MiB partition on that disk. Then use VirtualBox to resize the VDI to 2GB and boot DOS. It should still boot, but FDISK will report a disk of 500MiB only. If you now delete the enlarged disk, and create a new VDI with 2GB _from scratch_, FDISK will report a 2GB disk. In both runs you can grep the VM log for "LCHS" to see which geometry the VirtualBox BIOS decides to show DOS.

There's probably some software out there than can fix MBRs & partitions which have the wrong CHS values in their headers, but as you can imagine, magically growing disks was not much of a concern in the era. Software that would copy partitions from one disk to another needed to fix this, but in these cases you'd usually have both "old" and "new" disks connected. It's difficult to convince such software that the old and the new disk are the same (i.e. that you already did the copy yourself, you just want to fix CHS).

And of course none of this is relevant for running win95 and later era OSes since they'll use LBA.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: DOS 6.22 only recognizes 500MB disk instead of 2GB?

Post by mpack »

Perhaps it's worth mentioning that I wrote the CloneVDI drive resize tool, so (a) I'm well aware of the distinction between resizing a drive and resizing a partition, (b) I don't remember resizing a drive from 500MB ever being fed back to me as a problem.

However that would admittedly be an unusual scenario, so perhaps it's just that nobody ever tried it. Checking, I see that my own DOS 6.22 VM has a 512MB hard drive, so I can test what happens when I resize it. ... I'll report back shortly.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: DOS 6.22 only recognizes 500MB disk instead of 2GB?

Post by mpack »

... and in fact it worked perfectly. I did it with CloneVDI, and I had CloneVDI also resize the boot partition rather than having to look for a DOS compatible partition manager.

So no problem that I can see expanding a 500MB DOS drive to 2048MB.

(*) Checking again, DOS does boot so the drive and its geometry is fine, but I don't think expanding the FAT16 partition has worked, as chkdsk still shows ~512MB disk space. CloneVDI's partition management is very basic, it may not support increasing a FAT16 partition to 2GB, as that is usually the threshold at which FAT32 format is used instead, and that means major filesystem changes - which in case are not supported by DOS 6.22!
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: DOS 6.22 only recognizes 500MB disk instead of 2GB?

Post by mpack »

... Ah, I had forgotten just how limited CloneVDI's FAT16 partition expansion function was. Basically, CloneVDI will only do it if the FAT table itself is the only data structure that needs to be modified. However a 16bit FAT means a max limit of <65535 clusters, and CloneVDI will give up if it can't reach the desired partition size without increasing the cluster size, as the latter requires major surgery - every single cluster chain and FAT directory entry would have to be replaced, and every file would have to be copied to ensure that the new larger clusters are contiguous.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: DOS 6.22 only recognizes 500MB disk instead of 2GB?

Post by mpack »

As an aside, I have recalled that DOS is not very fussy about identifying drives, it only cares about contents - directories and files.

So I would suggest to the OP: create a new 2048MB VDI and attach it to the VM. FDisk and format it (/s to make it bootable) from inside DOS, then just copy *.* from C: to the new drive. You should then be able to swap drives in the VM settings and DOS should be perfectly happy to boot up from the new drive. The old one can now be disconnected.
javispedro
Posts: 58
Joined: 29. Jan 2022, 15:31
Primary OS: openSUSE
VBox Version: OSE other
Guest OSses: Old & New Windows, Linux

Re: DOS 6.22 only recognizes 500MB disk instead of 2GB?

Post by javispedro »

mpack wrote:(*) Checking again, DOS does boot so the drive and its geometry is fine, but I don't think expanding the FAT16 partition has worked, as chkdsk still shows ~512MB disk space.
No, the geometry may _not_ be fine. If the number of heads is still 16, then the translation has not kicked in, and therefore _DOS will not be able to address anything larger than >500MiB_, even if the MBR or the BPB make it believe it is a 2GiB partition. This is precisely the highly dangerous situation where the partition is going to be corrupted sooner or later. Just try writing more than 500MiB of files and reading them back.

6.22 FDISK must report that the disk size is 2GiB. Otherwise something will break.


I have just reproduced the behavior I mention with VBox 7.0.6:

First boot of a 6.22 DOS installed on a 500 MiB VDI with a 500MiB FAT16 partition:
00:00:01.117400 VMMDev: Guest Log: BIOS: ata0-0: PCHS=1015/16/63 LCHS=1015/16/63
(16H by default, BIOS translation is off)
FDISK reports 500MiB disk.

I resize the VDI to 2GiB using VBox's GUI. Neither MBR nor partition have been touched.
00:00:01.151152 VMMDev: Guest Log: BIOS: ata0-0: PCHS=4161/16/63 LCHS=1024/16/63
The BIOS translation has _not_ kicked in, as LCHS still shows 16 heads. The maximum DOS can address on this disk via CHS is still 500MiB!
FDISK reports a 504MiB disk.
It doesn't matter if I repartition the disk at this point, DOS simply _cannot_ access > 504MiB!

(If the BIOS translation where to kick in, and the number of logical heads were to change, my partition would become unreadable)
(If I were to resize the partition using another OS, or an external tool, DOS would believe the partition was 2GiB, but still would not be able to address anything > 504MiB, resulting in corruption!)

I now create a VM with a 2GB VDI, and install DOS 6.22. First boot:
00:00:01.099094 VMMDev: Guest Log: BIOS: ata0-0: PCHS=4161/16/63 LCHS=520/128/63
Note the physical size is exactly the same as in the case before. However the logical reported CHS is completely different.
The BIOS translation has now kicked in, and we have > 16 heads.
FDISK reports a 2GiB disk, and I can create a 2GiB partition just fine, and it will be completely accessible by DOS.


Basically, what one would need to "allow a 2GiB partition after resizing a disk from 500MiB to 2GiB" is:
1. Convince the VirtualBox BIOS to activate CHS translation on the resized disk, even if it would make data on it unreadable.
Normally there should be some byte on CMOS where you can enable the translation -- but I don't know where VirtualBox stores the CMOS.
Or is it possible the logical geometry is stored on the VDI metadata?
2. After doing that, DOS reports a 2GiB disk, but any existing partitions become unreadable due to changed geometry. Fix the MBR and the partition's BPB to realign with the new disk geometry using an external tool.
3. Now the partition is readable. Enlarge it to 2GiB.

Or:
1. Create a new 2GiB VDI from scratch. VirtualBox BIOS will enable CHS translation on it by default.
2. Now clone the partition from the 500GiB to 2GiB VDI, either from a tool inside the VM or a tool outside the VM.
The only requirement is that the tool should take care of translating from the original VDI's 16H geometry to the new VDI's 128H geometry, both in the MBR as well as the partition's BPB.
javispedro
Posts: 58
Joined: 29. Jan 2022, 15:31
Primary OS: openSUSE
VBox Version: OSE other
Guest OSses: Old & New Windows, Linux

Re: DOS 6.22 only recognizes 500MB disk instead of 2GB?

Post by javispedro »

mpack wrote:So I would suggest to the OP: create a new 2048MB VDI and attach it to the VM.
That was my original suggestion, create disk from scratch, don't try to resize :)
mpack wrote: FDisk and format it (/s to make it bootable) from inside DOS, then just copy *.* from C: to the new drive. You should then be able to swap drives in the VM settings and DOS should be perfectly happy to boot up from the new drive. The old one can now be disconnected.
The gotcha here is that neither copy nor xcopy on 6.22 will copy hidden nor system files. There's not even an option to do it. Depending on what type of software you have installed this could be an issue (e.g. some store licensing info in a hidden file deep in some subdirectory, precisely to prevent copying).
I did hit this resizing issue in the past and spent quite some time troubleshooting :)
I remember ending up using some GNU mv-like tool. I remember it was not DJGPP's, albeit DJGPP's would likely work too. Alternatively, grab xcopy from FreeDOS.

If you have nothing of importance installed on the VM, probably less hassle to just start the entire VM from scratch.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: DOS 6.22 only recognizes 500MB disk instead of 2GB?

Post by mpack »

As far as I know the only "system files" on a typical DOS boot drive are COMMAND.COM and the boot sectors, hence my instruction to format the drive using "format d: /s", so you start with those elements already there.

After all, the reason the files are on the C: drive at all is that they were copied there by the user from the DOS floppy. DOS did not always come with an installer, and if it did, all it did was copy the files too.
Post Reply