"mount: Invalid argument" on Android - android

I'm trying to mount an ext4 partition located on my SD card with the following:
# mount -t ext4 /dev/block/mmcblk1p2 /data/sdext2
But it always returns "Invalid argument". I've verified that ext4 is supported through /proc/filesystems.
Ideas on how to troubleshoot?

Turns out the SD card I bought from eBay was fake. It was packaged and branded as a 32gb card but the real capacity was 16gb. That's why it failed every time I tried to do 16gb FAT32 and 16gb EXT4. There wasn't any room for the second partition.
If I do 8gb each, it starts working again. Also works if I use a different card.

Related

How can i extract the userdata partition of my android emulator?

How can i extract the (unencrypted and complete) userdata partition of my android emulator (AVD)?
Due to some research i want to extract the userdata and system partition of my emulator. There are several possibilities to do so, yet i was unable to extract a complete and unencrypted userdata partition. I tried the following:
Extract using adb pull: adb pull /dev/block/dm-X DESTINATION_PATH. Results in being able to analyze the partition using autopsy. The image seems semi-complete as the important folders exist but are basically empty (i am using the SANS digital forensics & incident response poster to look up the most important data).
Extract using abd shell: adb shell "su root dd if=/dev/block/dm-X" > DESTINATION_PATH. The image seems corrupt. "File system is corrupt (extXfs_group_load: Group 1 descriptor block locations too large at byte offset 4128)" according to fsstat.
Access the partition via the file system: C:\Users\USER\.android\avd\EMULATED_DEVICE_NAME\userdata-qemu.img. The image seems incomplete as there are only a few folders to analyze.
What's really confusing to me are the three partitions userdata.img, userdata-qemu.img and userdata-qemu.img.qcow2 located in the folder stated in 3). According to the emulator help-page (emulator -help-disk-images), userdata.img is "the initial data partition image". userdata-qemu.img is "the persistent data partition image". There is no information about the userdata-qemu.img.qcow2. It seems that any data after the initial bootup will be saved in userdata-qemu.img.qcow2. I also tried to convert this file using qemu-img -f qcow2 -O raw userdata-qemu.img.qcow2 userdata.img to a raw file format (backing file from adb pull (method 1)), which can be analyzed using autopsy. However, the output seemes encrypted as the entropie is very high and you cannot detect any data using xxd/HxD.
I tested this on Android 11 and Android 12 rooted and emulated devices (Google Play API).
Thanks in advance!

How to Boot android bbbandroid from internal mmc?

I want to boot android pre-built bbbandroid.img.xz from internal mmc its always fail to boot whereas same procedure for SD Card it boot successfully.
To flash this image into internal mmc, I boot from SD Card and find internal memory at /dev/mmcblk1. Following command I used to flash image
sudo xz -cd bbbandroid.img.xz > /dev/mmcblk1
It shows partitions correctly. But always on console only slowly CCCCC printing and stopped.
Same procedure I am following to flash image into SD Card using UBuntu host machine and sd card reader and use similar command from ubuntu host machine
sudo xz -cd bbbandroid.img.xz > /dev/sdc
For Sd card, everything ok and booting successfully
I compared partitions of SD Card and internal mmc looks exactly same.
What might be problem any have idea?

adb install fails with error 'INSTALL_FAILED_INSUFFICIENT_STORAGE'

