* Discovering current MTD partition @ 2011-04-26 23:43 Umar Qureshey 2011-04-27 5:31 ` Artem Bityutskiy 2011-04-28 18:08 ` Bjørn Forsman 0 siblings, 2 replies; 18+ messages in thread From: Umar Qureshey @ 2011-04-26 23:43 UTC (permalink / raw) To: linux-mtd Hi, I searched this list's archive but did not see anything pertinent. I was wondering if there is a way to find out what the currently active mtd partition is. In my system, I have a few flash partitions for my file system and the kernel boots with the partition that is specified on the kernel command line. Aside from scanning /proc/cmdline, is there a way to programmatically ascertain which mtd partition is active *now*. I need to find this information within a Python script but really if it can be done in C (perhaps a syscall?), it's all I need. Regards, Umar ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Discovering current MTD partition 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 7:25 ` umar 2011-04-28 18:08 ` Bjørn Forsman 1 sibling, 2 replies; 18+ messages in thread From: Artem Bityutskiy @ 2011-04-27 5:31 UTC (permalink / raw) To: Umar Qureshey; +Cc: linux-mtd On Tue, 2011-04-26 at 16:43 -0700, Umar Qureshey wrote: > Hi, > > I searched this list's archive but did not see anything pertinent. > > I was wondering if there is a way to find out what the currently active mtd > partition is. In my system, I have a few flash partitions for my file > system and the kernel boots with the partition that is specified on the > kernel command line. Aside from scanning /proc/cmdline, is there a way to > programmatically ascertain which mtd partition is active *now*. > I need to find this information within a Python script but really if it can > be done in C (perhaps a syscall?), it's all I need. What does active mean? Anyway, there is /proc/mtd at your disposal. -- Best Regards, Artem Bityutskiy (Артём Битюцкий) ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Discovering current MTD partition 2011-04-27 5:31 ` Artem Bityutskiy @ 2011-04-27 6:22 ` Ricard Wanderlof 2011-04-27 17:08 ` umar 2011-04-27 7:25 ` umar 1 sibling, 1 reply; 18+ messages in thread From: Ricard Wanderlof @ 2011-04-27 6:22 UTC (permalink / raw) To: Umar Qureshey; +Cc: linux-mtd@lists.infradead.org, Artem Bityutskiy > On Wed, 27 Apr 2011, Artem Bityutskiy wrote: > > > On Tue, 2011-04-26 at 16:43 -0700, Umar Qureshey wrote: > > Hi, > > > > I searched this list's archive but did not see anything pertinent. > > > > I was wondering if there is a way to find out what the currently active mtd > > partition is. In my system, I have a few flash partitions for my file > > system and the kernel boots with the partition that is specified on the > > kernel command line. Aside from scanning /proc/cmdline, is there a way to > > programmatically ascertain which mtd partition is active *now*. > > I need to find this information within a Python script but really if it can > > be done in C (perhaps a syscall?), it's all I need. > > What does active mean? Anyway, there is /proc/mtd at your disposal. If you want to find out which partition is mounted as root you could look at /proc/mounts . /Ricard -- Ricard Wolf Wanderlöf ricardw(at)axis.com Axis Communications AB, Lund, Sweden www.axis.com Phone +46 46 272 2016 Fax +46 46 13 61 30 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Discovering current MTD partition 2011-04-27 6:22 ` Ricard Wanderlof @ 2011-04-27 17:08 ` umar 2011-04-28 7:31 ` Ricard Wanderlof 0 siblings, 1 reply; 18+ messages in thread From: umar @ 2011-04-27 17:08 UTC (permalink / raw) To: Ricard Wanderlof Cc: linux-mtd@lists.infradead.org, Umar Qureshey, Artem Bityutskiy > >> On Wed, 27 Apr 2011, Artem Bityutskiy wrote: >> >> > On Tue, 2011-04-26 at 16:43 -0700, Umar Qureshey wrote: >> > Hi, >> > >> > I searched this list's archive but did not see anything pertinent. >> > >> > I was wondering if there is a way to find out what the currently >> active mtd >> > partition is. In my system, I have a few flash partitions for my file >> > system and the kernel boots with the partition that is specified on >> the >> > kernel command line. Aside from scanning /proc/cmdline, is there a >> way to >> > programmatically ascertain which mtd partition is active *now*. >> > I need to find this information within a Python script but really if >> it can >> > be done in C (perhaps a syscall?), it's all I need. >> >> What does active mean? Anyway, there is /proc/mtd at your disposal. > > If you want to find out which partition is mounted as root you could look > at /proc/mounts . > > /Ricard Hi, /proc/mtd simply gives me a list of partition on the mtd device. It doesn't tell me which one we currently have booted from. /proc/mounts as well doesn't relay any info about /dev/mtdXX. ~Umar ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Discovering current MTD partition 2011-04-27 17:08 ` umar @ 2011-04-28 7:31 ` Ricard Wanderlof 2011-04-28 7:37 ` Artem Bityutskiy 0 siblings, 1 reply; 18+ messages in thread From: Ricard Wanderlof @ 2011-04-28 7:31 UTC (permalink / raw) To: umar@janteq.com; +Cc: linux-mtd@lists.infradead.org, Artem Bityutskiy On Wed, 27 Apr 2011, umar@janteq.com wrote: > Hi, > > /proc/mounts as well doesn't relay any info about /dev/mtdXX. Sorry, you are right of course. It just seems to say /dev/root on my system. The df command however seems to figure out which mtd device is mounted on / . I don't know exactly how it finds this out though. I'm pretty sure it uses /proc/mounts, because if /proc/mounts is missing it doesn't output anything, but it must be getting extra information from somewhere. /Ricard -- Ricard Wolf Wanderlöf ricardw(at)axis.com Axis Communications AB, Lund, Sweden www.axis.com Phone +46 46 272 2016 Fax +46 46 13 61 30 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Discovering current MTD partition 2011-04-28 7:31 ` Ricard Wanderlof @ 2011-04-28 7:37 ` Artem Bityutskiy 2011-04-28 8:00 ` Ricard Wanderlof 0 siblings, 1 reply; 18+ messages in thread From: Artem Bityutskiy @ 2011-04-28 7:37 UTC (permalink / raw) To: Ricard Wanderlof; +Cc: linux-mtd@lists.infradead.org, umar@janteq.com On Thu, 2011-04-28 at 09:31 +0200, Ricard Wanderlof wrote: > On Wed, 27 Apr 2011, umar@janteq.com wrote: > > > Hi, > > > > /proc/mounts as well doesn't relay any info about /dev/mtdXX. > > Sorry, you are right of course. It just seems to say /dev/root on my > system. > > The df command however seems to figure out which mtd device is mounted on > / . I don't know exactly how it finds this out though. I'm pretty sure it > uses /proc/mounts, because if /proc/mounts is missing it doesn't output > anything, but it must be getting extra information from somewhere. > > /Ricard Well, the best it to look at df sources. But here is my guess: /dev/root must have come from the kernel command line, if I'm not mistaken. You can find out what is your /dev/root from /proc/cmdline - find rootfs=<xxx> there, and xxx is your device. -- Best Regards, Artem Bityutskiy (Артём Битюцкий) ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Discovering current MTD partition 2011-04-28 7:37 ` Artem Bityutskiy @ 2011-04-28 8:00 ` Ricard Wanderlof 2011-04-28 8:52 ` Artem Bityutskiy 0 siblings, 1 reply; 18+ messages in thread From: Ricard Wanderlof @ 2011-04-28 8:00 UTC (permalink / raw) To: Artem Bityutskiy; +Cc: linux-mtd@lists.infradead.org, umar@janteq.com On Thu, 28 Apr 2011, Artem Bityutskiy wrote: > On Thu, 2011-04-28 at 09:31 +0200, Ricard Wanderlof wrote: >> On Wed, 27 Apr 2011, umar@janteq.com wrote: >> >>> Hi, >>> >>> /proc/mounts as well doesn't relay any info about /dev/mtdXX. >> >> Sorry, you are right of course. It just seems to say /dev/root on my >> system. >> >> The df command however seems to figure out which mtd device is mounted on >> / . I don't know exactly how it finds this out though. I'm pretty sure it >> uses /proc/mounts, because if /proc/mounts is missing it doesn't output >> anything, but it must be getting extra information from somewhere. >> >> /Ricard > > Well, the best it to look at df sources. But here is my guess: > > /dev/root must have come from the kernel command line, if I'm not > mistaken. You can find out what is your /dev/root from /proc/cmdline - > find rootfs=<xxx> there, and xxx is your device. Well, in this case /dev/cmdline says console=ttyS0 root=/dev/mtdblock3 rw rootfstype=jffs2 init=/linuxrc so no mention of /dev/root there. /Ricard -- Ricard Wolf Wanderlöf ricardw(at)axis.com Axis Communications AB, Lund, Sweden www.axis.com Phone +46 46 272 2016 Fax +46 46 13 61 30 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Discovering current MTD partition 2011-04-28 8:00 ` Ricard Wanderlof @ 2011-04-28 8:52 ` Artem Bityutskiy 2011-04-28 9:09 ` Ricard Wanderlof 0 siblings, 1 reply; 18+ messages in thread From: Artem Bityutskiy @ 2011-04-28 8:52 UTC (permalink / raw) To: Ricard Wanderlof; +Cc: linux-mtd@lists.infradead.org, umar@janteq.com On Thu, 2011-04-28 at 10:00 +0200, Ricard Wanderlof wrote: > On Thu, 28 Apr 2011, Artem Bityutskiy wrote: > > > On Thu, 2011-04-28 at 09:31 +0200, Ricard Wanderlof wrote: > >> On Wed, 27 Apr 2011, umar@janteq.com wrote: > >> > >>> Hi, > >>> > >>> /proc/mounts as well doesn't relay any info about /dev/mtdXX. > >> > >> Sorry, you are right of course. It just seems to say /dev/root on my > >> system. > >> > >> The df command however seems to figure out which mtd device is mounted on > >> / . I don't know exactly how it finds this out though. I'm pretty sure it > >> uses /proc/mounts, because if /proc/mounts is missing it doesn't output > >> anything, but it must be getting extra information from somewhere. > >> > >> /Ricard > > > > Well, the best it to look at df sources. But here is my guess: > > > > /dev/root must have come from the kernel command line, if I'm not > > mistaken. You can find out what is your /dev/root from /proc/cmdline - > > find rootfs=<xxx> there, and xxx is your device. > > Well, in this case /dev/cmdline says > > console=ttyS0 root=/dev/mtdblock3 rw rootfstype=jffs2 init=/linuxrc > > so no mention of /dev/root there. /dev/root is the alias for whatever is in root=, so in your case /dev/root = /dev/mtdblock3 -- Best Regards, Artem Bityutskiy (Артём Битюцкий) ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Discovering current MTD partition 2011-04-28 8:52 ` Artem Bityutskiy @ 2011-04-28 9:09 ` Ricard Wanderlof 0 siblings, 0 replies; 18+ messages in thread From: Ricard Wanderlof @ 2011-04-28 9:09 UTC (permalink / raw) To: Artem Bityutskiy Cc: linux-mtd@lists.infradead.org, Ricard Wanderlöf, umar@janteq.com On Thu, 28 Apr 2011, Artem Bityutskiy wrote: >> Well, in this case /dev/cmdline says >> >> console=ttyS0 root=/dev/mtdblock3 rw rootfstype=jffs2 init=/linuxrc >> >> so no mention of /dev/root there. > > /dev/root is the alias for whatever is in root=, so in your > case /dev/root = /dev/mtdblock3 Yes, I understand that, I was just mentioning the fact that it was not necessarily possible to determine the root file system partition from /proc/mounts as it uses the /dev/root alias there. /Ricard -- Ricard Wolf Wanderlöf ricardw(at)axis.com Axis Communications AB, Lund, Sweden www.axis.com Phone +46 46 272 2016 Fax +46 46 13 61 30 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Discovering current MTD partition 2011-04-27 5:31 ` Artem Bityutskiy 2011-04-27 6:22 ` Ricard Wanderlof @ 2011-04-27 7:25 ` umar [not found] ` <4DB7C9F9.9000609@free-electrons.com> 1 sibling, 1 reply; 18+ messages in thread From: umar @ 2011-04-27 7:25 UTC (permalink / raw) To: dedekind1; +Cc: linux-mtd, Umar Qureshey > On Tue, 2011-04-26 at 16:43 -0700, Umar Qureshey wrote: >> Hi, >> >> I searched this list's archive but did not see anything pertinent. >> >> I was wondering if there is a way to find out what the currently active >> mtd >> partition is. In my system, I have a few flash partitions for my file >> system and the kernel boots with the partition that is specified on the >> kernel command line. Aside from scanning /proc/cmdline, is there a way >> to >> programmatically ascertain which mtd partition is active *now*. >> I need to find this information within a Python script but really if it >> can >> be done in C (perhaps a syscall?), it's all I need. > > What does active mean? Anyway, there is /proc/mtd at your disposal. > > -- > Best Regards, > Artem Bityutskiy (ÐÑÑÑм ÐиÑÑÑкий) > > Hi, I have multiple redundant partitions on the flash chip. Each of these partitions has been flashed with a file system. The kernel resides in yet another partition. The bootloader loads the kernel into RAM, passes it the kernel command line, and passes control to the kernel. The kernel boots and mounts the partition it was told to do so via the command line. So, for instance, I may have this scheme: /dev/mtd2 ---> kernel /dev/mtd3 -----> FS #1 /dev/mtd4 -----> FS #2 The kernel can boot and mount either /dev/mtd3 or /dev/mtd4 depending on what command line the bootloader passed to the kernel. What I'd like is to detect from userspace is which /dev/mtdX partition is the currently executing program running on because that is the partition that has been obviously booted. My fallback idea is to just bite the bullet and parse /proc/cmdline to see which partition is being passed to the kernel. This should work fine. But I was curious if there is a "cleaner" more programmatic method of determining this information without resorting to clever regular expressions in parsing /proc/cmdline. ^ permalink raw reply [flat|nested] 18+ messages in thread
[parent not found: <4DB7C9F9.9000609@free-electrons.com>]
* Re: Discovering current MTD partition [not found] ` <4DB7C9F9.9000609@free-electrons.com> @ 2011-04-27 17:14 ` umar 2011-04-28 4:27 ` Iwo Mergler 0 siblings, 1 reply; 18+ messages in thread From: umar @ 2011-04-27 17:14 UTC (permalink / raw) To: David Wagner; +Cc: linux-mtd > On 04/27/2011 09:25 AM, umar@janteq.com wrote: >> Hi, >> [...] >> What I'd like is to detect from userspace is which /dev/mtdX partition >> is >> the currently executing program running on because that is the partition >> that has been obviously booted. > > I think you might want to take a look at getmntent (3) : it is a libc > function for getting the /etc/mtab entries. It also seems to be portable. > > Cheers, > David. > > -- > David Wagner, Free Electrons > Kernel, drivers, real-time and embedded Linux > development, consulting, training and support. > http://free-electrons.com This will give me the same info as /proc/mtab. I cannot figure out how I can infer which /dev/mtdXX was booted from with this information. ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Discovering current MTD partition 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 0 siblings, 2 replies; 18+ messages in thread From: Iwo Mergler @ 2011-04-28 4:27 UTC (permalink / raw) To: linux-mtd; +Cc: David Wagner, umar@janteq.com On Thu, 28 Apr 2011 03:14:36 umar@janteq.com wrote: > > On 04/27/2011 09:25 AM, umar@janteq.com wrote: > >> Hi, > >> [...] > >> What I'd like is to detect from userspace is which /dev/mtdX partition > >> is > >> the currently executing program running on because that is the partition > >> that has been obviously booted. > > > > I think you might want to take a look at getmntent (3) : it is a libc > > function for getting the /etc/mtab entries. It also seems to be portable. > > > > Cheers, > > David. > > > > -- > > David Wagner, Free Electrons > > Kernel, drivers, real-time and embedded Linux > > development, consulting, training and support. > > http://free-electrons.com > > This will give me the same info as /proc/mtab. I cannot figure out how I > can infer which /dev/mtdXX was booted from with this information. > Here is an example from the embedded system I have on my desk right now: root:/proc# cat /proc/mounts rootfs / rootfs rw 0 0 mtd:rfs / jffs2 rw,relatime 0 0 proc /proc proc rw,relatime 0 0 devpts /dev/pts devpts rw,relatime,mode=600 0 0 etc. From this we can see that the current root file system is mtd:rfs root:/proc# cat mtd dev: size erasesize name mtd0: 00100000 00020000 "S1S2EN" mtd1: 00400000 00020000 "rkern" mtd2: 00b00000 00020000 "rfs" mtd3: 00400000 00020000 "kernel" mtd4: 02000000 00020000 "root" etc. This tells us that mtd:rfs corresponds to mtd2, which should be accessible under /dev/mtd2, /dev/mtdblock2, etc. Best regards, Iwo This communication contains information which may be confidential or privileged. The information is intended solely for the use of the individual or entity named above. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this communication in error, please notify me by telephone immediately. ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Discovering current MTD partition 2011-04-28 4:27 ` Iwo Mergler @ 2011-04-28 7:39 ` Ricard Wanderlof 2011-04-28 17:26 ` umar 1 sibling, 0 replies; 18+ messages in thread From: Ricard Wanderlof @ 2011-04-28 7:39 UTC (permalink / raw) To: Iwo Mergler; +Cc: David Wagner, linux-mtd@lists.infradead.org, umar@janteq.com On Thu, 28 Apr 2011, Iwo Mergler wrote: >> This will give me the same info as /proc/mtab. I cannot figure out how I >> can infer which /dev/mtdXX was booted from with this information. >> > > Here is an example from the embedded system I have on my desk > right now: > > root:/proc# cat /proc/mounts > rootfs / rootfs rw 0 0 > mtd:rfs / jffs2 rw,relatime 0 0 > proc /proc proc rw,relatime 0 0 > devpts /dev/pts devpts rw,relatime,mode=600 0 0 > etc. On the other hand, here's another example from a system on my desk: # cat /proc/mounts rootfs / rootfs rw 0 0 /dev/root / jffs2 rw,relatime 0 0 proc /proc proc rw,relatime 0 0 sysfs /sys sysfs rw,relatime 0 0 udev /dev tmpfs rw,relatime 0 0 tmpfs /dev/shm tmpfs rw,relatime 0 0 /dev/part/rwfsblock /mnt/flash jffs2 rw,relatime 0 0 tmpfs /var tmpfs rw,relatime 0 0 devpts /dev/pts devpts rw,relatime,mode=600 0 0 The root partition is just listed as /dev/root without any information about what that refers to. The system doesn't even have a /dev/root so it's just some sort of placeholder. On the other hand, on the same system, df says: # df Filesystem 1k-blocks Used Available Use% Mounted on /dev/mtdblock3 28672 22384 6288 78% / udev 66588 4 66584 0% /dev tmpfs 66588 0 66588 0% /dev/shm /dev/part/rwfsblock 228864 5456 223408 2% /mnt/flash tmpfs 66588 25660 40928 39% /var which tells exactly where the root file system is. Don't know exactly how it obtains the information though. The system is running busybox so a quick look in the code for the df command should explain how its done. /Ricard -- Ricard Wolf Wanderlöf ricardw(at)axis.com Axis Communications AB, Lund, Sweden www.axis.com Phone +46 46 272 2016 Fax +46 46 13 61 30 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Discovering current MTD partition 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 1 sibling, 1 reply; 18+ messages in thread From: umar @ 2011-04-28 17:26 UTC (permalink / raw) To: Iwo Mergler; +Cc: David Wagner, umar@janteq.com, linux-mtd > On Thu, 28 Apr 2011 03:14:36 umar@janteq.com wrote: >> > On 04/27/2011 09:25 AM, umar@janteq.com wrote: >> >> Hi, >> >> [...] >> >> What I'd like is to detect from userspace is which /dev/mtdX >> partition >> >> is >> >> the currently executing program running on because that is the >> partition >> >> that has been obviously booted. >> > >> > I think you might want to take a look at getmntent (3) : it is a libc >> > function for getting the /etc/mtab entries. It also seems to be >> portable. >> > >> > Cheers, >> > David. >> > >> > -- >> > David Wagner, Free Electrons >> > Kernel, drivers, real-time and embedded Linux >> > development, consulting, training and support. >> > http://free-electrons.com >> >> This will give me the same info as /proc/mtab. I cannot figure out how >> I >> can infer which /dev/mtdXX was booted from with this information. >> > > Here is an example from the embedded system I have on my desk > right now: > > root:/proc# cat /proc/mounts > rootfs / rootfs rw 0 0 > mtd:rfs / jffs2 rw,relatime 0 0 > proc /proc proc rw,relatime 0 0 > devpts /dev/pts devpts rw,relatime,mode=600 0 0 > etc. > > From this we can see that the current root file system is > mtd:rfs > > root:/proc# cat mtd > dev: size erasesize name > mtd0: 00100000 00020000 "S1S2EN" > mtd1: 00400000 00020000 "rkern" > mtd2: 00b00000 00020000 "rfs" > mtd3: 00400000 00020000 "kernel" > mtd4: 02000000 00020000 "root" > etc. > > This tells us that mtd:rfs corresponds to mtd2, which > should be accessible under /dev/mtd2, /dev/mtdblock2, etc. > > > Best regards, > > Iwo > > # 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* ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Discovering current MTD partition 2011-04-28 17:26 ` umar @ 2011-04-28 17:48 ` Artem Bityutskiy 2011-04-29 0:53 ` umar 0 siblings, 1 reply; 18+ messages in thread From: Artem Bityutskiy @ 2011-04-28 17:48 UTC (permalink / raw) To: umar; +Cc: linux-mtd, Iwo Mergler, David Wagner 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 (Артём Битюцкий) ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Discovering current MTD partition 2011-04-28 17:48 ` Artem Bityutskiy @ 2011-04-29 0:53 ` umar 0 siblings, 0 replies; 18+ messages in thread From: umar @ 2011-04-29 0:53 UTC (permalink / raw) To: dedekind1; +Cc: David Wagner, Iwo Mergler, umar, linux-mtd > 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. > Yes, that definitely helps! # cat /sys/class/ubi/ubi0/mtd_num 11 Thanks :) ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Discovering current MTD partition 2011-04-26 23:43 Discovering current MTD partition Umar Qureshey 2011-04-27 5:31 ` Artem Bityutskiy @ 2011-04-28 18:08 ` Bjørn Forsman 2011-04-28 18:21 ` Atlant Schmidt 1 sibling, 1 reply; 18+ messages in thread From: Bjørn Forsman @ 2011-04-28 18:08 UTC (permalink / raw) To: Umar Qureshey; +Cc: linux-mtd On 27 April 2011 01:43, Umar Qureshey <umar@janteq.com> wrote: > [...] > Aside from scanning /proc/cmdline, is there a way to > programmatically ascertain which mtd partition is active *now*. > I need to find this information within a Python script but really if it can > be done in C (perhaps a syscall?), it's all I need. Busybox has a command called 'rdev' that looks up the block device that is mounted on /. $ busybox rdev /dev/sda1 / Look in busybox/util-linux/rdev.c and busybox/libbb/find_root_device.c for the implementation details. Best regards, Bjørn Forsman ^ permalink raw reply [flat|nested] 18+ messages in thread
* RE: Discovering current MTD partition 2011-04-28 18:08 ` Bjørn Forsman @ 2011-04-28 18:21 ` Atlant Schmidt 0 siblings, 0 replies; 18+ messages in thread From: Atlant Schmidt @ 2011-04-28 18:21 UTC (permalink / raw) To: 'Bjørn Forsman', Umar Qureshey; +Cc: linux-mtd@lists.infradead.org Bjørn: > $ busybox rdev > /dev/sda1 / Just FYI: This doesn't work on my particular Embedded Linux system (running on UBIfs). That command produces no result. Atlant -----Original Message----- From: linux-mtd-bounces@lists.infradead.org [mailto:linux-mtd-bounces@lists.infradead.org] On Behalf Of Bjørn Forsman Sent: Thursday, April 28, 2011 14:08 To: Umar Qureshey Cc: linux-mtd@lists.infradead.org Subject: Re: Discovering current MTD partition On 27 April 2011 01:43, Umar Qureshey <umar@janteq.com> wrote: > [...] > Aside from scanning /proc/cmdline, is there a way to > programmatically ascertain which mtd partition is active *now*. > I need to find this information within a Python script but really if it can > be done in C (perhaps a syscall?), it's all I need. Busybox has a command called 'rdev' that looks up the block device that is mounted on /. $ busybox rdev /dev/sda1 / Look in busybox/util-linux/rdev.c and busybox/libbb/find_root_device.c for the implementation details. Best regards, Bjørn Forsman ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message. Thank you. Please consider the environment before printing this email. ^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2011-04-29 0:54 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2011-04-29 0:53 ` umar
2011-04-28 18:08 ` Bjørn Forsman
2011-04-28 18:21 ` Atlant Schmidt
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox