Trying to understand how / is mounted

I have a small, self-built linux 'distro' for an embedded box I am working with.

Because the power is extremely unreliable, I am mounting / read only, and creating /tmp and /var on ramdisks.

All this works just fine, the board boots and runs.

I am a bit confused, though, about the boot process itself.

I tried using 'ro root=/dev/hda1' on the kernel parameter line, thinking that this would ensure that the drive would be mounted read only. No - it was mounted rw.

So... I added

mount -o remount,ro /

to my startup script and it is mounted ro.

So why didn't the kernel mount it ro in the first place? Why did it mount it rw even though I said 'ro' on the kernel parameter line?

My startup script is the only thing that runs on startup, and nowhere do I mount / rw....

Could someone please explain this behavior?

Thanks,

--Yan

Reply to
CptDondo
Loading thread data ...

If you're running init with the usual startup scripts, check that none of them does the remount. The kernel does not do it without being commanded to do so.

--

Tauno Voipio
tauno voipio (at) iki fi
Reply to
Tauno Voipio

I'm running a stripped-down busybox implementation with my own startup script....

I'll go through the startup stuff a line at a time - again.

It's good to know that it is not the kernel doing something bizarre.

--Yan

Reply to
CptDondo

Because the process uses /etc/fstab to figure out how the partitions should be mounted. Make the line in /etc/fstab for the / partition read ro in the options.

The system reads /etc/fstab and mounts all local stuff first and then nfs mounts later.

Reply to
Unruh

'ro root=/dev/hda1' controls the mounting of the root file system for 'stage 1' of the boot process. Once the kernel and drivers are fully loaded into memory than the system executes the code in /etc/init.d (driven by /etc/rc*.d in Debian). If you looked carefully there you would find a script that executes your /etc/fstab. You can insert your own code before this to manage the mount of the filesystems, etc. But it is better to just rewrite your /etc/fstab so that the drives are mounted ro instead of rw

David Tucker

Reply to
david.tucker

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.