Author Topic: How to Format a Hard Drive  (Read 565 times)

Neil Waldhauer

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 31
  • Posts: 460
    • View Profile
    • Blonde Guy
How to Format a Hard Drive
« on: August 31, 2019, 09:36:14 pm »
I have a computer that is running eComStation, and it became unreliable, with a trap screen after a minute of use.

I replaced the computer, and it's fine, but I was curious what was happening with the unreliable one. I booted from a USB stick and ran chkdsk /f on the drive, and one file was unrepairable. That was enough for me. I don't know why it happened, but I decided to format the drive and restore from backup.

I used FORMAT /L C: /FS:JFS to format the drive. That appears to work, but now I wonder what that does.

Quote
According to Jim Wilkerson, years ago, the /L parameter didn't just remove the header records but
formatted the drive removing all data. My understanding it was sector by sector putting ones and zeros
back on the drive as it was originally when it was new. I don't know what happens if there are bad areas on the
drive but I recall it may map around the bad area.

I don't think it works the same in every file system. I think the working code is implemented in the mini-FS driver. The behavior is documented for HPFS, but not for other file systems. What does FORMAT /L do in JFS?
Expert consulting for ArcaOS, OS/2 and eComStation
http://www.blondeguy.com

Lars

  • Sr. Member
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 43
  • Posts: 419
    • View Profile
Re: How to Format a Hard Drive
« Reply #1 on: August 31, 2019, 11:16:27 pm »
I seem to remember that it prevents chkdsk c: /F:3 from finding anything. If you want to have the exact technical detail you will need to look at the OpenJFS implemenation at Netlabs and analyze the source code ...

"format" for JFS is implemented in UJFS.DLL. At least the filesystem specific implementation. FORMAT.COM just queries which DLL to load for a given drive letter (UHPFS.DLL, UJFS.DLL, UFAT32.DLL etc.) and then invokes the "format" entry point.

Joop

  • Sr. Member
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 44
  • Posts: 482
    • View Profile
Re: How to Format a Hard Drive
« Reply #2 on: September 01, 2019, 12:35:25 am »
A test on the harddisk is performed with the /L parameter, just run help format or load newview and load the file  OS2\BOOK\CMDREF.INF. Then look for format and choose the /L parameter for more info. As far as I can read it, it has nothing to do with what system you are going to use the drive.

Neil Waldhauer

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 31
  • Posts: 460
    • View Profile
    • Blonde Guy
Re: How to Format a Hard Drive
« Reply #3 on: September 01, 2019, 04:14:51 am »
I think Lars sort of has the answer, but I'd hoped that someone would actually know. Shouldn't we have this documented somewhere besides reading the source code? The OS/2 command reference hints that /L only applies to MO (magneto-optical) drives.

Quote
FORMAT Command: /L Parameter

Specifies the long format procedure used to format hard disks or format and install the file system on an IBM read/write optical disc. Formatting an optical disc the first time requires about 20 minutes. Reformatting a previously formatted optical disc requires only a few minutes when you do not use the /L parameter.

For hard disks, specifying the /L parameter causes media testing to be performed.

To format and install the file system on a read/write optical disc, enter the following:

FORMAT D: /L


where drive D is designated as the optical disc drive.
Expert consulting for ArcaOS, OS/2 and eComStation
http://www.blondeguy.com

Dave Yeo

  • Hero Member
  • *****
  • Thank You
  • -Given: 11
  • -Receive: 149
  • Posts: 2115
    • View Profile
Re: How to Format a Hard Drive
« Reply #4 on: September 01, 2019, 07:11:08 am »
Wouldn't media testing involve writing known values and then reading them?
Could always use something like DFSee to read random sectors after a long format and see what is written there.

André Heldoorn

  • Hero Member
  • *****
  • Thank You
  • -Given: 117
  • -Receive: 19
  • Posts: 776
    • View Profile
Re: How to Format a Hard Drive
« Reply #5 on: September 01, 2019, 12:46:07 pm »
I seem to remember that it prevents chkdsk c: /F:3 from finding anything.

Not finding anything, including but not limited to the drive itself and errors!? :P

ISTR it's documented somewhere, takes quite long, and it prevents /F:3 from reporting (and repairing) an innocent error once. Testing should be simple: format a HPFS-drive without /L and execute CHKDSK x: /F:3. I cannot find the documentation quickly (HELP xxx, xxx /?).

My OS installer may be the documentation we'e talking about, because then the setting is an option (checkbox?) which comes down to a fast or slow format. I tend to use the slow setting, which seems to be a "full" format. About 20 minutes for a 2 GiB HPFS partition.
« Last Edit: September 01, 2019, 12:53:02 pm by André Heldoorn »

