1

Understanding the Linux Kernel says

The first block in each Ext2 partition is never managed by the Ext2 filesystem, because it is reserved for the partition boot sector.

As far as I heard, a block and a sector are not the same concept on a hard drive. A block usually consists of a number of sectors.

The first block in a partition is called a boot block. It is not a sector, so not called a boot sector.

The first sector in a disk is MBR, which is a sector not a block.

Is my understanding correct? How shall I understand their usages in the quote?

Thanks.

  • Well, really suggest you read the context every time you meet these words. – 炸鱼薯条德里克 Feb 21 at 7:36
  • Can you elaborate specifically for this post? – Tim Feb 21 at 11:51
  • Because different documents will use different names for the same thing or the same name for different things. Very confusing, but you have to accept it, it's really hard for human to get a consensus. Based on your quote, sector means logical sector of your hard disk, while block is the basic unit when operating on the filesystem. The latter can't be larger than former. – 炸鱼薯条德里克 Feb 21 at 11:57
  • Based on this naming convention, Partition can't have blocks, it only have sectors because it's just part of the disk. Within Itself really doesn't exist too much complex data structure. But filesystem have to use multiple sectors as one block as basic unit, so what filesystem do is it doesn't touch the first block, to ensure the first sector of the containing partition is not touched. – 炸鱼薯条德里克 Feb 21 at 12:16
3

It's considering a case where there's some bootloader type stuff in the start of the partition itself, not just in MBR (which is outside partitions). There's a potential overlap there, so the filesystem leaves some leeway for the boot stuff.

A sector there refers to a 512-byte unit, and the filesystem block is likely to be larger, usually 4096 bytes. But it's not useful to shift the filesystem blocks by such a small amount, so the filesystem just leaves the whole first block unused. Even though it's bigger than the 512 bytes required, it allows the rest of the blocks to be aligned to the block size.

(Of course, all that is a bit dated. Current hard drives actually have 4096-byte sectors, and with GPT and EFI, there shouldn't be need to store boot files in the partitions, overlapping the filesystem.)

  • Thanks. "the filesystem just leaves the whole first block unused". Does first sector in the boot block store boot information, while the rest of the boot block is empty for alignment purpose? – Tim Feb 20 at 20:41
  • @Tim, it really depends on filesystem, some filesystem might even not touch the first few blocks to support bootloader code embedding, while some other might just not touch the first block, and start to store meaningful fields in the second block. In such case, especially when bootloader code is too big, embedding would fail or even break the filesystem. – 炸鱼薯条德里克 Feb 21 at 12:20
  • Such scheme is so unreliable, so we finally design the UEFI, which store bootloader as a file in the ESP, and never use those old and painful bootloader chain anymore. – 炸鱼薯条德里克 Feb 21 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.