Detecting whether the OS is running from NAND or SD


gruso

thunderbox
Joined
Feb 28, 2008
Messages
7,461
Age
47
Location
Sydney, Australia
Website
pandorapress.net
I'm after some help getting my SnapSnap screenshot PND working on systems running from a boot SD. Currently I'm using a script provided by Caine to determine the SD path for creation of a screenshots folder:



Code:
dir=$(mount | awk '/^\/dev\/mmcblk0p/ {print $3}')


This is not working on boot SDs. I have a dirty workaround, but it relies on a certain partition configuration (per Dave1234's SD installer) so is not useful enough to release.


Seems to me that the cleanest solution would be to detect where the OS is running from, and if it's SD, simply save screenshots to the homedir. In reading up on this I was led to compare the contents of /dev in each scenario. There are unique entries when running from NAND, namely 'ubi0', 'ubi1' etc.


I'm thinking the script could check for the presence of one of these, to deduce where the OS is running from. Is this reliable, or even sensible? Is there a better way (probably)?
 
Last edited by a moderator:
why not just ask the user where he wants to save/create the folder instead of guessing? then if you extract sebt3 zenity script from his midi installer package you can see how he gives the users a choice?


;) hope this idea helps.
 
why not just ask the user where he wants to save/create the folder instead of guessing? then if you extract sebt3 zenity script from his midi installer package you can see how he gives the users a choice?


;) hope this idea helps.
That could introduce some complications, as this utility has two components (one installed, one not) and needs to allow for SD swapping - so it confirms the path before each shot. Doable yeah, but I don't want to go that way at this stage.

df / | tail -n 1 | awk '{ print $1 }'


will give you the filesystem / is mounted from.
Thanks for the tip. The output ("Filesystem") is the same in each case though.
 
That's weird... Working fine on my Linux box here. What does a 'df /' alone gives you?
On the Pandora it only prints the column headers (when running from NAND). On my desktop it works properly. Not sure what is the cause of the difference here.
 
Last edited by a moderator:
Hum, output of df on pandora is weird, root line (booting from NAND) is:



Code:
ubi0:rootfs 	blablab   blblbl blb%  /





And requesting for / mountpoint doesn't work... Maybe the union fs is confusing the system?





Output when booting from SD1 is





Code:
/dev/root   kjkljkl jkljkl  kjkl% 	/





Also root filesystem should be always first line of data, so something like that:





Code:
df | head -n 2 | tail -n 1 | awk '{ print $1 }'


Should give you one of the two options (NAND: ubi0:rootfs , SD: /dev/root).


Hope that helps,


(now, back to work)
 
Back
Top