Can't delete folder via adb or twrp - General Questions and Answers

Hi guys,
as the title states, I'm not able to delete the folder "/sdcard" I created.
What I tried:
TWRP:
File manager > Go into folder > Delete - error 1
Mount system > File manager > Go into folder > Delete - error 1
Mount system and Micro SD card > File manager > Go into folder > Delete - error 1
Mount everything > File manager > Go into folder > Delete - error 1
ADB:
adb shell rm -rf /sdcard - resource busy
adb shell mount -o remount,rw and then rm -rf /sdcard - resource busy
Why is this folder there?
Well, I have this HTC e8 with barely no battery and when I was installing LOS yesterday there was a power outage and it corrupted the installation. After being able to go into recovery I lost the touch controls in TWRP. Went via adb and didn't remember the path to the sd card, so I could send the restore command. After trying the ls and find commands and end up with millions of records my "brilliant" idea was to use the mkdir command to test for the common sd card path names...
Anyway, after reinstalling LOS (with wipe data) I noticed it didn't let me use the sd card without formatting. Then I went into TWRP File Manager and found out the "/sdcard" folder I created had all the folders that LOS usually creates in my sd card (which the path is "/external_sd"). So now I need to delete this folder and reinstall everything again so that LOS can see "/external_sd" as the true sd card path
Do you guys have any suggestion I can try here?
Thanks in advance

You cannot operate on a folder / file that is currently in use by another process - this might be a daemon or whatever: If you try nevertheless then you get error message "Resource is busy" or similar.
When I try to mount a partition then I always do it this way
Code:
cd /
mount -o rw,remount <mount_point>
what always worked for me.

Related

[research]Another way to extend /data

