Page 1 of 1
Disk formatting
Posted: Fri Aug 29, 2008 4:14 am
by abhishekmaharana
When the disk is formatted,it is divided into (mostly) 512 byte sectors.There is a preamble,data part and trailer(ECC).So is the preamble and trailer a part of the 512 byte or is only data sector of 512 byte and preamble and trailer occupy extra space?
Re: Disk formatting
Posted: Fri Aug 29, 2008 2:53 pm
by Combuster
Those details only apply when you low-level format disks, which is close to never unless you have old SCSI hardware.
Fixed disks go in sectors and everything around them are invisible for any (non-extraterrestrial) hardware drivers. So whatever is there, you won't be able to access it, or get more space.
The only place where you can still do those things are floppy disks, which have all the gaps and data positions for you to play with. Different sector sizes FTW
Oh and BTW, no error correction there, try CDs for that one
Re: Disk formatting
Posted: Sat Aug 30, 2008 12:20 am
by abhishekmaharana
Combuster wrote:Those details only apply when you low-level format disks, which is close to never unless you have old SCSI hardware.
But I have a doubt.I may be wrong but when you say the above thing,do you mean to say that the preamble-data-trailer structure does not apply to non-SCSI(old) hardware?According to me,the structure applies to all and they are visible to only the disk controller. Even the disk controller uses it only for its purposes but only outputs the data part. Correct me if I am wrong.
Thanks and regards.
Re: Disk formatting
Posted: Sat Aug 30, 2008 5:17 am
by mathematician
The preamle is additional to the 512 bytes.
Re: Disk formatting
Posted: Sat Aug 30, 2008 8:02 am
by bewing
abhishekmaharana wrote:
According to me,the structure applies to all and they are visible to only the disk controller. Even the disk controller uses it only for its purposes but only outputs the data part.
Only to the
internal hardware controller. It is not visible to any external (PCI) disk controller. Or to
anything external.
The disk also uses PRML encoding. It has platters that have a layer of ruthenium. Many platters are made mainly of glass.
The point being -- why do you care about irrelevant internal details?
1. You cannot change the preamble-data-ECC encoding in any way.
2. You cannot turn it off.
3: You cannot overwrite it.
4. You cannot ever read it.
5. You will never see anything but data, no matter what you do -- unless you destroy a disk by taking it apart, and then examining it with an electron microscope (not particularly recommended).
So, you might as well just treat it as a device that only contains data in 512b sectors.
Re: Disk formatting
Posted: Sat Aug 30, 2008 10:41 pm
by Brendan
Hi,
Just a quick note: For floppy disks and ATA/IDE hard disks (and maybe ATAPI and SCSI - I didn't check) there's "read long" and "write long" commands that can be used to read and write some of the preamble data in addition to the sector data itself.
AFAIK once upon a time this was used sometimes for copy protection schemes for floppy disks (so that software can detect if it's running from a copied floppy or the original floppy). It might also be useful for disk recovery purposes (e.g. trying to recover data if the disk becomes damaged).
I'm not sure if it can be (ab)used for other purposes, although for floppies it might be useful for auto-detecting the format (without relying on DOS's "BIOS Parameter Block", which doesn't support some advanced/non-standard floppy disk formats).
I'm also not sure if it actually works on ATA/IDE because some of the information that the hard drive tells the controller/OS is virtualized - for e.g. any CHS information that's returned may be an illusion (I wouldn't assume that each track on a hard drive has the same number of sectors, or that the preamble data structure contains fields that are large enough for modern drives). I'm also not sure if the format of the preamble is the same for all hard drives or if it's a proprietory (hard drive specific) structure.
Cheers,
Brendan
Re: Disk formatting
Posted: Tue Nov 18, 2008 7:09 pm
by Love4Boobies
Brendan wrote:For floppy disks and ATA/IDE hard disks (and maybe ATAPI and SCSI - I didn't check) there's "read long" and "write long" commands that can be used to read and write some of the preamble data in addition to the sector data itself.
You have such commands for SCSI drives. But I'm pretty sure you don't for IDE and ATAPI.
Re: Disk formatting
Posted: Tue Nov 18, 2008 9:17 pm
by Brendan
Hi,
Love4Boobies wrote:You have such commands for SCSI drives. But I'm pretty sure you don't for IDE and ATAPI.
For IDE/ATA it did exist. From "Information technology - AT Attachment Interface with Extensions (ATA-2)":
8.18. READ LONG (with retries and without retries)
OPCODE - 22h (with retries) or 23h (without retries)
TYPE - Optional.
PROTOCOL - PIO data in.
INPUTS - The Cylinder Low, Cylinder High, Device/Head and Sector Number specify
the starting sector address to be read. The Sector Count register shall not
specify a value other than 1.
NORMAL OUTPUTS - None required.
ERROR OUTPUTS - Aborted Command if the command is not supported. An
unrecoverable error encountered during the execution of this command results in
the termination of the command and the Command Block registers contain the
sector address of the sector where the first unrecoverable error occurred.
PREREQUISITES - The SET FEATURES subcommand to enable more than 4 vendor
specific bytes shall be executed prior to the READ LONG command if other than 4
vendor specific bytes are to be transferred.
DESCRIPTION - The READ LONG command performs similarly to the READ SECTOR(S)
command except that it returns the data and a number of vendor specific bytes
appended to the data field of the desired sector. During a READ LONG command,
the device does not check to determine if there has been a data error. Only
single sector read long operations are supported.
The transfer of the vendor specific bytes shall be one byte at a time over bits
DD0-7 only (8-bits wide).
The with retries and without retries versions of this command differ in
operation only in the level of error recovery performed by the device. The
level of error recovery performed by the device for either command is vendor
specific.
Note: Some ATA-1 devices are not capable of delivering the 8 bit ECC
immediately after the word sector data. BIOS and driver developers should use
PIO mode 0 for 8 bit ECC accesses.
Ralph Brown's Interrupt List says this command is "required" (but as usual, doesn't contain enough information to determine which specifications consider the command required).
However, "Information Technology - AT Attachment with Packet Interface - 6 (ATA/ATAPI-6)" says that this command is obsolete (and all the other "read/write long with/without retries" commands). I'm not sure exactly when they became obsolete - ATA-3 includes the command, but has a note saying "The committee is considering removing read long and write long commands in a future ATA standard", so I'm guessing it became obsolete in ATA-4, ATA-5 or ATA-6.
Cheers,
Brendan