Is it possible to remove sectors from a disk?

1

1

My question is a simple one, I think, but I could not find an answer on the internet (2h search time...): I want to remove to concept of sectors from one of my hdds?

If you think, this question is not explained well, let me try to re-ask this question differently: How does my computer/hdd know when a sector begins, an when a sector ends? Is it physically pressed in the disk? Or is it a counting thing, arrived from some controll united on the board in the hdd?

Thank you in advance! :)

The Array

Posted 2019-10-13T20:16:25.837

Reputation: 29

3Why do you want to do this? What kind of drive? – music2myear – 2019-10-13T20:51:23.160

1“My question is a simple one…” Nope. As the answers provided below demonstrate, this not a simple task. And the benefits seem dubious at best. Unless there is a clear core reason for you wanting to do this, you really can’t. – JakeGould – 2019-10-14T03:22:44.600

Answers

2

How does my computer/hdd know when a sector begins, an when a sector ends?

Start with floppies, since they are simpler and have tracks and sectors like hard drives.

All disk drives function with these capabilities:

  • turn motor on/off
  • move head to a certain track somehow
  • head read mode: generate a signal when it runs over a flux change, wherever it is on the disk.
  • head write mode: generate a flux change wherever it is on the disk.

How to detect when a sector starts?

There wasn't a single method, until 3.5" disks and the IBM PC became ubiquitous and created a de facto standard.

Here's an excerpt from the Wikipedia article on floppy discs:

All 8 inch and some ​5 1⁄4-inch drives used a mechanical method to locate sectors, known as either hard sectors or soft sectors, and is the purpose of the small hole in the jacket, off to the side of the spindle hole. A light beam sensor detects when a punched hole in the disk is visible through the hole in the jacket.

For a soft-sectored disk, there is only a single hole, which is used to locate the first sector of each track. Clock timing is then used to find the other sectors behind it, which requires precise speed regulation of the drive motor.

For a hard-sectored disk, there are many holes, one for each sector row, plus an additional hole in a half-sector position, that is used to indicate sector zero.

The Apple II computer system is notable in that it did not have an index hole sensor and ignored the presence of hard or soft sectoring. Instead it used special repeating data synchronization patterns written to the disk between each sector, to assist the computer in finding and synchronizing with the data in each track.

Apple II is a well-known 8-bit computer that was first sold in 1978 and predates the IBM PC era. The Apple II is famous for doing as much in software as possible and with as few chips as possible, which resulted in a system where the CPU had to control the floppy disk head and reading/writing data from it on a low-level, and where luxuries like a chip to detect holes in the disk weren't used. The hardware connected to the disk is primitive and expected to be mostly driven by the CPU.