In almost mobile ,the /data is too small.Can we use extend tf card instead data to get more space?
I try do something:
use a 8GB tf card,format to ext4.
My device is a tv box,is a android OS device.
It mount tf to /mnt/sda/sda1.
I copy /data all file to it: cp /data/* /mnt/sda/sda1 -rf
Set a flag to check the tf is mount when android start.
touch /mnt/sda/sda1/tf
write a script:/system/etc/install-recovery.sh,This file is run when system start.
#!/system/bin/sh
while [ ! -f /mnt/sda/sda1/tf ]
do
sleep 1
done
mount -o bind /mnt/sda/sda1 /data
Android started,it show /data is 8GB.
But when I install app,reboot device ,i can't see the app,but /data/app have the corresponding apk file,/data/data have the corresponding data file,
and /data/dalvik-cache have corresponding dex file.
What problem happend?
android will search installed app when it starting.
Maybe is search before install-recovery.sh running?
which is the search app? is service installd?

KitKat link play store cache to external sd (root)

Im new here and I've been searching for a solution to the play store telling me i need more space.. And I have found it out myself. Like I said, I am new.
So, let's get started.
First, download terminal emulator if you haven't already.
Next, grant superuser permissions by typing su.
Now, make a folder in the directory of your SD card.. For this, use mkdir. I named it play.
My SD card was located in the directory of /sdcard. So, I used the command mkdir /sdcard/play
After that, you will be removing the folder that the Google Play Store downloads files in
and symlinking that folder to your SD card.
So, type the command cd /data/data/com.android.providers.downloads
Then after that command, type rm -r cache
After that, symlink the cache folder to the sdcard.
ln -s /(insert your sdcard folder here)/play(or whatever you named your folder)
Bam. Done.
Now, this will not move all app data and stuff to the sdcard,
This will only make the Play Store download the app you are trying to get to the SD.
Therefore bypassing the not enough space error
To sum all of the commands up, how I used them...
su
mkdir /sdcard/play
cd /data/data/com.android.providers.downloads
rm -r cache
ln -s /sdcard/play cache
Done.
Note: this probably won't work with all phones, my phone is an LG L70 although my old LG (android 2.2) I tried to do this on had the SAME FILE that Play Store downloads to.. AKA downloadfile.apk.
I am not sure if it was in the same location, so I'm saying KitKat just to be safe.
Thank you!

How to decrypt SD storage(removable) | Phone to PC transfers | Easy | Automagically

I wanted an encrypted external sd on my phone that i could remove and transfer files to as needed.
This is the solution I conjured up after doing some testing and research
Thanks to @POQDavid who wrote How to decrypt and split adopted storage? which ive modified
Make sure your SD card is formatted as internal storage
Your device must be rooted.
Use a file browser like ES Explorer/Ghost/TotalCommander, browse to /data/misc/vold.
Copy the .key file to another folder and then move to your pc
DO NOT need to dump the hex like in other guides
Copy your key somewhere safe on PC
Code:
sudo mkdir /etc/keys/
cp <keyfilename>.key /etc/keys
On any Linux distro check where your drive is mounted, you can use
Code:
fdisk -l or lsblk
to find the large encrypted partition of the SD card, my SD card was mounted to /dev/sdd2.
Create the mount point:
Code:
sudo mkdir /mnt/1
Then run this command
Code:
sudo cryptsetup create usbcrypt1 /dev/sdd2 --key-size 128 --key-file /etc/keys/<keyfilename>.key
If your key is correct you can mount it by
Code:
sudo mount /dev/mapper/usbcrypt1 /mnt/1/
Test the mount
Code:
ls /mnt/1
Finally you can run
Code:
cd /mnt/1
to browse the decrypted storage.
Automation
Im tired now and so far I have automated this using terminal aliases
Just drop the alias into command and hit enter, the cryptmount to mount and cryptumount to unmount. (alias will be removed on reboot) edit and insert into ~./bashrc to make aliases stay
Code:
# alias mounting
[B]alias cryptmount="sudo su -c 'cryptsetup create usbcrypt1 /dev/sdd2 --key-size 128 --key-file /etc/keys/<keyfilename>.key' && sudo su -c 'mount /dev/mapper/usbcrypt1 /mnt/1'"[/B]
#alias unmounting and luksClose
[B]alias cryptumount="sudo su -c 'umount /mnt/1' && sudo su -c 'cryptsetup luksClose usbcrypt1'"[/B]
Remember to replace <keyfilename> with your keyfile name to make it work.
Next step make this automount in crypttab using dm-crypt method if thats possible... Any help appreciated.
cheers and good night
Table reserved for 2
Ok it works, but kind of a hassle. To copy files over you basically should copy them to a readable folder like user or any other one you can create directories in after mounting.
Copy your files to the encrypted drive, unmount .
then using a file manager with root access on your phone copy them from /mnt/expand/<UUID> to /mnt/sdcard and you should be good. It works for be but i wont be using this method anymore because its a pain to copy large amounts of files so many times. better to use an OTG usb for that
However this does have benefits if your phone is destroyed and only the adapted sd card exists and you need access to your files.
Enjoy.
[xzel] said:
Ok it works, but kind of a hassle. To copy files over you basically should copy them to a readable folder like user or any other one you can create directories in after mounting.
Copy your files to the encrypted drive, unmount .
then using a file manager with root access on your phone copy them from /mnt/expand/<UUID> to /mnt/sdcard and you should be good. It works for be but i wont be using this method anymore because its a pain to copy large amounts of files so many times. better to use an OTG usb for that
However this does have benefits if your phone is destroyed and only the adapted sd card exists and you need access to your files.
Enjoy.
Click to expand...
Click to collapse
Is it possible to browse adoptable storage from twrp using the aforementioned method?
I have busybox and cryptsetup in termux so i can use it from twrp terminal..?
Unreal_Hawkz said:
Is it possible to browse adoptable storage from twrp using the aforementioned method?
I have busybox and cryptsetup in termux so i can use it from twrp terminal..?
Click to expand...
Click to collapse
I believe you can mount it thru termux but I havent tried, I tried this on an Ubuntu system.

Question Trying to backup phone with adb, where is sdcard?

Right now I am backing up my files with adb and I have tried the following commands
adb pull /sdcard D:\[backupfolder]
adb pull /sdcard
But they just copy the internal storage folders, while what I want is to copy the stuff in the sdcard. I have tried
/storage/sdcard0
/storage/sdcard
/storage/0
/disk (it is how the folder is called in my phone)
but none of them exist.
Can anyone who has backed up their sd card on a Poco X3 tell me the actual storage path to use in adb? Thanks!
You can't.
Cuz SD card is always some strange digit number.
Try to enter ADB shell and then use the ls command to list all folders.
It should be in Mount or mnt
/sdcard is usually a chain of links that is not followed by ADB.
You need to:
Code:
$ stat /sdcard
And it will tell you where it points to. Then you stat that and keep on going until you stat something that is a real directory.

Mimic fstab entry by using a mount command that runs in an init.d script

Hey guys. I have an android tablet (running Android 8.1) that I flashed with a rooted system partition. The tablet has two main storage partitions: user and sdcard. sdcard is 20gb of storage that is immediately accessible via USB if plugged into the computer.
The problem I'm having is, after flashing with the new system partition, the 20gb storage is no longer mounted. I'm able to mount it using the following command:
Code:
$ mkdir /mnt/media_rw/sdcard
$ chmod 777 /mnt/media_rw/sdcard
$ mount -o rw /dev/block/blck27 /mnt/media_rw/sdcard
The problem is, after mounting it, I can't open media files, and I can't access it via USB either. I looked in the /vendor/fstab file to see how this partition is being mounted, which looks like this:
Code:
/dev/block/mmcblk0/mmcblk0p27 auto vfat defaults voldmanaged=sdcard1:auto,noemulatedsd
I'm not sure how to create a mount command that mimics the functionality of this. Any help would be greatly appreciated.

Categories

Resources