Disable SDCard - Testing

I need to be able to disable the external SDcard on a bunch of tablets. These tablets are all rooted, and boot directly into our custom app so we can su commands at boot time.
I have successfully disabled the usb using this command: su -c 'echo 0 > /sys/devices/virtual/android_usb/android0/enable'
Does anyone know of a similar method that can be used to disable or prevent external SD card from functioning? I need the internal SD space to continue to function.

you can use 'unmount' command:
eg:
unmount /mtn/sdcard/.android_secure
(or su -c 'unmount ... etc)

Asmok78 said:
you can use 'unmount' command:
eg:
unmount /mtn/sdcard/.android_secure
(or su -c 'unmount ... etc)
Click to expand...
Click to collapse
I have a couple problems with this...
1. I would need to execute this whenever they reinsert the sdcard which causes it to remount
2. It doesn't always work if the sdcard is in use.
I need to prevent the external sdcard from working at all (/mnt/extsd) as a security requirement for one of our customers.

NebulaSleuth said:
I have a couple problems with this...
1. I would need to execute this whenever they reinsert the sdcard which causes it to remount
2. It doesn't always work if the sdcard is in use.
I need to prevent the external sdcard from working at all (/mnt/extsd) as a security requirement for one of our customers.
Click to expand...
Click to collapse
I don't remember all options to umount on android. In "classic" unix for problem 2 you can use option -f. For 1. - need edit /etc/fstab. I'm not sure if the android is identical.

Related

DamageControl 3.2.2.1 Apps2SD

Hello All,
I have a rooted Evo with DamageControl's 3.2.2.1 rom. I know it has apps2sd built into the OS, yet I cannot seem to get this working at all. Would anyone be kind enough who has this OS and a2sd working to make a quick and dirty guide? Ihave tried partitioning via Rom Manager and then turning it on...tried a few things. Any help is appreciated.
I would like some help with this as well. Have tried all the same steps, just can't seem to figure it out.
Sent from Ye olde Evo
Im sure someone out there knows how to do this!
Got this from another forum:
Did you patition it on the phone? Did you upgrade EXT2 to EXT3? If the answer to either or both of these, that could be the problem.
Type this in order:
cd c:\android-sdk-windows\tools (or wherever you have installed the sdk)
adb remount
adb shell
busybox --install /system/xbin
mkdir /system/sd
a2sd
exit (wait until its done doing its thing, you should see # when its done)
restart your phone after the prompt is done spewing and you're all set.
Click to expand...
Click to collapse
Personally I don't think there's any need for this since the EVO has hugeee internal memory. This was used mostly on older phones.
Thanks I'll try it when I get home
correct, most roms using this will only use app2sd if you have the ext partition on the sdcard, otherwise it defaults to the normal app storage

[GUIDE] Persistent Temp Root for G2 to SD Card

Problem: Changes to the system partition are lost when Linux flushes the disk cache: http://pastebin.com/cm75Z9UA
These instructions are a workaround to provide temp root like normal plus persistence because /system /data and /cache are partitions on your SD card. This lets you reboot and even factory reset, while being able to easily restore your settings and such by re-rooting and mounting your SD card partitions back over the internal partitions.
Prerequisites:
SD card partitioned with four partitions:
6GB as fat (for your data, can be bigger or small depending on your card size)
400MB ext3 for /system
1.3GB ext3 for /data
200MB ext3 for /cache
On the phone, enable "USB debugging" in Menu -> Settings -> Applications -> Development
On a PC with the Android SDK tools (adb) installed and working:
adb push Superuser.apk /data/local
adb push busybox /data/local
adb push rage /data/local
adb push resume /data/local
adb push root /data/local
adb push rsync /data/local
adb push setup /data/local
adb push su /data/local
adb install Term.apk
adb shell chmod 755 /data/local/busybox /data/local/rage /data/local/setup /data/local/resume /data/local/rsync /data/local/root
On the phone, open "Terminal Emulator" and type:
/data/local/rage
Wait for it to say "[+] Forked NNNN childs." then press the back button.
Open "Terminal Emulator" again and it should force close.
Open it one more time and the prompt should display "#". Then type:
/data/local/root
/data/local/setup
You may need to re-root after it reloads the GUI, but then it will stick. setup is a script that mounts your SD card partitions and copies the existing. It should only be run once unless you want to erase what you have there previously. This step wont work if you SD card is not partitioned properly.
On future power-ons, run this after temp-root instead of setup:
/data/local/resume
and you should get your Android back how it was.
is it suppose to scan through all apps on phone then reboot
Thanks muchly, I'll try this when my G2 arrives.
I have a question about this method. It looks to me that what setup does is copy the entire system, data, and cache to the SD card. Then, when you run resume, it uses rsync to bring the main system (in the onboard flash) up to date from the SDcard version, and then any changes, even if not actually written to the main system partition due to the HTC copy protection, get written to the sdcard copy of the system. Very clever (if I'm reading this write, otherwise, still clever, but me not so clever as I mis-understood).
The question is this: Are there any glitches or instabilities generated by suddenly changing the system files after the OS is already booted? Do I have to make sure to do this before I begin using my phone after boot or risk making changes that I will then loose when I run resume?
Thanks again for the work putting this together!
Sheep
Sheep, you understand almost completely. Setup does copy the existing data from the internal phone memory to the SD card. However, it then (like resume) doesn't copy anything back, it just mounts the system, data, and cache partitions from the SD card on top of the internal ones.
I had issues with the internal memory reverting back after I make changes to it. It seemed to happen over a short time, or was triggered by things like mounting the SD card to a computer.
I've been using this for about 24 hours with no problems. I've done a couple fresh boots and ran resume. But I didn't test the instructions from scratch, so if anyone tests and finds a problem, let me know!
Any performance hit because of running from SD?
I haven't really noticed any.
How does this impact battery life?
Sent from my T-Mobile G2 using XDA App
Can't say, I've had my phone hooked up most of the time through adb looking for root. Just did this for fun and because I was sick of re-rooting all the time.
looks interesting I'll try it out tomorrow
Sent from my T-Mobile G2
so your sd card has to be partitioned pryor to trying this
pre-partitioned card?
thatruth132 said:
so your sd card has to be partitioned pryor to trying this
Click to expand...
Click to collapse
yes it does
texasaggie1 said:
yes it does
Click to expand...
Click to collapse
and how do i do this on a non-rooted device
thatruth132 said:
and how do i do this on a non-rooted device
Click to expand...
Click to collapse
Use your G1 to partition the card.
Brad
You can also connect your phone to a Linux computer (a LiveCD would be fine) and use gparted or fdisk. Don't forget to backup the contents of your card first!
Pretty cool. But I think I'm gonna wait for a more permanent solution....
sheek360 said:
Pretty cool. But I think I'm gonna wait for a more permanent solution....
Click to expand...
Click to collapse
There are no roms available yet any ways, so to a non dev, non cook like me, the Root is pretty much useless
I'd read that the currently available root was good until a reboot, then I saw this thread that made rerooting after a reboot much easier. Since then I've seen some posts that seem to indicate that a root may spontaneously disappear even without rebooting. Is this the case, some permissions may be lost even if you don't reboot?
I was ready to pull the trigger on this permanent-temporary root until I read that. I'd like to be able to import my old wpa_supplicant.conf file and get my corp ipsec vpn working. I'd also like to be able to get wifi-tether working (although I rarely use it), but if root won't stay 100% until a reboot, then I'm not going to bother.
Dalamak said:
There are no roms available yet any ways, so to a non dev, non cook like me, the Root is pretty much useless
Click to expand...
Click to collapse
Not true. I'm not a dev or a cook, but there are things that you can make the phone do with root besides adding a theme or ROM.
wifi tether
ipsec vpn
backups
etc...
smasraum said:
I'd read that the currently available root was good until a reboot, then I saw this thread that made rerooting after a reboot much easier. Since then I've seen some posts that seem to indicate that a root may spontaneously disappear even without rebooting. Is this the case, some permissions may be lost even if you don't reboot?
I was ready to pull the trigger on this permanent-temporary root until I read that. I'd like to be able to import my old wpa_supplicant.conf file and get my corp ipsec vpn working. I'd also like to be able to get wifi-tether working (although I rarely use it), but if root won't stay 100% until a reboot, then I'm not going to bother.
Click to expand...
Click to collapse
With temp root on the internal system partition, writes would revert back after certain things (after mounting the sd card to a computer through the phone and disconnecting it, I'd always loose root). When running /system from an sd card, no writes can be reverted because none are made, so I've never had to re-root.
how to partition an SD card?
thatruth132 said:
and how do i do this on a non-rooted device
Click to expand...
Click to collapse
I used gparted in ubuntu to do mine. Like SAINTH said, the install disk for ubuntu is also a livecd so you dont even have to install ubuntu if u dont want to

How can i turn on the swap??

I want to enable the swap partion on my desire, but i can't manage to make it work.
My phone's mod version is CyanogenMod-7.0.0-RC0-Desire-KANG.
I try to put a script in init.d, something like this:
Code:
#!/system/bin
if [ -e /dev/block/mmcblk0p3 ];
then
swapon /dev/block/mmcblk0p3;
fi;
But after the OS is started, i checked it & the swap was 0.
I open a terminal to type "swapon /dev/blockmmcblk0p3", but it gave me this message : Function not Implemented.
So, I think it haven't set the option swap=y when it was builded.
Swap will only slow your desire down, the device has over 500mb of ram, and can't access the SD card anywhere near fast enough to make a swap file nessesary
AndroHero said:
Swap will only slow your desire down, the device has over 500mb of ram, and can't access the SD card anywhere near fast enough to make a swap file nessesary
Click to expand...
Click to collapse
I just want to have fun with my Desire, I don't want factory default.
mondory said:
I just want to have fun with my Desire, I don't want factory default.
Click to expand...
Click to collapse
ok try this then
adb shell
mount /system
mount /sdcard
dd if=/dev/zero of=/sdcard/swap.img count=(amount of swap you want)
mkswap /sdcard/swap.img
swapon /sdcard/swap.img
exit
adb reboot
Your kernel may not implement swap; the general consensus is that having it enabled, even when not using it, slows down the phone a bit. You'll have to use one with it enabled or compile your own.
I agree with Deathisfatal. I guest my kernel is not implement swap. Because I can enable swap in recovery mode, but when system is started, swapon says Function not Implemented.
I will try to learn how to compile my own kernel later.
Thanks, guys.

[Guide]Functional ext4 for external microSD with just a few bumps left

Y.G. said:
I formated my sd card to Ext4 and when insert it in to my phone, it says that's it's blank and has unsupported files. Any reasons for that?
Sent from my SPH-L710 using xda premium
Click to expand...
Click to collapse
The SPH-L710 Samsung Stock LJ7 TW 4.1.1 Android doesn't understand/support the change to ext4 external SD card (microSD) without a few things being done.
I'm working this out right now. So far I have manually been able to mount the newly created ext4 partition on the microSD card through adb, and after some chown/chmod I was able to go back to "Settings and Storage" and the "Mount SD Card" picked it up, and I was up and running ext4. But this didn't persist after a restart. So I'm looking into: /etc/vold.fstab MODS to keep it after restart right Now !!
If Some one else already has this perfected please chime in. I'm wanting to do most of the devices in the house this way when I get time because better performance, having a file system with a journal, and getting rid of thins like 4 Gig per file limitations is pretty Sweet in my humble opinion *Grin*
0) Assuming you already have your microSD card formatted ext4. I also happened to label mine extSdCard for the volume label within gparted
1) Can mount with:
mount -w -t ext4 /dev/block/mmcblk1p1 /storage/extSdCard/
2) To get the correct owner and permissions run:
chown root:sdcard_rw /storage/extSdCard
chmod 775 /storage/extSdCard
3) Should make the extSdCard owner/permissons match the regular internal sdcard you can verify this like so:
cd /storage/ && ls -l
drwxrwxr-x root sdcard_rw 2013-01-12 18:16 extSdCard
drwxrwxr-x root sdcard_rw 2013-01-12 17:05 sdcard0
4) After that you can go to the "Settings and Storage" to run "Mount SD" and you will have ext4 extSdCard Show up and it bring up the File System Status !! --> Until you reboot and it goes to crap because I don't have the vold.fstab edit/MOD complete _yet_ ... So, for now a boot script has been put in place to bring our external SD card back online during restart, so the system will acknowledges it, making the world a better place.
Example of how things look file system wise: mount | grep extSdCard
/dev/block/mmcblk1p1 /storage/extSdCard ext4 rw,relatime,user_xattr,barrier=1,data=ordered 0 0
5) Have not been able to resolve the vold.fstab to make this ext4 extSdCard matter fully Legit (in my opinion), but I did manage to make it remount the card on boot, so its online when the system comes up instead of having to manually mount it. Did this by -->
Added the following lines to the very bottom of: /etc/init.qcom.post_fs.sh
## sponix MOD to match with ktoonz kernel for better power management
stop mpdecision
## sponix MOD to mount extSdCard prior to GUI work around to make ext4 function
## read and write extSdCard mount
chown root:sdcard_rw /storage/extSdCard
chmod 775 /storage/extSdCard
mount -w -t ext4 /dev/block/mmcblk1p1 /storage/extSdCard
chown root:sdcard_rw /storage/extSdCard
chmod 775 /storage/extSdCard
## if you want read only extSdCard mount
## mount -r -t ext4 /dev/block/mmcblk1p1 /storage/extSdCard
Still attempting to automate the process so the Stock+root LJ7 can pick up the extSdCard _normally_ without having to do the mount command manually, but so far its kicking my butt. Also this is more a "General, or Question and Answer type Topic" the Kernel(s) obviously support ext4 the system fs uses/requires it *Grin*.. So we might get Our Friendly Neighborhood Moderator to Migrate it to the proper place to help others. Just hoping to get the last few bumps smoothed out, or find someone that already documented the process that I've overlooked *Grin*..
Current Known Issues: If you unmount the card through the "Settings | Storage | Umount SD" or by hand with umount, you will either need to reboot for it to reattach through the /etc/init.qcom.post_fs.sh boot script script addition, or will have to mount it manually if you want to keep the system up and running. Guess you could also probably just run the /etc/init.qcom.post_fs.sh as root from a terminal emulator (or adb).
Still searching for vold.fstab bits of wisdom but that will have to continue next weekend -->
Sexy and You Know it,
Keep on Flashing,
sponix2ipfw (sponix
:fingers-crossed:
Ha! Sorry. Deleted: Didn't understand that you had it running on boot (can't read properly )
Great idea
Am I really the only one who also thinks this idea is the nuts?
Am I the only one who longs to transform the mess that passes for a filing system on the internal sd using symbolic links into a beautifully organized, encrypted and cloud synced system on my external sd?
Is it just me and a few others that want to be able to achieve the above so that we can move from one ROM to another or recover from a lost phone with the minimum of fuss?
Are we freaks? :cyclops:
Say it isn't so XDA!! :crying:
I'm gonna try this on my international S3 running Null_ Rom 25 JB 4.1.2
PS do you have any idea how the entire ExtSD or just a folder can be enrypted using Cryptonite and automatically mounted at boot time?
emp111 said:
PS do you have any idea how the entire ExtSD or just a folder can be enrypted using Cryptonite and automatically mounted at boot time?
Click to expand...
Click to collapse
Is this along the lines of what you're looking for?
http://forum.xda-developers.com/showthread.php?t=1141467
Also your idea is pretty insane, but also genius
If you get that to work please do come back and share
Insane ideas are the best lol
CNexus said:
Is this along the lines of what you're looking for?
http://forum.xda-developers.com/showthread.php?t=1141467
Also your idea is pretty insane, but also genius
If you get that to work please do come back and share
Click to expand...
Click to collapse
Thank you for your prompt reply, yes it is asking a lot I know but I think that it can be done.
Now if you really thought that idea was insane......check this out:
Imagine that we asked every Android app developer to submit the various paths used for their config (and config backup) files to a central database and had the ability to add or own custom paths (which could be added to the central database once approved).
We could build an script/app that would retrieve a list of currently installed apps on your phone then automatically build a symbolically linked file system (and/or backup file system) in the location of your choice that you could either encrypt and/or sync using your current tools or even incorporate this functionality into the app itself along with the ability to choose what was encrypted/backed up and how i.e. either synced to the Cloud or (S)FTP or SMB as either a dd copy or even a cwm flashable zip.
Could I dare hope for a Tasker module or the ability to add custom scripts?
I wish I could do this myself but my coding skills are non existent
Anyway the LUKS manager app won't automatically mount a file system, but I really like it anyways, thank you for pointing me to it!
And on the Ext4 front, the mount command (yes the 1st one ) failed, maybe the op could offer a suggestion. :angel:
BTW is there a place for people to suggest ideas for apps here?
Wait really it wont? I couldve sworn I remembering that it did
But dude....
You need to learn yourself some java and start whipping stuff up
Idk about the whole central database thing, but the rest could definitely be done with root access
I think the main problem with that is the proprietary aspects...i mean even here on XDA where binaries released are supposed to be GPL compliant, many of them arent and its sad because it deteriorates the overall quality of work thats released afterward
This whole thing is just hard work!
CNexus said:
Wait really it wont? I couldve sworn I remembering that it did
Click to expand...
Click to collapse
Doesn't seem to unfortunately
But dude....
You need to learn yourself some java and start whipping stuff up :D :D[/QUOTE said:
You make it sound soooo easy lol, and at another point in my life maybe it would have been but right now I'm operating at a reduced level due to some unforeseen circumstances that have left me lacking focus, motivation etc
You know all the things you need to be creative, learn etc lol
Anyway back to the matter at hand, I have got my ext4 SD card to the stage where I have to manually mount it from within the Settings/Storage as I'm using the international S3 and don't have the init.qcom.post_fs.sh, I think the qcom refers to Qualcomm chipset in US S3's.
As for modifying vold.fstab so we can avoid the above workaround it would seem that maybe thats a dead end as according to a German guy on android-hilfe. de, Vold may have been modified by Samsung to only deadl with exFAT on External SD's.
Looks like I'm not gonna be in Android nirvana for a while :crying:
Unless anyone else on XDA fancies getting in on this !!!!
Click to expand...
Click to collapse
Got it working ..... kinda
Got an app called ezymount (by ezynow) that automounts my ext4 64GB microSD at boot time.
I have to wait a few seconds for the boot process to complete but it's automatic, am pretty happy!!
Now gotta get symlinks, encryption and cloud synchronization sorted :/

How to correctly mount and set permissions for ext4 MicroSd card on stock system ?

On ASUS stock rooted system, we can make use of fdisk to create a primary partition then use make_exr4fs to format that partition to ext4.
Once done and the /dev/block/mmcblk1p1 partition mounted as /storage/MicroSD it is possible as root to interact with it, but as non root you can only read data from there, not write.
How do you set selinux permissions correctly to allow writing without root ? The folder is set to 777, it cannot be a file permissions problem, it leaves us selinux policies to fix.
I tried to apply the selinux policy used for exfat external volumes but it still failed for writing.
Thanks to @Chainfire and Red Hat selinux documentation, I was able to resolve this without modifying the system, patching rules, disabling selinux or anything like that.
A two lines script can take care of this, requiring supersu and tools that are already on the device.
su --mount-master -c "mount -t ext4 -o discard /dev/block/mmcblk1p1 /storage/MicroSD"
chcon -R ubject_r:media_rw_data_file:s0 /storage/MicroSD
I'm still unsure to what each things are related to at 100%, but the context source of 3rd party application can write to media_rw_data_file , and this is what is applied on user's media folder inside data partition.
Some applications may still fail at understanding this is the external storage, but as my favorite file manager Fx does, that's what I want needed.
For some reasons the lost+found folder remains inaccessible, but the recursive part of chcon should take care of it on next boot.
Hope this will be useful to someone else.
Will your script work with another stock-ROM too? I've a Sony phone. Never had a phone I could get an ext4-formated sdcard working. Only with cyanogenmod installed ext4-formated cards work out of the box.
I'm a noob so I don't about scripting or understand details of file systems.
It will depend on where the Sony custom built system is mounting the micro sd card, if it mounts it at the same place, it will work.
But your message should have been a comment to my answer and not an answer proposal as you don't bring an alternative solution

Categories

Resources