Neil Waldhauer

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 31
  • Posts: 460
    • View Profile
    • Blonde Guy
Re: How to Format a Hard Drive
« Reply #6 on: September 01, 2019, 04:56:24 pm »
The OS/2 help files were neglected as features like JFS were added. I thought it would be good to try formatting both with and without /L, and compare elapsed times. I found there was a substantial difference, so it is doing something. I used 10 GB volumes on a 2 TB hard drive.

Format /L results in a lot of errors:
Code: [Select]
Internal error: devices.c(532): Verify error 87 (INVALID PARAMETER)But the volume is available at the end in spite of the errors.

It turns out that you can browse the source of the OpenJFS project at Netlabs. The source no longer matches exactly the Arca Noae source, because line 532 of devices.c is a comment. But a few lines earlier in the source code, a routine named ujfs_rw_diskblocks is returning ERROR_INVALID_PARAMETER.

So it's clearly trying to do something different with FORMAT /L.
Expert consulting for ArcaOS, OS/2 and eComStation
http://www.blondeguy.com

Dave Yeo

  • Hero Member
  • *****
  • Thank You
  • -Given: 11
  • -Receive: 149
  • Posts: 2115
    • View Profile
Re: How to Format a Hard Drive
« Reply #7 on: September 01, 2019, 08:41:25 pm »
It takes way longer to format with /L here, at least on HPFS and JFS. Long enough that I believe it looks at every sector.
I once recovered a HPFS volume that I stupidly let Win2k access with pinball system (4.3 GB limit I didn't know about) by doing a regular format then running chkdsk /F:3 which recovered most everything except EA's, file names did get truncated to 15 chars.

Lars

  • Sr. Member
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 43
  • Posts: 419
    • View Profile
Re: How to Format a Hard Drive
« Reply #8 on: September 02, 2019, 11:36:41 am »
1) The parameters supported by "format.com" should be taken as "suggestive". They are more of a mutual agreement. They are passed verbatim to the corresponding FORMAT routine in the relevant DLL (UJFS.DLL, UHPFS.DLL etc.). But obviously, these parameters are distinct "per filesystem" and not "per drive type". Therefore, saying that /L was meant for "long format of optical drives" is not really accurate but rather a proposal of what it should do.

2) /F:3 for chkdsk means that even the free space is checked for errors / remainings of deleted files. If my assumption is right, this would mean that /L for JFS format means it will not only wipe the beginning of the partition (to wipe out whatever would interfere with JFS structures to manage directories and files) but would wipe the complete partition (for example, overwrite every single sector of the partition with zeros) before writing the necessary basic filesystem structures.
If "ujfs_rw_diskblocks" returns with ERROR_INVALID_PARAMETER, then my guess would be that the format routine is trying to access sectors that it should not. I would image that this could potentially happen if partitions are not cylinder aligned (which in the year 2019 is ridiculous but enforced by OS/2 up to this day) and the formatting routine tries to access sectors past the partition end.
« Last Edit: September 02, 2019, 12:05:53 pm by Lars »

Lars

  • Sr. Member
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 43
  • Posts: 419
    • View Profile
Re: How to Format a Hard Drive
« Reply #9 on: September 02, 2019, 12:01:03 pm »
Coming back to "ujfs_rw_diskblocks" returning with ERROR_INVALID_PARAMETER:
I had a look at the OpenJFS code and yes, "ujfs_rw_diskblocks" seems to work in units of "tracks". That would imply that a partition needs to be cylinder aligned at the partition start and partition end. If it is not, "ujfs_rw_diskblocks" will fail with ERROR_INVALID_PARAMETER because either the number of sectors to read/write/verify will not match the "sectors per track" or will potentially point past the partition or ahead of the partition start. All these cases will lead to ERROR_INVALID_PARAMETER in "ujfs_rw_diskblocks".
« Last Edit: September 02, 2019, 12:03:34 pm by Lars »

Lars

  • Sr. Member
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 43
  • Posts: 419
    • View Profile
Re: How to Format a Hard Drive
« Reply #10 on: September 02, 2019, 12:17:45 pm »
Forgot: judging from the error "Internal error: devices.c(532): Verify error 87 (INVALID PARAMETER)" I would also suspect that the /L parameter for JFS means to overwrite each sector (with zeros !?) and then to do an additional verify of each sector (what does that do ? Likely a readback to check if the sector was properly written, I forgot ...). Which would explain why the /L parameter will increase the formatting time substantially.