The question maybe odd but i didn´t find any explanation to it, so:

Sevreral tools for generating rootfs use fakeroot in order to fake the permissions, create the rootfs and then archive it. After that when the archive will be extracted it will be seen by the kernel as having root ownership.

My question is why the linux kernel expects that the rootfs has root ownership?

  • What makes you think that the kernel expects this? – JdeBP Oct 10 '17 at 5:11
  • @JdeBP, because if the ownership of the rootfs is different than root, the kernel will fail to mount it. – Mouin Oct 10 '17 at 7:04
  • The vanilla kernel has no such restriction, to my knowledge. So again: What makes you think that the kernel expects this? What error message have you seen, and where? – JdeBP Oct 10 '17 at 10:12

Because otherwise the owner of the root directory would be able to escalate privileges to root, f.i. by renaming /etc and creating a new one, and a new /etc/passwd.

  • I am not sure to understand, but what i mean is that the kernel fails to mount the rootfs if it s not root – Mouin Oct 10 '17 at 7:26
  • You asked why does the kernel do that, I gave you a plausible reason. Is that the definitive answer? No idea, you'll have to ask Linus for that. shrug – Satō Katsura Oct 10 '17 at 7:30

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.