I know that a sector is the unit in which a track is splitted, but I had this doubt since I was looking for information about the maximum number of pointers that an inode can support. I found that this number depends of the block size. Is this size variable? Is this size maintained when the computer is switched off?
-
1Sector describes an actual physical area. The meaning of "block" depends on the context, and may be prefixed with a descriptor such as "physical" or "logical". Seems like you are reading about a "block" in the context of a filesystem?– sawdustAug 5, 2016 at 22:23
-
Yes, I´m now studying the structure of a disk in a Unix system.– albertoAug 6, 2016 at 10:22
-
See also: What is the difference between sector and cluster?– hippietrailJun 21, 2020 at 13:45
-
@sawdust: There are also physical and logical sectors due to sector skew/interleave.– hippietrailJun 21, 2020 at 13:52
-
@hippietrail -- No, not really. Sector interleaving and skew were only done when the processor is slower than the media, e.g. cheap & very slow uP with floppy. There is no physical sector numbering versus logical sector numbering when sectors are interleaved or skewed. There is no mapping between logical to physical sectors. The interleave and skew whould be encoded into the track when it is formatted. There would be only a single sector #2 on the track that the controller could write or read. There is no distinction of a physical or logical sector just because of interleaving or skew.– sawdustJun 22, 2020 at 4:48
1 Answer
Once a file system is established the block size remains the same. Some partitioning tools can change this after the fact, but not while the OS is running.
A sector has traditional been a fixed 512 byte size, but a few drives have 4096 bytes sectors.
A sector is the smallest individual reference-able regions on a disk.
The block size refers to the allocation size the file system uses. The common options are 512, 1024, 2048, 4096, 8192, 16384, or 32678. Generally anything larger would be so inefficient nobody would use it, and you can't go smaller than 1 disk sector.
Sure you can write 10 bytes to a file, but behind the scenes it is allocated 1 block whether you use it all or not.
-
So... the blocks´ size can be changed modifying the filesystem right? Two more questions, that in fact are more or less the same: the inode table has always the same size? The number of pointers to disk blocks is also always the same? I suppose the inode table adapts its size to the size of the filesystem to support all the free space, but I wasn´t sure about that– albertoAug 5, 2016 at 20:51
-
"The number of pointers to..." Each file and folder has a pointer to a block, when a new file/folder is added it is assigned an unused block. The total number of block is determined by the disk size/block size. So if you re-partition the total blocks could increase or decrease, but online off line. The size of the inode table is determined, by the number and size of the files it is storing. The free space has no inodes pointing to them. Aug 5, 2016 at 21:41
-
1Technically a file system block can be smaller than a storage block. Such might even almost make sense if the page size supported by hardware was smaller than the sector size of storage. (Packing more than one file/object into a sector, i.e., treating such as a special case, might be more attractive.) The other portion of the sector would be considered a prefetch on a read; writes are somewhat more problematic since a smaller block size could sometimes require a read of the rest of the sector. Still it is a theoretical possibility.– user180742Aug 6, 2016 at 0:12
-
It it theoretical possible as you say, but given the standard sector size of 512 bytes for decades, I have never seen that implemented. I have studied the efficiency (typical), and usually a 512 byte block size results in %0.2 to %1 of the drive being wasted. The filesystem overhead increases dramatically when you go below 512 bytes so much so you probably lose more than the <1% you would have lost with the 512 byte block size. The industry generally agrees 4k is the right size, which is why some new hard drives have 4k sectors. Aug 6, 2016 at 0:45