Hi,
I'm trying to upgrade my Nexus S I9020 to ICS -- well, actually,
now I'm just trying to get my phone back. I backed up my phone
before I started, but now I can't even mount my phone on my
computer (Linux) to do a restore.
On power-on my phone immediately goes to fastboot mode, saying
> fastboot mode - no boot or recovery image
I see four options: reboot bootloader, reboot, recovery, and
power off. I go to recovery and I get to a screen with
ClockworkMod Recovery v5.0.2.0 at the bottom and a set of
options. At this point, if I connect my phone to the computer
with a USB cord, I can see it with lsusb,
> Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> Bus 003 Device 002: ID 1ea7:0002
> Bus 004 Device 002: ID 056a:0011 Wacom Co., Ltd Graphire 2 4x5
> Bus 001 Device 003: ID 18d1:4e22 Google Inc. Nexus S (debug)
but fdisk -l doesn't see anything. Now I execute "mount USB
storage" on the phone and Nautilus (linux file manager) pops up
with a mount at /media/CB59-1402, but there's nothing in it. Now
fdisk -l shows
$ sudo fdisk -l
...
> Disk /dev/sdb: 14.3 GB, 14314094080 bytes
> 64 heads, 32 sectors/track, 13650 cylinders, total 27957215 sectors
> Units = sectors of 1 * 512 = 512 bytes
> Sector size (logical/physical): 512 bytes / 512 bytes
> I/O size (minimum/optimal): 512 bytes / 512 bytes
> Disk identifier: 0x00000000
So the computer found some mass storage there. Now I try to
create a file there,
$ sudo touch /media/CB59-1402/test.txt
> touch: cannot touch `/media/CB59-1402/test.txt': Input/output error
so the filesystem or partitioning or something seems to be
borked. The filesystem is vfat (right?) so I try to fix it with
$ sudo fsck -t vfat /dev/sdb
> fsck from util-linux 2.21
> dosfsck 3.0.12, 29 Oct 2011, FAT32, LFN
> open: No medium found
I have the Android SDK installed, so I look to see if adb can see
the phone,
$ adb devices
> List of devices attached
> 3430CA26FCB200EC recovery
OK. Try
$ adb shell
It returns immediately. Try fastboot,
$ fastboot devices
Nothing.
--
I'm really stumped. I got here because the web page for the ROM
said to reformat everything from CMR. I reformatted /sdcard,
/system, /cache, /data, and /boot.
Help!
Thanks,
-Rod
fastboot only works in the bootloader i believe, not recovery. adb may not be working because Android is no longer installed (/system partition). To save the trouble next time, when switching between very different ROMs, all that needs to be done is a data/factory reset, formatting /system and formatting /boot. SDCard is optional, i never do it (data/factory reset gets rid of the .android_secure folder already).
I've not had this problem in linux with being unable to get into the SDCard though, this is what you want to sort out so you can copy a ROM .zip and flash through CWM. Everything besides this is how it should be. Try unmounting it and mounting it manually, something along these lines should work fine:
# mkdir /media/nexus
# mount -t auto /dev/sdb /media/nexus
Now try and open up /media/nexus with nautilus. Good luck.
Related
I am running cyanogen's rom with a fat32 partition and ext3 partition. When i run fdisk on the device /dev/sdb, i get this as a result and it looks ok:
Code:
# fdisk /dev/sdb
Command (m for help): p
Disk /dev/sdb: 8067 MB, 8067743744 bytes
249 heads, 62 sectors/track, 1020 cylinders
Units = cylinders of 15438 * 512 = 7904256 bytes
Disk identifier: 0x000eadb7
Device Boot Start End Blocks Id System
/dev/sdb1 1 941 7263548 c W95 FAT32 (LBA)
/dev/sdb2 942 1005 487398 83 Linux
Partition 2 does not end on cylinder boundary.
however, I cant mount my partitions reliably. Sometimes when I plug it in, I get the fat32 partition as /dev/android, and sometimes I get the ext3 partition. but under both circumstances, i NEVER see /dev/sdb1 or /dev/sdb2.
Code:
# ls /dev | grep sd
lrwxrwxrwx 1 root root 4 2009-07-20 15:55 root -> sda3
brw-rw---- 1 root disk 8, 0 2009-07-20 15:55 sda
brw-rw---- 1 root disk 8, 1 2009-07-20 15:55 sda1
brw-rw---- 1 root disk 8, 2 2009-07-20 15:55 sda2
brw-rw---- 1 root disk 8, 3 2009-07-20 15:55 sda3
brw-rw---- 1 root disk 8, 16 2009-07-21 20:43 sdb
however, my dmesg reports this:
Code:
78640.618666] sd 30:0:0:0: [sdb] 15757312 512-byte hardware sectors: (8.06 GB/7.51 GiB)
[78640.620661] sd 30:0:0:0: [sdb] Write Protect is off
[78640.620664] sd 30:0:0:0: [sdb] Mode Sense: 03 00 00 00
[78640.620667] sd 30:0:0:0: [sdb] Assuming drive cache: write through
[78640.624658] sd 30:0:0:0: [sdb] 15757312 512-byte hardware sectors: (8.06 GB/7.51 GiB)
[78640.626659] sd 30:0:0:0: [sdb] Write Protect is off
[78640.626662] sd 30:0:0:0: [sdb] Mode Sense: 03 00 00 00
[78640.626665] sd 30:0:0:0: [sdb] Assuming drive cache: write through
[78640.626669] sdb: sdb1 sdb2
[78640.633034] usb 1-2:1.0: uevent
[78640.633122] usb 1-2: uevent
[78640.899187] usb 1-2:1.0: uevent
[78640.899276] usb 1-2: uevent
[78641.054596] VFS: Can't find ext3 filesystem on dev sdb1.
it takes a bunch of tries of unplugging the usb and plugging it back in until it finally somehow mounts my fat32 partition under /media/disk. Is this some configuration issue? Before I partitioned my sdcard, it was fine mounting just a fat32 partition as the entire card, no problems.
check you hald
/etc/init.d/hald restart
do you have support for udev in you kernel ?
Check this steps and tell us it worked
yes HAL is running and has been running the entire time:
Code:
# rc-update show
alsasound | boot
bootmisc | boot
checkfs | boot
checkroot | boot
clock | boot
consolefont | boot
cupsd | default
dbus | default
hald | default
hostname | boot
keymaps | boot
lm_sensors | default
local | default nonetwork
localmount | boot
modules | boot
net.eth0 | default
net.lo | boot
numlock | default
rdate | default
rmnologin | boot
sshd | default
syslog-ng | default
urandom | boot
xdm | default
Code:
$ ps aux | grep hal
103 3544 0.0 0.0 26956 4032 ? Ss Jul24 0:01 /usr/sbin/hald --use-syslog --verbose=no
root 3545 0.0 0.0 15624 1176 ? S Jul24 0:00 hald-runner
root 3548 0.0 0.0 17748 1124 ? S Jul24 0:00 hald-addon-input: Listening on /dev/input/event1 /dev/input/event0 /dev/input/event3
103 3553 0.0 0.0 16608 968 ? S Jul24 0:00 hald-addon-acpi: listening on acpi kernel interface /proc/acpi/event
root 3558 0.0 0.0 17748 1128 ? S Jul24 0:08 hald-addon-storage: polling /dev/sr0 (every 2 sec)
john5788 4596 0.0 0.0 130688 3120 ? Sl Jul24 0:00 /usr/libexec/gvfs-hal-volume-monitor
root 11452 0.0 0.0 17748 1124 ? S Jul24 0:01 hald-addon-storage: polling /dev/sdb (every 2 sec)
john5788 13851 0.0 0.0 84792 864 pts/1 R+ 10:10 0:00 grep --colour=auto hal
restarting does not help anything.
udevd --version ??
since version 140 those stupids rules messed up with removable devices.
Since I'm lazy I built my kernel with genkernel and it took care of everything about udev.
Code:
# udevd --version
141
so its a rule in udev that is screwin this up?
i'm not using genkernel, I rolled my own kernel out, have been doing it this way for years.
Code:
# uname -a
Linux john5788 2.6.29-gentoo-r5 #1 SMP Fri May 29 16:56:58 PDT 2009 x86_64 Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz GenuineIntel GNU/Linux
John5788 said:
Code:
# udevd --version
141
so its a rule in udev that is screwin this up?
i'm not using genkernel, I rolled my own kernel out, have been doing it this way for years.
Code:
# uname -a
Linux john5788 2.6.29-gentoo-r5 #1 SMP Fri May 29 16:56:58 PDT 2009 x86_64 Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz GenuineIntel GNU/Linux
Click to expand...
Click to collapse
Yeah i think ...
what's the output of dmesg |grep EXT3-fs ?
the output has a bunch of instances last night when i was plugging and unplugging the device. like i said, sometimes it recognized my fat32 partition, sometimes ext3.
Code:
# dmesg | grep EXT3-fs
[ 9016.479321] EXT3-fs warning: mounting unchecked fs, running e2fsck is recommended
[ 9016.481783] EXT3-fs: mounted filesystem with ordered data mode.
[ 9111.770944] EXT3-fs error (device sdb2): ext3_put_super: Couldn't clean up the journal
[ 9134.532699] EXT3-fs warning: mounting unchecked fs, running e2fsck is recommended
[ 9134.534632] EXT3-fs: recovery complete.
[ 9134.536841] EXT3-fs: mounted filesystem with ordered data mode.
[ 9166.843481] EXT3-fs warning: mounting unchecked fs, running e2fsck is recommended
[ 9166.849252] EXT3-fs: mounted filesystem with ordered data mode.
[ 9184.778649] EXT3-fs error (device sdb2): ext3_put_super: Couldn't clean up the journal
[ 9243.636550] EXT3-fs warning: mounting unchecked fs, running e2fsck is recommended
[ 9243.638973] EXT3-fs: recovery complete.
[ 9243.638976] EXT3-fs: mounted filesystem with ordered data mode.
[ 9305.343298] EXT3-fs warning: mounting unchecked fs, running e2fsck is recommended
[ 9305.345249] EXT3-fs: mounted filesystem with ordered data mode.
[ 9328.776678] EXT3-fs error (device sdb2): ext3_put_super: Couldn't clean up the journal
[15048.450805] EXT3-fs: recovery complete.
[15048.452800] EXT3-fs: mounted filesystem with ordered data mode.
[15055.778655] EXT3-fs error (device sdb2): ext3_put_super: Couldn't clean up the journal
ok it seems one of partitions is broken i've looked around the web
try to :
e2fsck -p your /home partitions and
fsck.vfat -p /dev/sdb1 and e2fsck -p /dev/sdb2
I don't use any kind of automation, not even hal, but I have the same issue, without corruption though.
However, I have found that using cfdisk on /dev/sdb makes /dev/sdb{1,2} appear magically, and I can mount them correctly.
That's not really elegant, but it works for me.
I use adb push most of the time anyways, that way I don't have to unmount the SD from the phone and everything is smooth.
Zappletoo said:
I don't use any kind of automation, not even hal, but I have the same issue, without corruption though.
However, I have found that using cfdisk on /dev/sdb makes /dev/sdb{1,2} appear magically, and I can mount them correctly.
That's not really elegant, but it works for me.
I use adb push most of the time anyways, that way I don't have to unmount the SD from the phone and everything is smooth.
Click to expand...
Click to collapse
tht's strange cfdisk should not help mounting the devices but if it work it's worthing give it a try.
it has to be something with hal and rules :
emerge -pv hal dbus
etc-update
should get rid of that problem
PS : Zappletoo what linux distribution are you using ??
Gentoo.
But I don't use HAL, I don't see any good reason to. I'll try to activate it to see if it makes a difference, but I doubt it.
I'm not sure why cfdisk helps, maybe it simply updates the partition table somewhere.
Update : starting hald makes it work. Using partprobe works as well.. So I guess I was right about the partition table part.
what do you mean use cfdisk on it?
did you just select mount from the phone, then run cfdisk /dev/sdb, then immediately quit?
no no run cfdisk on your computer
Edit: yes I misread. That's what he did.
If things goes well your 2 partitions should appear
John5788 said:
what do you mean use cfdisk on it?
did you just select mount from the phone, then run cfdisk /dev/sdb, then immediately quit?
Click to expand...
Click to collapse
Yes, on the computer.
Apparently it does the same as partprobe, which is available in the sys-apps/parted package.
Hald does everything automatically though, but it's bloated.
Never had a problem with gentoo. No Hal...udev 1.41...custom kernel. Somewhere else on this forum however someone pointed out the phone doesn't show up properly in linux without first probing it. i.e. 'fdisk -l /dev/sda'. This has worked for me whenever I choose to mount it (which is almost never cuz i love adb).
So, I'm writing this post so that there is a unified "thing" for G2X and Linux. I just did this on mine, with information from a bunch of different places, so I'd like to make it easier some people (doing it with a guest Windows machine is not fun).
Thanks to jnichols595, and others.
The procedure itself is painless and quick. For me, everything worked from the first time.
1. ROOTING
* download http://forum.xda-developers.com/attachment.php?attachmentid=577906&d=1303754302
* extract it so it is a folder and cd into it with terminal.
* run the following 1 command:
Code:
$ [B]sudo ./root.command[/B]
There appears to be a permissions problem accessing your device
Press Y to try running adb with sudo or any other key to quit: Y
Checking for connected device...
Pushing temporary root exploint (psneuter) to device...
2635 KB/s (585731 bytes in 0.565s)
Running psneuter on device...
property service neutered.
killing adbd. (should restart in a second or two)
Waiting for device...
Remounting /system read/write...
remount succeeded
Pushing su to /system/bin/su...
580 KB/s (26324 bytes in 0.044s)
Pushing busybox to /system/bin/busybox...
1273 KB/s (1062992 bytes in 0.815s)
Installing Superuser.apk android application...
1134 KB/s (196521 bytes in 0.169s)
Removing psneuter from device...
Rebooting device...
Once device has rebooted you should be rooted.
Press Enter when you're ready to quit:
Done, rooted. How do you know? There should be a Pirate's icon in your app menu.
2. INSTALLING CLOCKWORKMOD
* get the nvflash scripts from http://mirror.dal.tdrevolution.net/ctso/g2x/nvflash-recovery.tgz and extract the folder.
* go into the folder and put http://mirrorbrain.cyanogenmod.com/cm/recoveries/recovery-clockwork-3.0.2.7-p999.img in there
* open flash-recovery.sh in that same folder with a text editor and modify the line to say
Code:
sudo ./nvflash --bct E1108_Hynix_512MB_H8TBR00U0MLR-0DM_300MHz_final_emmc_x8.bct --bl fastboot.bin --download 5 recovery-clockwork-3.0.2.7-p999.img
* now open terminal and cd into the folder
* remove the battery on the phone, and plug the cable while holding both VolUp and VolDown keys. Hold like that for 5sec and let go
* in the terminal you opened, execute the commans
Code:
lsusb
to make sure you see something like this:
Code:
Bus 002 Device 008: ID 0955:7f20 NVidia Corp.
* immediately after that, execute the script
Code:
./flash-recovery.sh
this is what I had
Code:
[email protected]:~/Desktop/nvflash$ [B]lsusb[/B]
Bus 003 Device 014: ID 0955:7f20 NVidia Corp.
Bus 003 Device 005: ID 046d:c526 Logitech, Inc. Nano Receiver
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 021: ID 0489:e00f Foxconn / Hon Hai
Bus 001 Device 009: ID 064e:2100 Suyin Corp.
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
[email protected]:~/Desktop/nvflash$ [B]./flash-recovery.sh[/B]
Nvflash started
rcm version 0X20001
System Information:
chip name: unknown
chip id: 0x20 major: 1 minor: 3
chip sku: 0xf
chip uid: 0x038891c443c145d7
macrovision: disabled
hdcp: enabled
sbk burned: false
dk burned: false
boot device: emmc
operating mode: 3
device config strap: 0
device config fuse: 0
sdram config strap: 0
downloading bootloader -- load address: 0x108000 entry point: 0x108000
sending file: fastboot.bin
/ 1024992/1024992 bytes sent
fastboot.bin sent successfully
waiting for bootloader to initialize
bootloader downloaded successfully
sending file: recovery-clockwork-3.0.2.7-p999.img
\ 4308992/4308992 bytes sent
recovery-clockwork-3.0.2.7-p999.img sent successfully
[email protected]:~/Desktop/nvflash$
* as soon as some image appears on your phone saying it's updating, you can unplug the phone
Awesome we have the recovery now.
3. Installing the Custom ROM
This one is a video. It is done on a mac, but the computer system does not matter at this point. You just download it to your computer, and then put the zip on the SD card. Use Up/Down to move and Power to select when in recovery mode. This is the guide: http://theunlockr.com/2011/05/03/how-to-load-a-custom-rom-on-the-t-mobile-g2x/
Awesome. Now you can flash ROMs on your device.
***Credits and thanks go to the developers who came up with this, I just put it together!
aplsux said:
So, I'm writing this post so that there is a unified "thing" for G2X and Linux. I just did this on mine, with information from a bunch of different places, so I'd like to make it easier some people (doing it with a guest Windows machine is not fun).
Thanks to jnichols595, and others.
The procedure itself is painless and quick. For me, everything worked from the first time.
1. ROOTING
* download http://forum.xda-developers.com/attachment.php?attachmentid=577906&d=1303754302
* extract it so it is a folder and cd into it with terminal.
* run the following 1 command:
Code:
$ [B]sudo ./root.command[/B]
There appears to be a permissions problem accessing your device
Press Y to try running adb with sudo or any other key to quit: Y
Checking for connected device...
Pushing temporary root exploint (psneuter) to device...
2635 KB/s (585731 bytes in 0.565s)
Running psneuter on device...
property service neutered.
killing adbd. (should restart in a second or two)
Waiting for device...
Remounting /system read/write...
remount succeeded
Pushing su to /system/bin/su...
580 KB/s (26324 bytes in 0.044s)
Pushing busybox to /system/bin/busybox...
1273 KB/s (1062992 bytes in 0.815s)
Installing Superuser.apk android application...
1134 KB/s (196521 bytes in 0.169s)
Removing psneuter from device...
Rebooting device...
Once device has rebooted you should be rooted.
Press Enter when you're ready to quit:
Done, rooted. How do you know? There should be a Pirate's icon in your app menu.
2. INSTALLING CLOCKWORKMOD
* get the nvflash scripts from http://mirror.dal.tdrevolution.net/ctso/g2x/nvflash-recovery.tgz and extract the folder.
* go into the folder and put http://mirrorbrain.cyanogenmod.com/cm/recoveries/recovery-clockwork-3.0.2.7-p999.img in there
* open flash-recovery.sh in that same folder with a text editor and modify the line to say
Code:
sudo ./nvflash --bct E1108_Hynix_512MB_H8TBR00U0MLR-0DM_300MHz_final_emmc_x8.bct --bl fastboot.bin --download 5 recovery-clockwork-3.0.2.7-p999.img
* now open terminal and cd into the folder
* remove the battery on the phone, and plug the cable while holding both VolUp and VolDown keys. Hold like that for 5sec and let go
* in the terminal you opened, execute the commans
Code:
lsusb
to make sure you see something like this:
Code:
Bus 002 Device 008: ID 0955:7f20 NVidia Corp.
* immediately after that, execute the script
Code:
./flash-recovery.sh
this is what I had
Code:
[email protected]:~/Desktop/nvflash$ [B]lsusb[/B]
Bus 003 Device 014: ID 0955:7f20 NVidia Corp.
Bus 003 Device 005: ID 046d:c526 Logitech, Inc. Nano Receiver
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 021: ID 0489:e00f Foxconn / Hon Hai
Bus 001 Device 009: ID 064e:2100 Suyin Corp.
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
[email protected]:~/Desktop/nvflash$ [B]./flash-recovery.sh[/B]
Nvflash started
rcm version 0X20001
System Information:
chip name: unknown
chip id: 0x20 major: 1 minor: 3
chip sku: 0xf
chip uid: 0x038891c443c145d7
macrovision: disabled
hdcp: enabled
sbk burned: false
dk burned: false
boot device: emmc
operating mode: 3
device config strap: 0
device config fuse: 0
sdram config strap: 0
downloading bootloader -- load address: 0x108000 entry point: 0x108000
sending file: fastboot.bin
/ 1024992/1024992 bytes sent
fastboot.bin sent successfully
waiting for bootloader to initialize
bootloader downloaded successfully
sending file: recovery-clockwork-3.0.2.7-p999.img
\ 4308992/4308992 bytes sent
recovery-clockwork-3.0.2.7-p999.img sent successfully
[email protected]:~/Desktop/nvflash$
* as soon as some image appears on your phone saying it's updating, you can unplug the phone
Awesome we have the recovery now.
3. Installing the Custom ROM
This one is a video. It is done on a mac, but the computer system does not matter at this point. You just download it to your computer, and then put the zip on the SD card. Use Up/Down to move and Power to select when in recovery mode. This is the guide: http://theunlockr.com/2011/05/03/how-to-load-a-custom-rom-on-the-t-mobile-g2x/
Awesome. Now you can flash ROMs on your device.
***Credits and thanks go to the developers who came up with this, I just put it together!
Click to expand...
Click to collapse
With the G2X as long as you get clockworkmod recovery on your phone you can flash any compatible rom. No need to root first.
And if you do want to root your existing rom, just get clockworkmod on your phone and then flash the root zip file that jboxer has posted in the development section. It issues the commands and installs su and superuser.apk for you, and sets the proper permissions for those files.
phburks said:
With the G2X as long as you get clockworkmod recovery on your phone you can flash any compatible rom. No need to root first.
Click to expand...
Click to collapse
Yes, as long as you are going to a custom ROM. However, if you don't want the whole thing, i.e. just root - easier and quicker.
phburks said:
And if you do want to root your existing rom, just get clockworkmod on your phone and then flash the root zip file that jboxer has posted in the development section. It issues the commands and installs su and superuser.apk for you, and sets the proper permissions for those files.
Click to expand...
Click to collapse
Awesome!
aplsux said:
Yes, as long as you are going to a custom ROM. However, if you don't want the whole thing, i.e. just root - easier and quicker.
Awesome!
Click to expand...
Click to collapse
Notice that that zip doesn't install busybox but it can be easily installed from the Market once you have root access.
Here's a link to the thread.
http://forum.xda-developers.com/showthread.php?t=1255214
CleverCoder's Guide to Mounting Android’s Internal Storage As A Mass Storage USB Device
I found inspiration from this guide: http://mohammadag.xceleo.org/mounting-your-android-devices-internal-storage/
His process did not work exactly, but by changing the “lun” to “lun0” and the path to the “android_usb” device, I was able to get this to work with my rooted Samsung Note 10.1. The instructions below were verified on my Note 2.
I was motivated to find this solution after I accidentally deleted my daughters world that she worked so hard to create in Survivalcraft. Ultimately, I wasn’t able to recover her world, but I learned a lot in the process. Enjoy!
Steps:
Boot into recovery mode (Usually holding volume (and home) down while powering up). I find the Wiki on CyanogenMod to be helpful to find device-specific bootloader instructions.
Invoke a root shell using ADB: “adb shell" (Note: This assumes you have the Android SDK installed and /platform-tools are in your PATH)
Find the /data partition, determine the block device that corresponds to it:
Code:
mount | grep /data
…
/dev/block/mmcblk0p16 on /data type ext4 (rw,seclabel,relatime,user_xattr,barrier=1,data=ordered)
…
Click to expand...
Click to collapse
Make a note of the block device name. In my case, it's "/dev/block/mmcblk0p16". Unmount the /data partition to allow mounting as a mass storage device:
Code:
umount /data
Locate the “mass storage” device LUN entry. (In my case, it was ..\lun0 rather than ..\lun):
Code:
find /sys -name lun*
…
/sys/devices/platform/s3c-usbgadget/gadget/lun0
/sys/devices/virtual/android_usb/android0/f_mass_storage/lun0
…
Click to expand...
Click to collapse
In this case, we want to make a note of the entry with "f_mass_storage" in it. This is the entry that corresponds to a USB Mass Storage device.
Map the block device to the mass storage logical device LUN “file”. Note, this will be a file called “file” within the LUN folder. For example:
"/sys/devices/virtual/android_usb/android0/f_mass_storage/lun/file":
~# echo BLOCK_DEVICE_HERE > LUN_FILE_PATH_HERE
For example:
Code:
echo /dev/block/mmcblk0p16 > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun0/file
Note: the ADB shell appears to wrap at around 80 characters, making it look like the line is split.
Reconfigure the USB device in “mass storage” mode. This has to be done in one command, since it will terminate the ADB connection. Also, the path varies to the “android_usb” device. It may be:
/sys/devices/virtual/android_usb/android0/
/sys/class/android_usb/android0/
You can use "find /sys -name *android0*" to help narrow the options. I believe either entry will work. YMMV
On my Note 2 the following worked:
Code:
echo "echo 0 > /sys/devices/virtual/android_usb/android0/enable && echo \"mass_storage,adb\" > /sys/devices/virtual/android_usb/android0/functions && echo 1 > /sys/devices/virtual/android_usb/android0/enable" > enable_mass.sh
sh enable_mass.sh &
This should terminate the ADB connection and cause a new USB device to appear, representing the /data volume mounted as a mass storage device.
At this time, the block device associated with the /data partition should show up as a USB mass storage device on your computer. I verified this with OSX. OSX did not support the ext3/4 filesystem, however, Unix utilities that support it will work.
Recovering Files
Once the device is mounted on your host machine, you can use PhotoRec (http://www.cgsecurity.org/wiki/PhotoRec) to recover files. It performs a file signature based recovery, is very powerful, and works with any file you can think of. It’s also easy to add support for your own file types.
I hope this helps others.
Cheers!
- Sean
Have anyone tried it?
Failed while do the step with the lun0/file.
Permission denied
Quite interesting :good: and works as expected with lun/file
Thanks for this amazing post
great
command done for E300K over Wifi adb
while system running normally
working great thanks
Code:
echo /dev/block/mmcblk0p20 > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun0/file
echo 0 > /sys/devices/virtual/android_usb/android0/enable
echo "mass_storage,adb" > /sys/devices/virtual/android_usb/android0/functions
echo 1 > /sys/devices/virtual/android_usb/android0/enable
---------- Post added at 05:10 AM ---------- Previous post was at 05:08 AM ----------
wondering how we could mount many partition at the same time
will see
Edit : seems to be related to the module that provide mass storage gadget, it's set to 1 emulation for the moment... i think i have to recompile that stuff and/or the kernel to have this feature... any way not for now ^^
Note : an alternative to check deleted files is R-Studio work well
Some Hint Please?
CleverCoder said:
CleverCoder's Guide to Mounting Android’s Internal Storage As A Mass Storage USB Device
I found inspiration from this guide: http://mohammadag.xceleo.org/mounting-your-android-devices-internal-storage/
His process did not work exactly, but by changing the “lun” to “lun0” and the path to the “android_usb” device, I was able to get this to work with my rooted Samsung Note 10.1. The instructions below were verified on my Note 2.
I was motivated to find this solution after I accidentally deleted my daughters world that she worked so hard to create in Survivalcraft. Ultimately, I wasn’t able to recover her world, but I learned a lot in the process. Enjoy!
Steps:
Boot into recovery mode (Usually holding volume (and home) down while powering up). I find the Wiki on CyanogenMod to be helpful to find device-specific bootloader instructions.
Invoke a root shell using ADB: “adb shell" (Note: This assumes you have the Android SDK installed and /platform-tools are in your PATH)
Find the /data partition, determine the block device that corresponds to it:
Code:
mount | grep /data
Make a note of the block device name. In my case, it's "/dev/block/mmcblk0p16". Unmount the /data partition to allow mounting as a mass storage device:
Code:
umount /data
Locate the “mass storage” device LUN entry. (In my case, it was ..\lun0 rather than ..\lun):
Code:
find /sys -name lun*
In this case, we want to make a note of the entry with "f_mass_storage" in it. This is the entry that corresponds to a USB Mass Storage device.
Map the block device to the mass storage logical device LUN “file”. Note, this will be a file called “file” within the LUN folder. For example:
"/sys/devices/virtual/android_usb/android0/f_mass_storage/lun/file":
~# echo BLOCK_DEVICE_HERE > LUN_FILE_PATH_HERE
For example:
Code:
echo /dev/block/mmcblk0p16 > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun0/file
Note: the ADB shell appears to wrap at around 80 characters, making it look like the line is split.
Reconfigure the USB device in “mass storage” mode. This has to be done in one command, since it will terminate the ADB connection. Also, the path varies to the “android_usb” device. It may be:
/sys/devices/virtual/android_usb/android0/
/sys/class/android_usb/android0/
You can use "find /sys -name *android0*" to help narrow the options. I believe either entry will work. YMMV
On my Note 2 the following worked:
Code:
echo "echo 0 > /sys/devices/virtual/android_usb/android0/enable && echo \"mass_storage,adb\" > /sys/devices/virtual/android_usb/android0/functions && echo 1 > /sys/devices/virtual/android_usb/android0/enable" > enable_mass.sh
sh enable_mass.sh &
This should terminate the ADB connection and cause a new USB device to appear, representing the /data volume mounted as a mass storage device.
At this time, the block device associated with the /data partition should show up as a USB mass storage device on your computer. I verified this with OSX. OSX did not support the ext3/4 filesystem, however, Unix utilities that support it will work.
Recovering Files
Once the device is mounted on your host machine, you can use PhotoRec (http://www.cgsecurity.org/wiki/PhotoRec) to recover files. It performs a file signature based recovery, is very powerful, and works with any file you can think of. It’s also easy to add support for your own file types.
I hope this helps others.
Cheers!
- Sean
Click to expand...
Click to collapse
Hello sir, I want to ask you.
What recovery version do you use? Philz Touch? TWRP or another? can you please help me.? I am using Galaxy Note II device (GT-N7100)
When I am using TWRP recovery I can do all steps you provide but no luck. Then I am try using Philz Touch, adb shell is error, Device Not Found.
What can I do? Can you please help me? :good:
I need to recover some photos that I accidentally deleted.
Hi Sean,
This is a great idea!!! I've been struggling for the past two weeks to recover data from my HTC One M7 ever since I accidentally hit the factory reset button!:crying:
I got a few questions...
Does this method work on my M7 which has only the internal memory and no SD card?
IIf I'm trying this directly on a terminal window on he phone, how would the last command change?
Also, once done, how do we mount /data back?
Sorry for the noob questions!
Thanks a lot!
No response from HTC One M7
Hello Experts,
I tried the above mentioned method on my HTC One M7. It was lun0 in my case. I have unmounted /data. However, I still found that mmcblkp037 that was mounted on /data was still linked to /sdcard for some reason. I proceeded to unmount /sdcard too. (There is no SD card in my device btw).
After unmounting both /data and /sdcard, I proceeded to edit the lun0/file and then the long command all in one go. Unfortunately nothing happens, the adb shell remains active and I do not see a USB device appearing on My Computer. I've added the snapshots from the terminal window.
Can someone please help?:crying:
Thanks!!!
So i am trying to run this so that i can do a photo recovery on the internal storage. At first i wasn't getting the list of mmcblk0p and what they were assigned to. I found a different command that I think returns the correct information ( mmcblk0p26) when i make it to the end, it mounts it on my pc as the cd rom drive, but i cant do anything with it and it doesnt show up in my recovery program. I ran the command again and i got ( mmcblk0p26-orig) but again at the end, i still only have the cd rom that it mounts. im not sure if im not pointing to the correct mmcblk or what im missing. Any help is appreciated.
anyone?
Issues with step 4 umount
Hi together,
I have issues by proceeding step 4. "umount /data" it all the times says: "umount: bad /etc/fstab: No such file or directory"
I tried so many things to solve it.
Could you please help me?
I am unable to switch to mass_storage on my Moto G 2013.
I tried with DriveDriod Android App and it successfully enabled mass_storage but I am unable toreplicate the same manually.
This is what I tried:
[email protected]:/sdcard # find /sys -name lun*
/sys/devices/virtual/android_usb/android0/f_mass_storage/lun
/sys/devices/platform/msm_hsusb/gadget/lun0
[email protected]:/sdcard #
[email protected]:/sdcard # mount | grep /data
/dev/block/mmcblk0p36 on /data type f2fs (rw,seclabel,nosuid,nodev,noatime,nodiratime,background_gc=on,user_xattr,inline_xattr,acl,inline_data,nobarrier,active_logs=6)
[email protected]:/sdcard #
[email protected]:/sdcard # echo "/dev/block/mmcblk0p36" > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun/file
[email protected]:/sdcard #
[email protected]:/sdcard # setprop sys.usb.config mass_storage,adb
Click to expand...
Click to collapse
No luck in mounting the partition as UMS.
Please Help.
Thanks.
@CleverCoder im trying this on a OneplusX but it ends up showing as unallocated space in gparted. Any clue?
All worked fine with a bq aquaris a4.5.
~#: umount /data
umount: can't umount /data: Invalid argument
Click to expand...
Click to collapse
Why can't I unmount the /data partition?
Any hints please?
Useful guide. Thanks. :good:
Additionally, you may look into kernel source of your device or simply into these USB related initramfs files for further details what you need to edit on your device:
/init.qcom.usb.rc
/init.usb.rc
/init.recovery.usb.rc (on TWRP)
Click to expand...
Click to collapse
You can find in these files the USB vendor id and product id values provided by your device manufacturer or Google. These values should be fed to corresponding files so that PC may properly identify your phone as a USB mass storage device. In given example, 2717 is USB Vendor ID of Xiaomi; manufacturer of Redmi Note 4.
Sample init.qcom.usb.rc (RN4/mido):
Code:
# Following are the parameters required for usb functionality. They provide configurable options like
# product_id/vendor id and allows specifying required functions:
#
# Required parameters:
#
# /sys/class/android_usb/android0/enable: Enables/disables usb composition
# Value: 0 (disable), 1 (enable)
[...]
# /sys/class/android_usb/android0/functions: Stores name of the function drivers used in usb composition.
# Value: Passed one per function driver. e.g. diag[,adb]
[...]
on property:sys.usb.config=mass_storage,adb && property:sys.usb.configfs=0
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/iSerial ${ro.serialno}
write /sys/class/android_usb/android0/idVendor 2717
write /sys/class/android_usb/android0/idProduct FF28
write /sys/class/android_usb/android0/functions adb,mass_storage
write /sys/class/android_usb/android0/enable 1
start adbd
setprop sys.usb.state ${sys.usb.config}
#Mass-storage only composition
on property:sys.usb.config=mass_storage && property:sys.usb.configfs=0
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/iSerial ${ro.serialno}
write /sys/class/android_usb/android0/idVendor 2717
write /sys/class/android_usb/android0/idProduct FF20
write /sys/class/android_usb/android0/functions mass_storage
write /sys/class/android_usb/android0/enable 1
setprop sys.usb.state ${sys.usb.config}
A good source is https://android.googlesource.com/kernel/common/+/bcmdhd-3.10/Documentation/usb/mass-storage.txt
Code:
[B]mido:/ #[/B] (find / -maxdepth 1 -type f) | while read fyle; do grep -iE "/sys.{,}lun" "$fyle" && printf ">>> $fyle\n\n"; done
/sys/class/android_usb/android0/f_mass_storage/lun/file
/sys/class/android_usb/android0/f_mass_storage/lun/file
>>> /init.usb.rc
[...]
[B]mido:/ #[/B] find /sys -iname lun*
/sys/devices/soc/7000000.ssusb/7000000.dwc3/gadget/lun0
/sys/devices/virtual/android_usb/android0/f_mass_storage/lun
[...]
[B]mido:/ #[/B] file /sys/class/android_usb/android0/f_mass_storage/lun
/sys/class/android_usb/android0/f_mass_storage/lun: symbolic link to ../../../../soc/7000000.ssusb/7000000.dwc3/gadget/lun0
[B]mido:/ #[/B] file /sys/class/android_usb/f_mass_storage/lun
/sys/class/android_usb/f_mass_storage/lun: symbolic link to ../../../../soc/7000000.ssusb/7000000.dwc3/gadget/lun0
[B]mido:/ #[/B] file /sys/devices/virtual/android_usb/android0/f_mass_storage/lun
/sys/devices/virtual/android_usb/android0/f_mass_storage/lun: symbolic link to ../../../../soc/7000000.ssusb/7000000.dwc3/gadget/lun0
[B]mido:/ #[/B] file /sys/class/android_usb/android0
/sys/class/android_usb/android0: symbolic link to ../../devices/virtual/android_usb/android0
So, the original files to modify are:
/sys/devices/soc/7000000.ssusb/7000000.dwc3/gadget/lun0
and
/sys/devices/virtual/android_usb/android0
Click to expand...
Click to collapse
All others are symlinks. Check your devices accordingly.
Simply use these files:
Code:
echo '0' > /sys/class/android_usb/android0/enable
echo '/dev/block/mmcblk0p**' > /sys/class/android_usb/android0/f_mass_storage/lun/file; # replace ** with partition number
echo 'mass_storage,adb' > /sys/class/android_usb/android0/functions
If your /data partition is encrypted and TWRP can decrypt it, you should use:
Code:
echo '/dev/block/dm-0' > /sys/class/android_usb/android0/f_mass_storage/lun/file
Additional settings:
Code:
setprop persist.sys.usb.config mass_storage,adb
setprop sys.usb.config mass_storage,adb; # disabling mtp will probably cause adb unauthorized
If you want to mount /data read-only, being on safe side or to avoid overwrite if want to recover deleted stuff:
Code:
echo '1' > /sys/class/android_usb/android0/f_mass_storage/lun/ro
And finally:
Code:
echo '1' > /sys/class/android_usb/android0/enable
Don't try this in running ROM, it's only for recovery mode.
Don't forget to unmount /data from your computer before disconnecting. Otherwise eMMC may get corrupted.
You can mount other partitions having a filesystem (like /system or /cache) in similar way, but that's rarely needed.
Can you tell me how to disable mass_storage again? revert everything back?
osrl said:
Can you tell me how to disable mass_storage again? revert everything back?
Click to expand...
Click to collapse
"sysfs" is a volatile filesystem. Everything is reset on reboot. Or you may revert changes manually:
Code:
echo 0 >/sys/class/android_usb/android0/enable
echo "" >/sys/class/android_usb/android0/f_mass_storage/lun/file
setprop persist.sys.usb.config adb
setprop sys.usb.config adb
echo 1 >/sys/class/android_usb/android0/enable
honor 9 error lun
Hello, On my Honor 9 I'm trying to do the same but I'm stuck on
find /sys -name lun*
Click to expand...
Click to collapse
because this command gives no lines found, it seems that I don't have any directory with "lun" written in it, so I'm unable to continue the tutorial, what am I doing wrong?
eyewee said:
honor 9 error lun
Hello, On my Honor 9 I'm trying to do the same but I'm stuck on
because this command gives no lines found, it seems that I don't have any directory with "lun" written in it, so I'm unable to continue the tutorial, what am I doing wrong?
Click to expand...
Click to collapse
i met this same problem. My phone is OPPO R15x PBCM.
i have ever installed an apk named UMS interface which can be downloaded from coolapk and found its code in github . this apk can allow root user create an image in their sdcard and mount it as a usb device or mount an external sd card as a usb device. the latter is like ums enabler .
it work normally, until i reinstalled OS of my phone. then it always return Mass storage Unit is not ready. i take a glance at the code of the apk, and found this warning exist only when /sys/devices/virtual/android_usb/android0/f_mass_storage/lun doesn't exist. exactly, /sys/devices/virtual/android_usb/android0/f_mass_storage/ doesn't exist. when i ls /sys/devices/virtual/android_usb/android0, it only return f_audio_source f_midi power state subsystem uevent, not
Code:
f_mass_storage
. no matter i reinstalled OS for many times, nothing become normal.
Code:
grep f_mass_storage /init.usb.rc
will return
Code:
chown system system /sys/class/android_usb/android0/f_mass_storage/lun/file
chmod 0660 /sys/class/android_usb/android0/f_mass_storage/lun/file
, but i don't know its meaning. i don't have enough knowledge about android.
thanks anyone for help!
Hi, please do you know how to mount the full disk (all partitions) of an android device so that I can make a "dd" backup for another phone? (same model) Thanks for help!
ps: I'm now at the adb shell of the device, on ubuntu I have disks mounted as /dev/sda or /dev/sdb ... I have on my android device many many things in /dev and I don't find any sd* ; isn't the same thing?!
Hello all.
I'm coming to you with a problem I'm facing with my black 32gb T-Mobile LG G2.
Situation:
While attempting to install Cyanogenmod 13.0 (stable/snapshot), I've run into an issue where I somehow rooted it with towelroot on 4.2.2, then upgraded to 4.4.2, then 5.0.2, rooted again with KingRoot, then attempted to re-install TWRP as the 5.0.2 OTA update somehow erased it. Once AutoRec Lollipop (D801 version) finished installing. Version 2.8.6.0 was flashed using AutoRec. I rebooted the phone into recovery and proceeded to flash CM 13. According to TWRP, CM 13 was successfully installed, but when I rebooted after installing the CM package, and Google Apps, it rebooted to the LG logo, then came up with tiny white text saying "Boot certification verify" or whatever... I think "Oh crap"... I did something wrong... I continue by attempting to boot into Recovery by holding the power and volume down buttons, it shows the white screen with the yes or no options, I hit yes for all of them, it shows the LG logo, then continues to show the boot certification error... I look it up, and find out that it's a bad install of TWRP, just boot into Download mode and reflash the stock KDZ in the LG Flash Tool... I plug it into my other PC running Windows 7 Pro 32-bit, I hold the power and volume up buttons, it reboots, flashes the LG logo, then comes up with the dark blue "Download Mode" text with the dots below it, then goes black and starts faintly blinking between backlight off and backlight on... So that's my situation that I've been struggling with since August 24th, 2016.
In it's current state, it only sometimes shows up on my main desktop running Linux when I run ls /dev/sd*
It only shows my primary and secondary drives... Being my 128 gb SSD and my 1 TB storage drive.
However, if I spam ls /dev/sd*, it shows up intermittently.
Here's a paste directly from my terminal window.
[[email protected] /]# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sdb /dev/sdb1
[[email protected] /]# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sdb /dev/sdb1
[[email protected] /]# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sdb /dev/sdb1
[[email protected] /]# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sdb /dev/sdb1
[[email protected] /]# ls /dev/sd*
/dev/sda /dev/sdb1 /dev/sdc11 /dev/sdc15 /dev/sdc19 /dev/sdc22 /dev/sdc26 /dev/sdc3 /dev/sdc33 /dev/sdc37 /dev/sdc5 /dev/sdc9
/dev/sda1 /dev/sdc /dev/sdc12 /dev/sdc16 /dev/sdc2 /dev/sdc23 /dev/sdc27 /dev/sdc30 /dev/sdc34 /dev/sdc38 /dev/sdc6
/dev/sda2 /dev/sdc1 /dev/sdc13 /dev/sdc17 /dev/sdc20 /dev/sdc24 /dev/sdc28 /dev/sdc31 /dev/sdc35 /dev/sdc39 /dev/sdc7
/dev/sdb /dev/sdc10 /dev/sdc14 /dev/sdc18 /dev/sdc21 /dev/sdc25 /dev/sdc29 /dev/sdc32 /dev/sdc36 /dev/sdc4 /dev/sdc8
[[email protected] /]# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sdb /dev/sdb1
[[email protected] /]# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sdb /dev/sdb1
[[email protected] /]#
When I follow this guide: http://forum.xda-developers.com/showthread.php?t=2582142, the "'dd" command returns "input output error". I have tried like 4 different USB cables which plug in and work fine on my friend's Galaxy SIII, but strangely don't work with the G2.
On my windows 7 machine, it shows up in Device Manager as 2 instances of QHSUSB_BULK one of which is resolved to "Qualcomm HS-USB 9006" once I install the LG and Qualcomm drivers. Windows suggests the other one is a USB Mass Storage device when I tell it to do the automatic install aka "Search for software automatically", but it always fails when it gets to the "Installing driver software" step.
I need help because I've followed almost every guide out there to no avail.
Problem has been solved. No need for 3rd party solutions.
THREAD CLOSED!!!