VOGONS


First post, by unix_junkie

User metadata
Rank Newbie
Rank
Newbie

Hi everyone.

So I watched this video from Phil about sector-aligned partitioning of a SATA SSD: How to avoid short lifespan when using SSD in Retro PC, and decided whether the above was possible when using DOS (or Windows 9x) -- let's say, for the first FAT16 partition.

Normally, when you are partitioning a hard drive for modern operating systems, the 1st partition starts at sector 2048, and partition boundaries are already sector-aligned, regardless of whether the physical sector size if 512 or 4096 bytes.

When partitioning for MS-DOS (or from within MS-DOS, using fdisk), the 1st partition gets created at sector 63, or cylinder 1, and partition boundaries are instead cylinder-aligned. Obviously, when physical sector size is 512 bytes (old HDDs), partition boundaries are automatically sector-aligned, too. I always used to think cylinder alignment was a must for the primary partition to be able to boot DOS or Windows 9x.

Linux version of fdisk even has two separate modes (DOS compatibility on or off), to follow either of the above approaches.

Now, since MS-DOS can't use FAT16 partitions with a cluster size of 64k, let's create a partition of the maximum possible size using a 32k cluster size. The maximum number of clusters FAT16 can have is 65536 - 10 = 65526 (source), so the partition size would be 2147155968 bytes (slightly less than 2GB), or 4193664 logical sectors. Using Linux fdisk, while creating the partition, we can manually specify the first (2048) and the last (4195711) sector. Then we can format the partition without leaving Linux, though format.com from DOS works just as well:

mkdosfs -F16 -R 1 -s 64 -S 512 -v /dev/sda1

After the above was done, I rebooted from a Windows 98 live CD and ran scandisk. Interestingly, no errors were reported.

Then I started Windows 98 installation, rebooted a couple of times and completed the installation -- and no problems were detected, either.

I tried to run multiple diagnostic or partitioning tools, incl. scandisk, Norton Utilities, Disk Editor from PTS-DOS -- and all those tools reported no errors about partition boundary misalignment. All of them reported partition geometry correctly, too.

The only exception I found was PowerQuest PartitionMagic, which always expects a partition table to be in DOS compatibility mode (cylinder-aligned).

So the question is: assuming I will never run PartitionMagic again, is DOS compatibility mode that essential when running MS-DOS 6.22 or 7.x?

  • Which problems may I encounter?
  • Which extra tests/tools should I run to feel more confident?

Reply 1 of 12, by konc

User metadata
Rank l33t
Rank
l33t

Even if you start the partition where you want it, what about the FAT table(s) that do not have a fixed size? I was always under the impression that you cannot align a FAT partition, or to phrase it better a FAT partition won't stay aligned.

Reply 2 of 12, by unix_junkie

User metadata
Rank Newbie
Rank
Newbie

Thank you for your response.

Assuming FAT16 cluster size is 32k, the content of the file system (each file and directory) will be sector-aligned?
Or will it not?
Please clarify your response, I don't fully get your point.

Reply 3 of 12, by konc

User metadata
Rank l33t
Rank
l33t

From what I know the FAT table is not a convenient cluster size multiple, so the actual files that start right after the FAT table will be out of alignment. One would need to start the data region from a specific sector, and I don't know if this is possible or how to do it. I may be completely wrong though so every one please feel free to correct me.

Reply 4 of 12, by jmarsh

User metadata
Rank Oldbie
Rank
Oldbie
konc wrote on 2023-11-21, 11:51:

From what I know the FAT table is not a convenient cluster size multiple, so the actual files that start right after the FAT table will be out of alignment. One would need to start the data region from a specific sector, and I don't know if this is possible or how to do it. I may be completely wrong though so every one please feel free to correct me.

The size of the FATs is specified in the BPB (Sectors Per FAT) and can be larger than necessary / padded to force alignment.

Reply 5 of 12, by Falcosoft

User metadata
Rank l33t
Rank
l33t

