Disk formatting
-
- Posts: 16
- Joined: Sat Aug 23, 2008 4:13 am
Disk formatting
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?
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Disk formatting
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
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
-
- Posts: 16
- Joined: Sat Aug 23, 2008 4:13 am
Re: Disk formatting
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.Combuster wrote:Those details only apply when you low-level format disks, which is close to never unless you have old SCSI hardware.
Thanks and regards.
- mathematician
- Member
- Posts: 437
- Joined: Fri Dec 15, 2006 5:26 pm
- Location: Church Stretton Uk
Re: Disk formatting
The preamle is additional to the 512 bytes.
Re: Disk formatting
Only to the internal hardware controller. It is not visible to any external (PCI) disk controller. Or to anything external.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.
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
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
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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Disk formatting
You have such commands for SCSI drives. But I'm pretty sure you don't for IDE and ATAPI.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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Disk formatting
Hi,
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
For IDE/ATA it did exist. From "Information technology - AT Attachment Interface with Extensions (ATA-2)":Love4Boobies wrote:You have such commands for SCSI drives. But I'm pretty sure you don't for IDE and ATAPI.
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).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.
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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.