Tuesday, October 31, 2017

sd card - Is there any way to recover data from 2nd SD partition?


From the beginning. I was using Link2SD in order to save up some internal memory, but today I noticed that all apps moved to to second partition (EXT2) magically disappeared. I don't want to repair Link2SD because I'm going to change phone very soon. I want to recover data from /data/sdext2, but i can't mount it. I want to recover this data because I change SDCard too. Link2SD saying something about invalid argument during creating mount script. Is there any way to access this data so far? Or I must say goodbye to them?


PS. First partition is safe and sound. It works great.



Answer



To access second partition on SD card if it's not deleted, you may adopt multiple approaches listed below. For deleted partitons or deleted files, you may use tools like testdisk and extundelete which doesn't seem to be the case here.


LINUX / WINDOWS


As mentioned by @iBug, you can remove SD card from phone and insert in a PC with Linux OS like Ubuntu. You will be able to access both partitions there. File browsers like Nautilus and Dolphin by default show all formatted partitions in left panel on newly inserted media.
In order to directly mount a partition from Android device to Linux PC, you can expose it as a USB Mass Storage device. By default UMS is disabled on newer devices but can be enabled by a little hacking.


Windows by default only mounts first accessible partition on SD cards and other removable media. However, if you want to access second partition on Windows, it is possible. You need to make SD card a local hard disk drive using a hacked driver like Cfadisk usb driver. Follow this link for detailed guide.



ACCESS 2nd PARTITION FROM ANDROID


Some custom builds of TWRP auto-mount SD card second partition under something like /sd-ext etc. If not so, you can mount it yourself in Android recovery or ROM, as you seem to have already rooted device.



  1. Reboot in TWRP recovery and use built-in terminal app there. Or if you want to do it from ROM, install terminal emulator app like Terminal Emulator if you don't have one already. Third option is to use adb, in ROM or in recovery.


  2. Find how kernel names block devices on your phone:


    ~# ls /dev/block/

    You will find a number of devices there. On a typical Qualcomm device, mmcblk0 will be representing internal memory i.e. eMMC and mmcblk1 will be representing external SD card. Though there will be many other internal partitions and loop devices, we are concerned with three entries of external SD card:


    mmcblk1    mmcblk1p1    mmcblk1p2


    Here mmcblk1p2 is the second partition on SD card.




  3. For confirmation:


    ~# fdisk /dev/block/mmcblk1p2

    This will show details about SD card second partition including size.





  4. Mount partition:


    ~# mkdir /sd_ext
    ~# mount -o ro /dev/block/mmcblk1p2 /sd_ext

    First command will create a directory sd_ext under your root which you may access from any file explorer or command-line. ro option in second command will mount the partition read-only so that you may not harm any data accidentally. You may eliminate this.
    If not successful, you may need to specify filesystem yourself what you used at the time of partitioning:


    ~# mount -t ext4 -o ro /dev/block/mmcblk1p2 /sd_ext

    To know which filesystem a partition has:


    ~# blkid /dev/block/mmcblk1p2


    There are many other tools that can be used for the purpose like parted, fsck and tune2fs etc. but these might not be necessarily available.




  5. Mounted partition will be un-mounted automatically on reboot. You can do this manually:


    ~# umount /sd_ext


NOTE:




  1. Be cautious not to touch second partition on internal memory which may belong to bootloader. Or you may brick your phone.

  2. All commands used above need root access and binaries are included in TWRP. You may install busybox in ROM if any command not found.


RELATED:



No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...