View Full Version : Why use bytes and not sectors ?
klitsuk
08-13-2004, 06:57 PM
Hi there.
i was reading about operation systems and hard drives and much much more and i have this one huge question that i just don't get : as you know the units on a hard drive are sectors of 512 bytes. Additionaly the sectors are also added into clusters. Lets assume that my clusters are 4kb each. i have a a 2kb file and a 3kb file. however they both will take one cluster in the memory. so what difference how many kb does my file takes, shouldn't i say how many clusters my file takes? or even sectors but why use bytes ?
Paleo Pete
08-14-2004, 03:23 AM
Because you still have to have a descriptor for the smaller size of the file, whether it homesteads more actual disk space or not.
Look at it from another perspective...Most people think about distances in terms of inches, feet, yards and miles. Your pencil might be 4 inches long, after a few sharpenings. Your living room might be 12 feet across, you might drive 7 miles to work.
I'm a former machinist. For 8 years I dealt with distances of thousandths of an inch. Your 4 inch pencil might be "just a bit over 4 inches" to you, but to me it's 4.187" (4 3/16"). Why would you need the .187 part? Why not just consider it slightly over 4 inches? Or round it off to 4 inches? Just say about 4 inches?
Because if I were to need to draw a blueprint of that pencil for some reason, I'd need to know the exact length, within .001" (one thousandth), not a close guesstimate. And it still writes, whether you see inches or thousandths, or even if you just see a short pencil, forget about length. My blueprint would still show thousandths of an inch, even though you might not be able to tell it's a few thousandths over or under a certain length...or care...
Same for file sizes. To you, or your hard drive, partitioned to one 60GB partition let's say, a 4 KB file would still take up 32K of a FAT 32 partition, 64K of a NTFS partition. But to the programmer who wrote that program, trying to keep the total file size down, every 4KB file matters. A dozen of those adds up quick.
Your hard drive also still holds a finite total amount of data, measured in those terms. Whether it's actually holding a few megabytes less in real world usage, it still is capable of storing a certain number of bytes. The actual total storage potential also changes with partition size and file system, since cluster size changes as partitions get bigger. Cluster Size Comparison (http://web.ukonline.co.uk/cook/Clustsize.htm)
That also means a 20GB drive set up with 4 partitions will hold more total clusters than the same drive set up with one large partition, while still theoretically holding 20GB of data either way. That would make it impossible for a manufacturer to offer a drive that can handle a certain, specific number of clusters, soon as you change partitioning and/or file system the total number of clusters changes.
I hope that makes a little sense...
By the way, when I hit Google and looked up "cluster size", guess where the Second Result (http://www.pcguide.com/ref/hdd/file/partCluster-c.html) came from...
ziba-june
08-14-2004, 06:17 PM
That was intersting. It is like going to grocery store and ask the butcher for 2 packages of fish and 2 packages of ground beef. Depend on what store you are at and who is your butcher, you will get different amount of fish and beef. While if you ask for 2lb of fish and 1lb of ground beef, you will get the same amount no matter where you buy them from.
So depend on your OS, Hard drive partition size ,and file allocation system(FAT16, Fat32, NTFS), you are getting different amount of bytes per cluster.
klitsuk
08-19-2004, 03:14 PM
thank you both (up till now) for showing me that point of view. i didn't think about it.
however, can you please tell me why not to talk in sectors then. i understand that each OS, or HD size will have it's on cluster byte length, however sectors are always 512 bytes nevermind the OS or partition size... why can't we talk in terms of sectors then?
Paleo Pete
08-20-2004, 01:32 AM
why can't we talk in terms of sectors then?
OK, can you think in terms of pie slices then? Seriously...that's how a hard drive is laid out. An old LP album cut into pie slices. Each sector is a slightly smaller one than the one outside it, but the ones to each side are the same size, physically...What the computer sees is 512 bytes, numerically addressed to different physical sections of the platter, laid out in concentric rings and cut into sections like pie slices. One of those peices of each ring is a sector. Each sector is 512 bytes, but I don't know why. That's what the computer gods decreed I suppose... :D
If you draw it out, it might make more sense, or if you can get a mental image of a pie or pizza also cut into round sections, as well as the usual wedges...Concentric rings...
Paul Komski
08-20-2004, 05:57 PM
Sectors are usually but not always 512 bytes; that is just by far the most common unit used by all the common operating systems and formatting utilities using magnetic media.
Sectors are in any case virtual areas of any HDD and not physical areas of 512 bytes. In fact even the bytes themselves are virtual. At the most basic level there are no lovely discrete physical areas that our human minds can correlate into noughts and ones - much as our human minds would like to do so.
So HDDs are not divided into discrete 0s and 1s nor indeed into discrete sectors and the way in which data is written and read is done by the chips on the hardware using "transitions" and "radio-frequency" signals.
A bit is the smallest programmable value of any binary system.
A byte is the smallest unit of bits used by any system and is usually 8 bits in size. Most systems use simple multiples of such bytes to produce 16, 32 and 64 bit addresses and values. The individual bits inside a byte can also be used individually or in groups - such as nibbles - or even parts of nibbles.
A sector is the smallest block of data that can be read/written "in one go" on magnetic media. Even if you edit one byte, all 512 bytes in that sector get re-written at the same time. Sectors are also used as the basic way of organising addresses on a HDD or Partition or Array or Volume on such devices. Optical drives don't use 512 bytes in the same way that magnetic devices do. That is not because of anything physical; it is just that there is more inherent redundancy needed because, for one thing, error checking is much more important on such media.
Clusters (or File Allocation Units) were initially introduced to allow larger HDDs to be used by older operating systems. The older systems and the older way in which HDD geometry was mapped meant that there was a finite maximum number of units that could be used. Grouping together a fixed number of sectors per cluster allowed for more total data to be incorporated into large partitions and drives. There were other benefits and disadvantages but this was the pre-eminent reason for introducing clusters as a concept and tying together a number of sectors. Small clusters may waste less data but are inherently less efficient since there will be so many of them to be dealt with.
Whether data is measured in bits, bytes, sectors or clusters doesn't really matter from a mathematical concept at all - any more than measuring volume in ccs, pints, litres or gallons does. There is however a base unit of data - the bit - whereas there is no base unit of water. So a gallon barrel can contain any intermediate amount of water whereas a sector of data can only hold a finite and discrete number of bits.
So, in a nutshell, its all really virtual and mathematical in nature - though there are historical and real hardware and software reasons for talking about data in these different terms.
Machine code only really cares about bits; most windows programs only really care about bytes; the hard drive cares about sectors; the file system cares about clusters (file allocation units) and I care about a good pint of Guinness!
vBulletin v3.6.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.