I posted this in the nook touch forum by mistake. Please read below and let me know what you think.
One of the biggest issues I had with my nook was the 16/1GB division between content I can load and content from B&N/etc. Not being able to use that 16GB how I wanted was something I set forth to fix. Here is my solution to make this usable to non-rooted apps.
1) Root if not already rooted.
2) Make a directory inside of /data. I chose /data/usrdata.
3) remount / as RW with the command mount -o remount,rw -t rootfs rootfs / (credit to Indirect for this, as I could't find the command to do so)
4) mkdir /mnt/internal . We need somewhere to mount /data/usrdata/ and /mnt is public enough.
5) busybox mount -o bind /data/usrdata /mnt/internal. Mounts /data/usrdata to /mnt/internal.
6) For good measure, chmod 777 /mnt/internal and chmod 777 /data/usrdata.
Now, /mnt/internal should have whatever free space /data has, and should be read/write accessible from any program. A quick test with touch+terminal emulator shows new files as being created with RW permissions for all.
Alternatives: When I was initially thinking about ways to do this, my first reaction was to just open up /data to be read only to all, then have my usrdata folder be read/write all. However, I know part of android's app security model depends on some of these permissions. While I can't think of anything breaking or sensitive data being leaked, I decided against it. If anyone has any thoughts as to that scenario, I am very interested in hearing about it.
USB support: This will *not* be mountable under USB. Unfortunately you are still limited to transfering the data from a computer to the B&N internal storage or SDcard first, then moving the data internally. The problem that I see with this is similar to my understanding of the galaxy nexus situation, where the system can't unmount its /data partition and let the USB host take over. Another alternative to this could be to write an image file and mount that over usb (I've done this on my Evo, it worked so-so). Problem with that is that it really wouldn't grow/shrink with the storage. I suppose you could do some shell trickery and pipe it through gzip somehow, but that wouldn't help very much.
Let me know what you think and if you have any ways to improve this.
UPDATE: Persistance:
To make this persistant across reboots, run these commands as root:
1) mount -o rw,remount -t ext4 /dev/block/platform/mmci-omap-hs.1/by-name/system /system
2) echo mount -o remount,rw -t rootfs rootfs / >> /system/bin/clrbootcount.sh
3) echo mkdir /mnt/internal >> /system/bin/clrbootcount.sh
4) echo busybox mount -o bind /data/usrdata /mnt/internal >> /system/bin/clrbootcount.sh
5) echo mount -o remount,ro -t rootfs rootfs / >> /system/bin/clrbootcount.sh
All this does is put the following at the end of clrbootcount.sh
mount -o remount,rw -t rootfs rootfs / #Remounts root as RW. Root is regenerated at each reboot, so /mnt/internal is never going exist on a fresh startup
mkdir /mnt/internal #make /mnt/internal, see above
busybox mount -o bind /data/usrdata /mnt/internal #Binds the directory
mount -o remount,ro -t rootfs rootfs / #remounts root as RO. Unsure if this is necessary, but since it runs as RO, its probably better safe than sorry.
Thanks to eded333 for mentioning a good place for the script.
Click to expand...
Click to collapse
I was the one who wrote the script gameman. >.>'
Very nicely done.
Does Android possess a fstab? If so, could these changes (also) be made there and still be persistent?
this is a good work around
Am I understanding this correctly in that if I follow these guidelines I can move my data over to the Barnes and noble alotted storage that we were complaining about not having available?
Sent from my Nook Tablet using Tapatalk
downsay said:
Am I understanding this correctly in that if I follow these guidelines I can move my data over to the Barnes and noble alotted storage that we were complaining about not having available?
Sent from my Nook Tablet using Tapatalk
Click to expand...
Click to collapse
That is correct, from what I understand as well.
Sent from my BNTV250 using Tapatalk
liquidzoo said:
Very nicely done.
Does Android possess a fstab? If so, could these changes (also) be made there and still be persistent?
Click to expand...
Click to collapse
From what I could tell, it does, but its not the normal /etc/fstab. It looks like they have a daemon or something that mounts the sdcard and the media (1gb) drive. When I first looked at its version of the fstab, it looked like it only took a block device, which doesn't quite work for the directory binding.
downsay said:
Am I understanding this correctly in that if I follow these guidelines I can move my data over to the Barnes and noble alotted storage that we were complaining about not having available?
Click to expand...
Click to collapse
Yes that is correct. You still cannot mount it under USB, however. If you have some other way of getting the files there, however, its open as an option. I've been using swiFTP (in the market) to do that. Could also copy and move from the media/sd cards that do mount to the PC, but thats a two step process. I've thought about getting MTP setup so that you can see that folder via USB, but haven't really had a chance to look into how that would work.
*Note, when using swiFTP and other programs more than likely, you may get some file permissions errors or other odd errors about corrupt files. These are just the file permissions that the program defaulted to, and can be fixed by doing a 'chmod -R 777 /mnt/internal/'. Don't have this problem on sdcard or media because they are just FAT32 formatted, which don't support permissions.
Trying to understand ...
gameman733 said:
I posted this in the nook touch forum by mistake. Please read below and let me know what you think.
Click to expand...
Click to collapse
I don't understand the purpose of the mounts. Why not just create /data/usrdata and put your stuff in there?
I know /data has "access-only/no-read" access for non-system apps, but anything in /data/usrdata/ should be visible (and no need to modify clrbootcount.sh).
If you need "/mnt/internal" (I don't see the need for that either), why not just use a soft link (which is permanent)???
The primary reason for using the mounts was that I was originally planning on trying to mount it in a way that would ignore file permissions, but didn't know at the time that you can't do that with a bind mount. Using a simple link would be just as effective in this case.
However.. / is Read only. Even when remounted read-write, this filesystem is actually regenerated every boot. So nothing in /mnt would stay past the next restart.
The purpose for having it in /mnt (could have been anywhere, I suppose, but it seemed a little more appropriate) was for apps that can't browse /data. For example, gameboid and related programs would get to /data and show nothing, because you can't browse it as a non-rooted app. Having a symlink or bind mount elsewhere in the filesystem where they can browse helps with that. The alternative was to remove the no-browsing permissions from /data. I didn't feel comfortable with doing this, however, as I'm sure there are some security risks to doing this. It probably isn't a big deal, but since we have the tools to do it while maintaining those existing permissions, why not go ahead and do that?
Is there a solution that does not require being rooted?
[I was gonna start a thread about this 1.0 GB vs 16GB issue. Glad someone
beat me to it. ]
A day or two ago, I side-loaded a couple of movies, each about 400-MB in size,
and was surprised to notice that I had only 20% of my 1.0GB remaining.
I haven't 'bitten the bullet', and got brave enough to 'root' my Nook yet.
(Still not sure yet whether my wife will keep it, and it's an XMAS-gift for her.)
But, I'm quite fluent in Linux, so if we DO keep it, I'll definitely get around
to doing the 'root'.
Meanwhile, if anyone does find a way, without rooting, to re-allocate these
built-in assigned storage quotas, please post it in this thread.
Cheers...
gameman733 said:
The primary reason for using the mounts was that I was originally planning on trying to mount it in a way that would ignore file permissions, but didn't know at the time that you can't do that with a bind mount.
Click to expand...
Click to collapse
To solve this issue I've compiled fuse kernel module and bindfs userspace utility. Bindfs is similar to "mount -o bind" but can override permissions and ownerships. I can share how-to instruction and compiled binaries if you want
Related
Hi !
I have an application (CamScanner) with large amount of data (~8Gb). This app doesn't support transfering data do external SD card, so I checked mount -o bind command to bind directory with data stored on external SD to directory in /sdcard and it's working correctly. Question is where I can put this command so that system will run it at boot time after external sd card is ready. There is no /etc/init.d directory on my SGS2 (stock XXKI4). I prefer not to install any applications to perform such a simple task...
Thanks for help, regards !
slig said:
I prefer not to install any applications to perform such a simple task...
Click to expand...
Click to collapse
I think you have no choice, as stock kernels do not have init.d support. You'd need to go down the route of either using an app to run a script on boot, install a kernel with init.d support, or stick with your current method of manually running a script when you need to use the app.
Also, you could try asking the developers kindly to allow saving to external_sd. There's an Email Developer link on the Android market, and a Contact Us link on their website
Thanks for response. I found script named init.rc located in "/", it has several mount commands inside, wonder if it can be used...
Also discovered that app Tasked has ability to run shell scripts with root privileges (at boot or at application start). I suppose I have to put this shell script in /system because in /sdcard owner permissions cannot be set so that file cannot be modified (vfat does not support that) and a security hole would be created...
I think that I'll also ask developer for this feature as You suggest.
slig said:
Thanks for response. I found script named init.rc located in "/", it has several mount commands inside, wonder if it can be used...
Click to expand...
Click to collapse
Everything in "/" is initramfs, a volatile ramdisk changes to which would be lost
on reboot. Only exception are directories in which actual partitions are mounted,
like /system and /data (you can check which directories with "mount" command).
Have you tried just using symbolic link?
INFO
This may be the best solution, try something like:
Code:
mkdir /sdcard/AppFolder
ln -s /sdcard/AppFolder /data/data/com.your.application.data.folder
Just in case you don't know, you can execute those command using
Terminal Emulator. You were considering modifications to /, so I guess you already have root.
Yes, I have rooted my SGS2 via ZergRush.
I didn't know that / is volatile initramfs, thanks for that information.
As for symbolic link - unfortunately on my stock ROM both /sdcard and /sdcard/external_sd filesystems are vfat and don't support symbolic linking. Only working way I discovered is bind mount.
In my case, I have the following:
mount -o bind /sdcard/external_sd/CamScanner /sdcard/CamScanner
And application runs OK, all data is accessible and doesn't consume internal flash memory.
I'll take a look how hard would be to write some small application to do just this task - define some pairs of source and target directories and mount - bind them at start.
I've somehow missed the fact that you're need redirection from /sdcard
to /sdcard/external_sd, I was thinking about symlink on /data...
Anyways, there another nice trick you can do - if you can devote your SD card
to this one application, then just edit /system/etc/vold.fstab to make SD card
mount in /sdcard/CamScanner instead of /sdcard/external_sd.
Hello everyone!
Is it possible to enlarge free space on /osh by moving the biggest directory (/osh/usr/share) to /preinstall directory to symlink/mount it to previous location?
Thanks!
It should be possible, if you do it right.
Well, something is not right. I moved /usr/lib to /preinstall and symlinked it. Everything is fine!.. until a reboot
I changed /osh/ubuntu.sh, added remount lines from Gentop
/bin/mount -o remount,rw /
/bin/mount -o remount,rw /preinstall
Click to expand...
Click to collapse
but after reboot /preinstall is always "Device is busy".
Can someone help me? This is just a great possibility to get more space for webtop without SD - and it works much faster! If I could free some more space via uninstalling unused apps - I could even install OpenOffice =)
I am told that android partitions are somewhat special/different than what you see on standard linux hard drives.
Maybe an expert can step forward and point us to some good information on how android does things, until then I think trial & error is the only option.
You could try: /bin/mount -o rw,remount /dev/block/mmcblk0p17 /usr/lib
One other thought, it may be possible to create a fstab entry instead of putting a mount command in /osh/ubuntu.sh
tamuin said:
I am told that android partitions are somewhat special/different than what you see on standard linux hard drives.
Maybe an expert can step forward and point us to some good information on how android does things, until then I think trial & error is the only option.
You could try: /bin/mount -o rw,remount /dev/block/mmcblk0p17 /usr/lib
One other thought, it may be possible to create a fstab entry instead of putting a mount command in /osh/ubuntu.sh
Click to expand...
Click to collapse
That's a good idea. Will write back in minutes!
Hi. If you really need more space, best way is to use WebtopToSD apk. I have 14GB for osh with a linuxdisk chroot and it works great.
Send from my Atrix 4G
tamuin said:
I am told that android partitions are somewhat special/different than what you see on standard linux hard drives.
Click to expand...
Click to collapse
Kinda. Yes, the partition layout and partition handling is unusual and unconventional (at least compared to the PC world), but the partition contents (ie. the filesystem) is perfectly normal, exactly what you'd expect to find.
As far as this idea goes, I'd recommend not using the preinstall directly but instead creating a folder on preinstall dedicated to osh. So probably something like this:
Code:
#-- just the first time
mkdir -p /preinstall/osh-lib
cp -a /osh/usr/lib/* /preinstall/osh-lib
rm -rf /osh/usr/lib/*
#-- every time
mount --bind /preinstall/osh-lib /osh/usr/lib
This is just an idea, though it is completely untested.
jisse44 said:
Hi. If you really need more space, best way is to use WebtopToSD apk. I have 14GB for osh with a linuxdisk chroot and it works great.
Send from my Atrix 4G
Click to expand...
Click to collapse
Of course I know that techique =) My goal is to build small and usable Webtop without any SD cards
ravilov said:
Kinda. Yes, the partition layout and partition handling is unusual and unconventional (at least compared to the PC world), but the partition contents (ie. the filesystem) is perfectly normal, exactly what you'd expect to find.
As far as this idea goes, I'd recommend not using the preinstall directly but instead creating a folder on preinstall dedicated to osh. So probably something like this:
Code:
#-- just the first time
mkdir -p /preinstall/osh-lib
cp -a /osh/usr/lib/* /preinstall/osh-lib
rm -rf /osh/usr/lib/*
#-- every time
mount --bind /preinstall/osh-lib /osh/usr/lib
This is just an idea, though it is completely untested.
Click to expand...
Click to collapse
Thank you for your ideas.
So, I must make a conclusion:
1. I forgot to disable load_pia.sh in /system via ADB/Terminal
Code:
$ su
# cd /
# mount -o remount,rw /dev/block/mmcblk0p12 /system
# mv /system/bin/load_pia.sh /system/bin/load_pia.sh.disabled
This prevents mmcblk0p17 mounting to /preinstall
2. I used webtop2sd's mount and mount.orig - and added /preinstall mounting there just befor last mounting attemps of ubuntu.disk
After all everything works like a charm
Uninstalled most of apps, used gnome-appearance-properties to change metacity and gtk2 themes, saved that theme as my own, uninstalled every other theme... The only cons of this techique - still no enough of free space to install OpenOffice, and I decided:
1. to stop with this experiment - as everithing works as I expected;
2. not to symlink folders to /data for OpenOffice - because I will lose everything after first wipe.
If I could resize /osh or /preinstall partition via shrinking /data
I like your idea...
NemeZZiZZ said:
If I could resize /osh or /preinstall partition via shrinking /data
Click to expand...
Click to collapse
Changing the partition sizes has been other devices, see this post:
http://forum.xda-developers.com/showpost.php?p=22157605&postcount=25
I asked if anyone had tried it with the Atrix 4G in this post:
http://forum.xda-developers.com/showthread.php?t=2207918
...but I was strongly cautioned against it, I still might try it someday when I have the time.
Thanks for the info on what you did.
Hello! I already read that before, and I tried to "parted" mmcblk0 - but no success: as I remember, I can't get partition list because of error, and after googling that error I concluded, that partitions are made with error or overlapped.
Hi,
I've been Google'ing all over and now am really stuck
I have an HTC One with Android 4.2.2 installed on it and the phone is ROOTED
I want to do something really simple however, due to a puzzling Busybox install I keep getting caught out!
So here's the issue; I want to install Archlinux on the phone in a chroot... documentation is here:
<can't post link>
no probs
Though the issue I'm facing is wget can't resolve host, I try nslookup and get the internal loopback address of the phone "127.0.0.1/localhost".
This seems to be due to no resolv.conf file existing in /system/etc... using information described here:
<can't post link>
I attampted:
Code:
mount -o remount,rw -t yaffs2 /dev/block/<output from mount cmd> /system
mount -o remount,rw /system
mount -o rw,remount /proc /system
these seem to work for a while as "mount" shows /system being rw..... only after a while this seems to revert back to ro?
Additionally if I try installing anything like Busybox from Stephen Stericson the phone just crashes and reboots itself?? - using both "normal" and "smart" install methods.
Busybox X seems to work well for the current runtime, however, after reboot it's gone?
I have absolutely no idea how to solve this as I've been reading and reading and reading and the closest thing I came up with is a watchdog timer mentioned on a Sony handset but then if there is such a thing on my HTC how to find the pid to kill it?
Unfortunately standard *NIX commands don't really seem to work well, ie.
Code:
ps aux | grep watch
so I have no idea how to even begin finding it.
I have tried using various GUI apps additionally which also just reboot the phone when checking the "remount /system rw" option.
Has anyone got any advise or suggestions that could help me win the battle??
Many thanks.
.....well I hope this helps someone now but found an app called: HTC One RW which did the trick!
Busybox installed properly, nslookup worked and now running shell script to install Archlinux
I recently upgraded from my S2, to the S4. I'm enjoying the snappiness, and as are we all, a bit disappointed by the locked down nature of it. One of the things I liked about my old phone was the ability to have an encrypted container for sensitive files. In particular, I was using LUKS Manager to mount encrypted folders and it worked perfectly. However the stock kernel on the S4 appears to lack the dm-crypt module, and I am therefore unable to use it on the new phone.
I've tried a few other things as well, including Cryptonite and EDS Lite (as well as the paid version), but ran into similar problems. With EDS paid version there is source available for the required kernel module, but it hasn't been built for the S4 yet, it seems.
I'm willing to get into some of the nitty gritty details, but I was wondering if anyone else had any success building dm-crypt or the eds module for the s4 yet. Or if anyone would have some resources that might be a good starting point so I could build them on my own.
Thanks!
(MJ7, rooted)
Edit:
After a bit more digging I found the LUKS Guardian project, which looks promising. (I can't post links yet, but google "android cryptsetup luksopen" and it should be the first result). Their binary is throwing a segfault when i try it, but I'll pull it down and play with it tonight at home to see if I can get anywhere.
I think our kernel may in fact have DM-CRYPT available, but for some reason it's simply not working. In LUKS when I attempt to mount a file, it thinks it successfully mounts (and creates a folder) but it when I unmount, anything I copied over is still there. I find it telling though that it will only "mount" a file with the correct password. So the encryption may be working, while the mounting is not. I'm very comfortable in linux so I'll poke around and see if there's anything I can glean from the terminal.
One step closer, but not quite there yet. I SSH'd in and started playing with the LUKS Manager app and have come to the conclusion that it's really the mounting that is causing problems.
LUKS Manager creates a shell script over in /system/bin/luks. I pulled this off and looked over it a bit, and managed to run the pieces one by one until I came to failure. Essentially what is happening is it's using busybox to do the following:
mknod
losetup
/system/bin/lm.cryptsetup luksOpen #Yay, I don't need to compile LUKS Guardian!
mkdir ${mount_path}
chmod 777 ${mount_path} # THIS FAILS
mount the mapper to the mount path
chmod 777 ${mount_path} # THIS FAILS
chmod 777 -R ${mount_path} # THIS FAILS
So what you're left with is an encrypted volume which mounts just fine, but is only readable by root. Permissions on ${mount_path} are 700 and neither busybox chmod nor standard chmod will change them. I've also tried mounting the mapper with the busybox mount as well as the builtin. Same result. Further, it looks like I'm unable to (as root) chmod pretty much anything.;
Frustrating, because I can clearly see that the data is there when I'm in a root terminal, but none of the apps can access it.
Anyone have any ideas on why I can't chmod? Or how to get mount to grant 777 in the first place?
spdqbr said:
One step closer, but not quite there yet. I SSH'd in and started playing with the LUKS Manager app and have come to the conclusion that it's really the mounting that is causing problems.
LUKS Manager creates a shell script over in /system/bin/luks. I pulled this off and looked over it a bit, and managed to run the pieces one by one until I came to failure. Essentially what is happening is it's using busybox to do the following:
mknod
losetup
/system/bin/lm.cryptsetup luksOpen #Yay, I don't need to compile LUKS Guardian!
mkdir ${mount_path}
chmod 777 ${mount_path} # THIS FAILS
mount the mapper to the mount path
chmod 777 ${mount_path} # THIS FAILS
chmod 777 -R ${mount_path} # THIS FAILS
So what you're left with is an encrypted volume which mounts just fine, but is only readable by root. Permissions on ${mount_path} are 700 and neither busybox chmod nor standard chmod will change them. I've also tried mounting the mapper with the busybox mount as well as the builtin. Same result. Further, it looks like I'm unable to (as root) chmod pretty much anything.;
Frustrating, because I can clearly see that the data is there when I'm in a root terminal, but none of the apps can access it.
Anyone have any ideas on why I can't chmod? Or how to get mount to grant 777 in the first place?
Click to expand...
Click to collapse
Since you're on MJ7, it's probably SELinux doing that to you.
You might try using chmod 555 (read + execute) to see if that's allowed.
What is the mount point that you're trying to use? Perhaps that's also being blocked by SELinux.
Thanks for the suggestions. I've poked around a bit at selinux, but with no hope of disabling it I'm not sure if I'll make it through the last hurdle. I've tried a few different mount points and a few different chmod permissions to no avail. I *did* however have one breakthrough, but now I'm just flat out puzzled.
I mounted it via the luks script I mentioned earlier, and then do a busybox umount on it (leaving the mapper in place). I then checked the mount options for my external sd card, since both it and the LUKS volume are vfat. I remounted the mapper using
busybox mount /dev/mapper/test /storage/extSdCard/test -o rw,dirsync,nosuid,nodev,noexec,noatime,nodiratime,uid=1000,gid=1023,fmask=0002,dmask=0002,allow_utime=0020,iocharset=iso8859-1,shortname=mixed,utf8
This mounts the drive with user, group, and permissions all set exactly like other file in the external SD card. However es file explorer and all other apps show the mount point as simply empty. If I'm not on command line, I can't see anything in it, which is utterly baffling to me.
From the terminal I can copy files out to another location (this is a luks volume I created on the old phone, so it already had data in it) and access them just fine via esfile explorer and various text editors.
The data is there, it's decrypted, it's accessible through command line, but all my apps simply refuse to acknowledge it.
Edit:
I'm not the only one experiencing this mounting phenomena... https://groups.google.com/forum/#!topic/android-kernel/JeY_u-pHcxQ
Edit:
According to this, android 4.2 made is so that application-created mount points are not globally accessible. They suggest a few workarounds which I have not yet had a chance to try. This certainly explains the problem though!
Hi all,
So I've spent hours trying to solve this, using everything I have found on the Internet. (This problem isn't exclusive to CIFS mounts by the way, it's all FS types. CIFS mount is what I require)
Basically I have an android box that's running 4.4.2. I need to mount a NAS box onto the file system. I can do this no problem using Terminal as SU. As soon as I use another App to navigate to the location, the mounted location isn't visible. I know that it is a known bug/security restriction after 4.2, and is due to multiusers or something. People have suggested including the mount command into /system/bin/debuggerd because the start command is a system command that has higher privileges or something. Anyway, I've tried this by just removing the contents of debuggerd and typing the following:
#!/bin/sh
mount -o username=JOELB,password=password -t cifs //192.168.1.252/PUBLIC /data/media/0/NAS
However, this doesn't work on boot, or if i run 'start debuggerd'
Apparently /data/media/0 is the location I should be mounting to, due to the bug/security flaw. Apps like mount manager are useless because they only work for that app.
Can anyone help me on this... It's killing me!!
Many thanks
Joel