Trying to understand how / is mounted - Embedded

This is a discussion on Trying to understand how / is mounted - Embedded ; 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 ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: Trying to understand how / is mounted

  1. 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

  2. Re: Trying to understand how / is mounted

    CptDondo wrote:
    > 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


    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

  3. Re: Trying to understand how / is mounted

    Tauno Voipio wrote:

    > 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.
    >


    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

  4. Re: Trying to understand how / is mounted

    CptDondo writes:

    >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?


    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.



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

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


    >Could someone please explain this behavior?


    >Thanks,


    >--Yan


  5. Re: Trying to understand how / is mounted

    '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 Thread