I have bought my first Android mobile Sony Xperia M without being aware of the issue that we can't move apps to external sd card. Refer this link for details.
The only thing Sony advice is to root the device, partition and use third party apps to move it. They also mention that rooting may void warranty.
My Android Details of Sony Xperia M is listed below
Model number C1904
Android version 4.1.2
Build number 15.1.C.2.8
I have tried running the below commands from some forum and it is not working for me,
adb devices
adb shell pm get-install-location
adb shell pm set-install-location 2
Though the above commands doesn't prompt any error and I can get the install location as 2 (with adb shell pm get-install-location). So I believe it has set properly. But then I tried installing some apps and it is only installing in the internal memory only.
I have tried 'apps2sd' utility to move my apps and it is showing the below error,
'The device does not have a real primary external storage, or the primary external storage is emulated. Moving app to SD function cannot be supported by this device.'
Finally from another forum, I understand that we can install apk files through 'adb install' command to install directly into the sd card as below,
adb install -s C:\com.furkan0gul.mvanparking.apk
The above command fails with this error,
3531 KB/s (13523837 bytes in 3.740s)
pkg: /sdcard/tmp/com.furkan0gul.mvanparking.apk
Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]
I have enough space (more than 6GB out of total 8GB memory) in my external card. You can find this using below command,
>adb shell df
Filesystem Size Used Free Blksize
/dev 402M 64K 402M 4096
/mnt/asec 402M 0K 402M 4096
/mnt/obb 402M 0K 402M 4096
/system 1183M 907M 275M 4096
/cache 246M 4M 241M 4096
/persist 3M 80K 3M 4096
/firmware 63M 43M 19M 16384
/data 2101M 1401M 700M 4096
/lta-label 15M 4M 10M 4096
/storage/sdcard0 2101M 1401M 700M 4096
/storage/sdcard1 7572M 1088M 6483M 32768
If I run the adb install command without '-s' switch, it installs fine in internal memory without any issues as below,
> adb install C:\com.furkan0gul.mvanparking.apk
2549 KB/s (13523837 bytes in 5.180s)
pkg: /data/local/tmp/com.furkan0gul.mvanparking.apk
Success
While installing to sd card, app seems to be installed in '/sdcard', but no mount of such thing there in 'df' command output. Also tried searching this 'INSTALL_FAILED_INSUFFICIENT_STORAGE' by google. Most of them asked to do some changes in emulator to get this done. I have uninstalled the app, restarted the device and tried installing again into sd card but not working ended with the same insufficient storage error.
I am not using emulator. I am just directly installing apk into my sd card. I dont want to root the device and void warranty offer.
Appreciate if some one could send your ideas on this.
There is a simple workaround.If your test device is running Android 2.2 or later then add the
android:installLocation
attribute to your application's manifest file, with the value "preferExternal". This will force the app to be installed on the device's external storage, such as a phone's SD card.
For example:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dem"
android:installLocation="preferExternal">
I have a Fairphone (first edition) with applied unified storage. The INSTALL_FAILED_INSUFFICIENT_STORAGE problem should have been gone with the unified storage. Nevertheless, it showed up after a few month despite having 12gb of free disk space. For me, the following steps solved the issue
Install an ssh server on your phone
Login
su (in case you're not root)
pm set-install-location 1 (set to external memory)
Since I HAVE enough space on the internal memory, this is preferred over the external memory (which I probably don't have anymore due to the unified storage). This might be specific to the Fairphone

Unable to change permission of the sdcard(emulator),can any1 guide me how to change them?

the permission of my sdcard is Irwxrwxrwx
i am unable to push any files in it
Android Emulator sdcard push error: Read-only file system
how to change permission of DDMS / File Explorer / sdcard?
Change file permissions in DDMS (Android)
i have gone through many questions some of them have been posted above,they didn't help..
i even tried getting an image from a friend,with read/write permissions but that didn't help either.
Sometimes the problem comes for something simpler: my SD Card was FAT32 formated and this problem finished when I changed the filesystem to NTFS.
You first need to create an SD Card image. This can be done in the AVD Manager at the same time as creating the AVD image.
The SD Card image has to be mounted too (i.e. if you use an already mounted SD Card). When no card is mounted, /sdcard is treated as a folder of /system. So when you try to write to /sdcard on an AVD image without an SD Card mounted it tries to write to /system which is read-only.
Update:
Make sure your SD card is mounted correctly. Use adb shell (or adb shell emulator-5554 when your real device is also plugged in) and enter df in the shell.
The output should look like this
Filesystem Size Used Free Blksize
/dev 378M 32K 378M 4096
/mnt/asec 378M 0K 378M 4096
/mnt/obb 378M 0K 378M 4096
/system 194M 191M 2M 4096
/data 194M 8M 185M 4096
/cache 64M 1M 62M 4096
/mnt/sdcard 246M 6K 246M 512
/mnt/secure/asec 246M 6K 246M 512
Make sure that this two lines are present.
/mnt/sdcard 246M 6K 246M 512
/mnt/secure/asec 246M 6K 246M 512
This means, that the SD Card is mounted correctly.
That being said: DO NOT IN ANY CASES NEVER EVER USE HARDCODED /sdcard/... PATHES. Always use Envirnoment.getExternalStorageDevice() (for multi-user) or Environment.getExternalStoragePublicDirectory (String type) (for public folders accessible to all users)
For Clarification: The SD Card is mounted in a different physical path depending on manufacturer of the ROM. Back when Android first appeared, all external cards where mounted by default in /sdcard since back then all devices had small internal memory and SD-Card slots.
Newer Android Smartphones often ship without an SD Card. The newerones with 1-16 GB internal memory, like tablets, do not mount to /sdcard instead they mount by default to /mnt/sdcard. But it also depends on vendors. One vendor use one way over the other way. Tablets w/o SD Card for example use part of the internal storage to mount to the old /sdcard for compatibility reasons. Always use the API to get the path to internal storage memory!
Envirnoment | Android Developers
http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory%28%29
or
http://developer.android.com/reference/android/os/Environment.html#getExternalStoragePublicDirectory%28java.lang.String%29

remounting a stubborn sdcard directory back to read-write

I'm developing an application for commercial market that won't be available on Play and I have a specific target device which was custom built, but not by me. Certain 3rd party SDK resources need to be installed in the SDCard directory. That alone is simple to do.
The problem I'm facing is that somehow the sdcard directory has been mounted read-only. Note there isn't really an sdcard, it's a partition on the internal drive. It was actually mount rw at point, something changed and now I'm stuck with read-only sdcard directory.
What I have tried so far:
Tried remounting the sdcard mount point. Hasn't worked. Even if i'm logged in as root. No errors supplied.
mount -o remount,rw /dev/block/mmcblk1p4 /mnt/sdcard
Checked /proc/mounts. I can see there in /proc/mounts that sdcard has been mounted ro. What I don't know is if there's an fstab equivalent in Android so I change the options. I'm told that vold.fstab is where I should go for that but...
/dev/block/mmcblk1p4 /mnt/sdcard vfat ro,relatime,uid=1000,gid=1015,fmask=0202,dmask=0202,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
Checked vold.fstab. That's not the same device shown in /proc/mount.
dev_mount sdcard /mnt/sdcard 4 /devices/platform/mmci-omap-hs.1/mmc_host/mmc1
dev_mount usbdisk /mnt/sdcard/usbdisk auto /devices/platform/ehci-omap.0
dev_mount extsd /mnt/sdcard/extsd auto /devices/platform/mmci-omap-hs.0/mmc_host/mmc0
Checked logcat output from boot. Nothing to indicate there was an error for mounting, but then I'm not even sure if mount/vold would report to logcat. There were however a number of errors that indicated booting applications couldn't write to sdcard.
I'm super confused at this point. Does anyone know of a sure fire way to fix this?
EDIT:
I've tried different mount options this time
mount -w -o remount /dev/block/mmcblk1p4 /mnt/sdcard
This works for awhile, and I'm able to do a few file operations but It eventually reverts back to RO, almost within a couple of minutes.
Managed to solve the problem. The file system had been corrupted thus the system forced remount to read-only. The simple fix was to recreate the file system.
admittedly this wasn't on android but i had to install ntfs-3g and configure fstab thus:
/dev/sda1 /media/mycard ntfs-3g rw,umask=0000,defaults 0 0
or mount with
mount -t cifs -o uid=1000 /dev/sda1 /media/mycard

Categories

Resources