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

Search This thread

[xzel]

Member
Jul 21, 2016
13
7
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 :cowboy:
 
Last edited:

[xzel]

Member
Jul 21, 2016
13
7
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.
 
  • Like
Reactions: Unreal_Hawkz
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.
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..?
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    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 :cowboy:
    1
    Table reserved for 2
    1
    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.
    1
    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..?
    I believe you can mount it thru termux but I havent tried, I tried this on an Ubuntu system.