All of lore.kernel.org
 help / color / mirror / Atom feed
From: Artem Bityutskiy <dedekind1@gmail.com>
To: umar@janteq.com
Cc: linux-mtd@lists.infradead.org, Iwo Mergler <IwoM@netcomm.com.au>,
	David Wagner <david.wagner@free-electrons.com>
Subject: Re: Discovering current MTD partition
Date: Thu, 28 Apr 2011 20:48:14 +0300	[thread overview]
Message-ID: <1304012894.2737.19.camel@localhost> (raw)
In-Reply-To: <7bc099d4301235c5f76f9689cb956f2c.squirrel@emailmg.startlogic.com>

On Thu, 2011-04-28 at 13:26 -0400, umar@janteq.com wrote:
> # cat /proc/mounts
> rootfs / rootfs rw 0 0
> ubi0:rootfs / ubifs rw,sync,relatime 0 0
> proc /proc proc rw,relatime 0 0
> tmpfs /tmp tmpfs rw,relatime 0 0
> devpts /dev/pts devpts rw,relatime,gid=5,mode=620 0 0
> sysfs /sys sysfs rw,relatime 0 0
> debugfs /debug debugfs rw,relatime 0 0
> tmpfs /webSvr/logs tmpfs rw,relatime 0 0
> 
> # cat /proc/mtd
> dev:    size   erasesize  name
> mtd0: 00020000 00020000 "bst"
> mtd1: 00500000 00020000 "ptb"
> mtd2: 00500000 00020000 "bld"
> mtd3: 00500000 00020000 "hal"
> mtd4: 00500000 00020000 "pba"
> mtd5: 00800000 00020000 "pri"
> mtd6: 00800000 00020000 "sec"
> mtd7: 03c00000 00020000 "bak"
> mtd8: 03c00000 00020000 "rmd"
> mtd9: 03c00000 00020000 "rom"
> mtd10: 00300000 00020000 "dsp"
> mtd11: 03c00000 00020000 "lnx"
> 
> # df
> Filesystem                Size      Used Available Use% Mounted on
> ubi0:rootfs              52.7M     35.1M     17.5M  67% /
> tmpfs                    65.4M     32.0K     65.4M   0% /tmp
> tmpfs                    65.4M     32.0K     65.4M   0% /webSvr/logs
> 
> There's nothing above I can use to infer about which /dev/mtdXX is
> currently booted - at least on this system.
> I have resorted to my backup strategy of parsing /proc/cmdline within
> Python to determine which partition is booted. *sigh*

Yes, this is a bit messy and complex. Anyway, here is the algorithm for
you, in short. Ask specific questions if it is not clear, I do not have
time right now to write long mails. Anyway, you need to spend some time
and understand the relations between all these mtdX, ubiY, ubiY_Z,
ubiY:name...

So, in your case you know your rootfs is "ubi0:rootfs". This means that
   a) your rootfs is an UBI volume
   b) this UBI volume belongs to the UBI device 0 (there may be several
      of them - ubi1, ubi2, etc). This is the typical case, I do not
      know if anyone really has more than one UBI device ever.
   c) You know that the volume name is "rootfs".

You also should know that there is 1-1 correspondence between MTD and
UBI devices - one UBI device sits on top (and fully controls) one MTD
device. To find out the MTD device number you look
at: /sys/class/ubi/ubi0/mtd_num

There you see the number X, this means your MTD device is mtdX

P.S. If you had set-up similar to Ricard's, you' also need to look
at /proc/cmdline to translate "rootfs" or "/dev/rootfs" to
"ubi0:rootfs". Not, in this case it is just co-incidence that you named
your volume "rootfs", if you named it "pussy_cat", you' have the
following in your /proc/mounts:

rootfs / rootfs rw 0 0
ubi0:pussy_cat / ubifs rw,sync,relatime 0 0

HTH.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

  reply	other threads:[~2011-04-28 17:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-26 23:43 Discovering current MTD partition Umar Qureshey
2011-04-27  5:31 ` Artem Bityutskiy
2011-04-27  6:22   ` Ricard Wanderlof
2011-04-27 17:08     ` umar
2011-04-28  7:31       ` Ricard Wanderlof
2011-04-28  7:37         ` Artem Bityutskiy
2011-04-28  8:00           ` Ricard Wanderlof
2011-04-28  8:52             ` Artem Bityutskiy
2011-04-28  9:09               ` Ricard Wanderlof
2011-04-27  7:25   ` umar
     [not found]     ` <4DB7C9F9.9000609@free-electrons.com>
2011-04-27 17:14       ` umar
2011-04-28  4:27         ` Iwo Mergler
2011-04-28  7:39           ` Ricard Wanderlof
2011-04-28 17:26           ` umar
2011-04-28 17:48             ` Artem Bityutskiy [this message]
2011-04-29  0:53               ` umar
2011-04-28 18:08 ` Bjørn Forsman
2011-04-28 18:21   ` Atlant Schmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1304012894.2737.19.camel@localhost \
    --to=dedekind1@gmail.com \
    --cc=IwoM@netcomm.com.au \
    --cc=david.wagner@free-electrons.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=umar@janteq.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.