On Apple II you could not read/write the disk and run programs at the same time (you couldn't do this on most CP/M machines of that era either, also 8-bit machines).

So how exactly did that old Apple II read and write to a disk? More than you probably every wanted to know about those gory details are right here starting at chapter 3. It's getting heavy into timing patterns and such, but essentially each sector begins with a unique "prologue" that is detectable when the system's trying to find a sector, and does not ever appear anywhere else. An encoding scheme is used to write out the actual data, and it takes more space than the number of bits. There is also an "epilogue" at the end of the sector. Essentially the Apple II was its own controller for the disks.

Each sector is tagged with its number so the system can scan each sector and then read in the one it wants. This tag is not part of the sector data and is written when the disk is formatted.

The later ​3 1⁄2-inch drives of the mid-1980s did not use sector index holes but instead also used synchronization patterns.

When the IBM PC came to market in 1981 (before 3.5" drives but during the 5" drive era), you could get a controller card for one or more floppy drives. This enabled the computer to ask the controller card for a track and sector, and not have to control the head and data stream directly. So programmers now dealt with a far more abstracted view. All the stuff described in chapter 3 of that Apple II reference above is something the controller does on IBM PC hardware. So programmers just had to worry about talking to the controller and not things like sector prologues, sync patterns, etc. Programming the PC floppy controller is still complex but it can do most of its work separately from the CPU.

FWIW IBM PC floppy drives also have additional data around the sector data and tag the sectors with CRC and other info.

So ... on the Apple II ....

  • Could you overwrite the prologue of a sector and erase the sector? Yes. The Apple DOS software would probably just hang when asked for a missing sector - it would go to the track it believes it should be and probably just read sectors forever looking for it.

  • Could you create your own disk routines and make really long sectors or make a whole track that's a single sector? Yes.

Many developers on the Apple II platform created custom formats to prevent copying.

Can you do this on a modern computer? On a hard drive? The answer is NO because you can only tell the controller to run commands, and some of those commands are "read sector", "write sector" but you don't have commands like "turn drive head on/off" and it probably wouldn't be possible to send commands fast enough to read/write at modern densities anyway.

Hard drives have their own integrated controllers (hence the term "IDE" for "Integrated Drive Electronics"). So low-level information like the above is only known by the device manufacturer.

You don't have control of the drive head like you do on older computers that didn't have controllers. So you are stuck with what the drive controller lets you do which is not fun actual low-level stuff.

LawrenceC

Posted 2019-10-13T20:16:25.837

Reputation: 63 487

Thank you so much for answering. You said, it isn't possible. But, I hope, I did not forget to read a part including this, would this mean, that on modern drives, the first sector would always have 512 bytes? I think, that would mean, that with that first sector (including mbr or sth) the disk/computer knows the sector sizes of the disk. – The Array – 2019-10-14T15:45:16.133

512 I believe is something just assumed because the PC floppy in 1981 did it and then everything became compatible with the PC. Newer hard drives can do 4096-byte sectors (and they can emulate 512 byte sectors in firmware for compatibility), and optical media is based on 2048-byte sectors - again something just assumed if you are dealing with a CD-ROM. – LawrenceC – 2019-10-14T17:42:06.057

0

Actually this question is not as absurd as it might seem: There is no actual technical reason to disallow a block size of 1 which would effectivly create a non-blocked device, as long as it is a spinning-rust type.

That said, let me give a few basic facts about hdd sectors for the benefit of the original poster:

  • The reason, why disks are organized in sectors (or better: blocks) is performance: Not only is it much faster to address a block of storage then a single byte in it, it is also much easier to count them. The reason, why old hard- and software often comes with a 2TB/Volume size limit is, that counting blocks of 512 bytes each with a 32bit counter results in ... 2TB. 512 bytes/block in earlier days and 4K/block on modern hardware have become so ubiquitous, that many OSes will have a hard time dealing with different values (including the value 1)

  • Many vendors (e.g. NetApp) chose a 520 byte/block unit ("sector size 520") as they want to store a "normal" sector of 512 bytes and a checksum.

  • While hard-sectored disks (i.e. disks, where the secotrs were actually physically marked on the disk) existed in early history, all newer hardware uses soft-sectoring, i.e. the sectors are marked on the disk by writing to the disk. This makes it possible to reformat e.g. NetApp disks with a sector size of 520, that are unusable under Windows and Linux, into bog-standard 512 bytes/sector disks that work fine.

Eugen Rieck

Posted 2019-10-13T20:16:25.837

Reputation: 15 128

1"There is no actual technical reason to disallow a block size of 1" -- False. Most of the (unformatted) disk capacity would be used/wasted as gaps rather than actual storage of data. Your answer treats an HDD almost as if it were a block box. In fact it uses magnetic media, which makes writing data far more complicated than you probably imagine, e.g. the need for a write splice in the gap. – sawdust – 2019-10-14T05:33:32.737

I said, that the blocking is for performance reasons - and space efficiency is nothing else then an aspect of performance. A NetApp SAS HDD works fine reformated to a block size of 1 under BSD (of course with reduced capacity and speed). – Eugen Rieck – 2019-10-14T07:20:11.373

0

Is it possible to remove sectors from a disk?

No.
To be clear we are referring to a fixed-sized block of data storage on a magnetic platter.
Be sure you understand the purpose of disk sectors, in particular:

Reading and writing data on a magnetic medium requires that the medium to be moving, and that the erase & write heads be turned on and off away from existing data. So the disk data is always written and read in units of a sector (or more precisely a data record) in order to preserve the layout (or format) of each track.

Sectors of a HDD are actually a simplification of older HDD interfaces.
Disk interfaces such as SMD (storage module drive) allowed variable "sector" sizes on each/any track.
Each "sector" consisted of an identification record (of fixed length) and a data record (of length declared in the ID record).
In theory you could have just one "sector" to cover the "whole" track, or alternate short "sectors" with long "sectors". The former is impractical for data transfer & buffering as well as data integrity reasons. The latter scheme is impractical as it complicates the data transfer & buffering requirements.

Making the size of every "sector" of the drive uniform is a simplification for the software.
Disk controllers (hard disks as as well as floppy controllers) refer to this (low-level) formatting scheme as soft sectors.

When the IBM PC was introduced, its implementers made another simplification by fixing the "sector" size to 512 bytes.
Prior to this IBM PC convention, sector sizes of 128, 256 and 1024 bytes were also used.

As IBM PC compatibility became a de-facto standard, so did the 512-byte sector.
The soft-sectoring capability in hard/flexible disk controllers that allowed an alternate sector size became a useless feature.
Hence "hard sector" controller/drives that only operated with 512-byte sectors became standard in the PC market.
As the PC began to dominate the rest of the computer market, so did the "standardization" of the 512-byte sector.
As drive capacity increased, the size of the physical sector (on the platter) was increased to 4096 bytes.
The use of zoned-bit recording brought back soft sectoring so that the number of sectors per track could be varied. But low-level formatting was removed as a controller capability.

See this answer that describes in detail how a sector is written.

Since the electro-mechanics of the drive limit reading or writing to one track at a time, continuous reading or writing to span tracks is not feasible.
So the concept of a "sector" to transfer and read/write this block of data constrains its size to one track.

Reducing the "sector" size to a much smaller quantity such as one byte is impractical.
The gaps (see the linked answer) necessary to support writing and reading such as tiny quantity of data would waste 90% or more of the capacity of the magnetic medium.

How does my computer/hdd know when a sector begins, an when a sector ends?

That is up to the disk controller and drive.
On modern HDDs, starting with IDE drives, the controller is built-in with the HDD.

Is it physically pressed in the disk?

No, the magnetic disk surface must be as smooth as possible.
Sectors can be timed (e.g. a servo track) or recorded (i.e. an ID record that precedes the data record).

Or is it a counting thing, arrived from some controll united on the board in the hdd?

See above and/or the link.

sawdust

Posted 2019-10-13T20:16:25.837

Reputation: 14 697