Yeah, Konc is absolutely right. Contrary to NTFS in case of FAT/FAT32 partition alignment is not enough to get optimal speed.
In case of NTFS metadata is part of the file system (MFT) but in case of FAT/FAT32 the metadata is before the file system and the size of metadata is not fixed but depends on the partition and cluster size.
In order to get optimal speed you need to get First FAT table, Second FAT table, Root Directory and most importantly the First file data (cluster 0) to begin at aligned LBA addresses.
On Windows you can use RMPrepUSB to check if this is the case.
More info:
Re: Benchmarks: HDD vs. CF vs. true SSD on Tualatin rig
https://msfn.org/board/topic/151798-does-fat3 … n-its-clusters/

Website, Facebook, Youtube
Falcosoft Soundfont Midi Player + Munt VSTi + BassMidi VSTi
VST Midi Driver Midi Mapper

Reply 6 of 12, by chiveicrook

User metadata
Rank Newbie
Rank
Newbie

Unless for some reason you need every 0.1% of performance, to avoid most of the write amplification problems it's enough to just sector align (edit: asssuming first 1MiB alignment). There are too many operational differences which are unknown to the user between various solid state media to bother with lower level optimization IMHO (allocation unit size, write page size, erase block size, internal wear leveling algorithms, FAT optimization (that's a thing on SD/CF cards for example))

Reply 7 of 12, by Riikcakirds

User metadata
Rank Member
Rank
Member

I think there is a solution for aligning the Fat tables. In the Windows 2003 SP2 Deployment Tools (deploy.cab) it has an updated format tool for Dos called OFORMAT.COM. It is the DOS 8 format.com updated with new switches.
The new /A switch aligns the fat. You would use the /A:8 option to create a FAT volume that is aligned to 4k clusters. Each number is 512kb, 8 = 4096kb.

It also includes another dos tool called Cvtarea.exe. It summarizes it as "This is a command-line tool to create files and to analyze the placement of those files on a volume that uses the FAT32 or FAT file system.................................................
which you can use to create a reserved, contiguous, placeholder file for a less fragmented and more efficient file system".

Reply 8 of 12, by stanwebber

User metadata
Rank Member
Rank
Member

i remember having problems getting win9x or dos to recognize an extended partition/logical drive unless it was cylinder aligned. i dual-booted linux in a 2nd primary partition with shared data in the extended partition. in the end i had to abandon linux tools and use dos to do the partitioning (with respect to the extended partition/logical drive). i could go back and redo the primary partitions with linux at-will to align them any way i wanted.

Reply 9 of 12, by unix_junkie

User metadata
Rank Newbie
Rank
Newbie

Chiveicrook,
Falcosoft,
Jmarch,
Konc,
Riikcakirds,
Stanwebber,

thank you very much for your responses.

Reply 10 of 12, by Disruptor

User metadata
Rank Oldbie
Rank
Oldbie
stanwebber wrote on 2023-11-22, 15:23:

i remember having problems getting win9x or dos to recognize an extended partition/logical drive unless it was cylinder aligned. i dual-booted linux in a 2nd primary partition with shared data in the extended partition. in the end i had to abandon linux tools and use dos to do the partitioning (with respect to the extended partition/logical drive). i could go back and redo the primary partitions with linux at-will to align them any way i wanted.

For DOS, there is no need to have it cylinder-aligned but cylinder-head-aligned.
For a 4K sectored drive, cylinder 0, head 0-7 should not be used - that are 504 sectors.

Reply 11 of 12, by douglar

User metadata
Rank Oldbie
Rank
Oldbie
Disruptor wrote on 2023-11-26, 00:09:

For DOS, there is no need to have it cylinder-aligned but cylinder-head-aligned.
For a 4K sectored drive, cylinder 0, head 0-7 should not be used - that are 504 sectors.

What is the best way to check to see if things are allign correctly in DOS?

I’m often running 2GB CF devices or 16GB msata devices at 528MB becuase of the 1024 cylinder limit in some early IDE drivers. I would like to check the sector alignment.

Reply 12 of 12, by Disruptor

User metadata
Rank Oldbie
Rank
Oldbie

I do it manually with nu.exe - the disk editor from Norton Utilities 4.50 Advanced Edition.