The directories /proc and /sys have inode value 1 even though it means "bad block". Both of them are functioning and I have another linux machine that in addition to these two, /boot also has inode 1.

adam@AdamMobile:/$ ls -i
 1179649 bin           2 dev           25034753 home            22675457 lib         12058625 media         1 proc  10092545 sbin        12 swapfile   8912897 usr            14 vmlinuz.old
12713985 boot         15 device-clean        13 initrd.img       9961473 lib64       25165825 mnt    13500417 root   7733249 snap         1 sys        2621441 var
20578305 cdrom  23330817 etc                 17 initrd.img.old        11 lost+found   1441793 opt           2 run   23592961 srv   18743297 tmp             18 vmlinuz

Why do they have inode 1?

| |

Inode structure is part of filesystem design. The assumption that inodes 1–10 are reserved is specific to UFS and derivatives (including Linux ext2/ext3/ext4), and does not necessarily apply to filesystems that were independently designed.

All three locations you mentioned are mountpoints for different filesystems (use findmnt to find out).

  • For example, /boot is frequently where a FAT32 filesystem (the EFI system partition) is mounted. The FAT filesystems don't have inode numbers as such (the kernel has to show fake inode numbers); they do mark bad sectors in the 'cluster map'.

  • /proc and /sys are entirely virtual (kernel-generated) filesystems, procfs and sysfs, and do not even have the concept of "bad blocks" and "reserved inodes" as they're not actually on-disk filesystems.

  • Other filesystems still work differently. For example, NTFS uses inode 8 (a real hidden file named $BadClus) to reserve bad sectors. Btrfs doesn't track bad sectors entirely.

| |
  • I believe the term for NTFS is "file id". When you say "NTFS uses inode 8", do you mean the filesystem itself uses file id 8? Or maybe the file id for $BadClus can be different but it's Linux driver who always maps inode 8 to $BadClus? – Kamil Maciorowski Jun 30 '19 at 8:44
  • @KamilMaciorowski: No, it's always the 8th record in the NTFS MFT. It has a name but programs still access it by its ID. (e.g. ntfsprogs does ntfs_inode_open(vol, FILE_BadClus);) – user1686 Jun 30 '19 at 8:52
  • Another question is how the kernel can differentiate between files with the same inode? /dev, /run and / have inode 2. I also thank you for the quick answer. – Adam Katav Jun 30 '19 at 17:22
  • It recognizes that this is a different filesystem mounted from a different device, i.e.. at minimum it uses inum+devno together. (Imagine if you had two disks formatted with ext4, and they both had inode 1, inode 2, ...) – user1686 Jun 30 '19 at 20:04

inode value 1 even though it means "bad block"

In ext4 "list of defective blocks" actually. But it's for ext4. Each filesystem type can reserve some special inodes in its own way.

The mountpoints in question hold some other filesystems (pseudo-filesystems): /proc is of type proc and /sys is of type sysfs. You can see this by invoking mount without arguments.

I guess /boot on the other machine is not on ext4.

| |

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.