1

Device drivers and device initialization starts when the kernel goes through the initramfs bridge; the initramfs contains the initial modules needed to set up the devices including the storage device on which the real root filesystem resides.

My question is, does the init script in initramfs after loading the relevant modules into the kernel mount the root filesystem on / in read-only mode ro?

Unfortunately, I can't read shell scripts, but it seems that fsck runs from /init, but I can't say with certainty.

Last but not least, where does the root filesystem get remounted in rw mode? Possibly in /sbin/init?

Zanna
  • 70,465
direprobs
  • 285
  • Do you mean your system is raising up with unwriteable root folder? If this is, look if your /etc/fstab matches to your partitions UUID. Look at https://askubuntu.com/questions/947407/partial-upgrade-to-16-04-3-lts-error-cannot-create-wakeup – Redbob Aug 24 '17 at 21:57
  • Well /sbin/init in the initramfs would mount the "real root" and switch to it, unless it is pointed to a shell or so. It's not necessarily a shell script though. Neither would it necessarily mount it in ro mode and need a remount (you can instruct that with boot parameter ro/rw). If you instructed it to mount in ro mode, fsck on the "real root" is supposed to be performed after switching root and rw remount takes place after that. It is done by whatever handles the fstab as per it. – Tom Yan Aug 24 '17 at 23:19
  • @TomYan It's a mayhem. I've unpacked initrd.img and there was no /sbin/init. There's only /init which is obviously executed once the kernel finishes device initialization. I could tell now, why it's boring to try to figure it out what fits where. – direprobs Aug 25 '17 at 08:35
  • Actually I was wrong. There are rdinit= and init= for setting the init to run in initramfs root and real root. The fallback value for rdinit= is /init, while one of the fallback values for init= is /sbin/init. – Tom Yan Aug 25 '17 at 08:59
  • /init is usually a shell script in initramfs. I (think) after going through its lines, it mounts real the root filesystem. Basically this chain goes like this: /init --> /sbin/init where /init in initramfs and /sbin/init in the real filesystem. – direprobs Aug 25 '17 at 09:05

0 Answers0