Search code examples
linuxlinux-kernelfilesystemsembedded-linuxmount

Difference between / and /mnt/upgrade if mounted on different partitions


I have a 512 MB NAND flash which has 7 partitions. The rootfs of UBIFS type is mounted on 4th partition (mtdblock03). It also has an upgrade partition of UBIFS type and mounted on 6th partition (mtdblock06). The information displayed after mount command is :

root@freescale ~$ mount
rootfs on / type rootfs (rw)
ubi0:gpmi-nfc-general-use on / type ubifs (rw,relatime)
proc on /proc type proc (rw,relatime)
sys on /sys type sysfs (rw,relatime)
tmpfs on /dev type tmpfs (rw,relatime,mode=755)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620)
shm on /dev/shm type tmpfs (rw,relatime)
rwfs on /mnt/rwfs type tmpfs (rw,relatime,size=512k)
ubi1:upgrade on /mnt/upgrade type ubifs (rw,relatime)

My question is, when upgrade is on /mnt/upgrade, weather it will not be a part of /. As whole of the / is in (mtdblock03), so /mnt/upgrade shall be a part of (mtdblock03) rather than (mtdblock06)?


Solution

  • No. /mnt/upgrade is NOT part of mtdblock03.

    / and /mnt/upgrade are all virtual points in a virtual filesystem, which is only a virtual map to the underlying physical media (NAND-flash in your case).

    Look at it this way :

    1. When the system boots

    Initially using the kernel bootargs rootfs=,
    the entire filesystem / is be mounted.
    At this point in time, mtdblock03 (pointed to by ubi0) is mounted to /.

    initial rootfs mounted

    • Anything written anywhere under / ends up in mtdblock03.

    2. Later

    Either manually or using init scripts, mtdblock06 (pointed to by ubi1) is mounted,
    at /mnt/upgrade.

    another block mounted

    • Now anything written under / EXCEPT under /mnt/upgrade ends up in mtdblock03.
      And anything written under /mnt/upgrade ends up in mtdblock06.

    As long as the second mount is not unmounted (using umount),

    all I/O to /mnt/upgrade is redirected to mtdblock06

    and NOT mtdblock03.


    1. In the above figures, the red dotted-line represents the 1st mount command (rootfs) and the blue dotted-line represents the second mount command (/mnt/update). Both establish a filesystem mapping with the underlying device i.e the NAND-flash.

    2. The mount command basically establishes a virtual map i.e. your filesystem that represents various parts of the physical device(s) present on the system.

    3. Also the mount command will over-ride any earlier mount command that maps the same node on the filesystem. Hence, any node on the filesystem represents the physical device as pointed to by the last executed mount command that references the node or its parent.

    4. In the interests of keeping things simple, the figures show a direct mapping. In reality, there are multiple drivers involved; namely the vfs, ubifs and the nand drivers that sit in between the filesystem and the underlying physical media.