{"id":975,"date":"2020-09-08T00:51:00","date_gmt":"2020-09-07T21:51:00","guid":{"rendered":"https:\/\/blog.andresgomez.org\/?p=975"},"modified":"2020-09-07T22:30:34","modified_gmt":"2020-09-07T19:30:34","slug":"installing-lineageos-in-the-sony-xperia-xz2-compact-dual-in-gnu-linux-2-5-backing-up-the-trim-area-ta-partition","status":"publish","type":"post","link":"https:\/\/blog.andresgomez.org\/es\/2020\/09\/08\/installing-lineageos-in-the-sony-xperia-xz2-compact-dual-in-gnu-linux-2-5-backing-up-the-trim-area-ta-partition\/","title":{"rendered":"Installing LineageOS in the Sony Xperia XZ2 Compact Dual (in GNU\/Linux) 2\/5: Backing up the Trim Area (TA) partition"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">WARNING<\/h2>\n\n\n\n<p>I have no responsibility whatsoever if this guideline causes any harm to your device. The intention of these posts are solely as personal notes for myself. Follow them at your own risk.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">WARNING<\/h2>\n\n\n\n<p>Through these steps I will unlock the phone&#8217;s bootloader, erasing all data. This includes the DRM keys stored in the Trim Area (TA) partition. I&#8217;ll attempt backing them up but, as of today, there is no way of restoring them to the previous state nor knowing if the actual backup is usable at all.<\/p>\n\n\n\n<p>Without these DRM keys, several audio and video proprietary functionality provided by Sony <a rel=\"noreferrer noopener\" href=\"https:\/\/developer.sony.com\/develop\/open-devices\/get-started\/unlock-bootloader\" data-type=\"URL\" data-id=\"https:\/\/developer.sony.com\/develop\/open-devices\/get-started\/unlock-bootloader\" target=\"_blank\">won&#8217;t be available<\/a> <strong>including some camera post-processing features<\/strong>, color gamut profiles, white balance, noise reduction, X-Reality Video Enhancement, DSEE HX, ClearAudio+, and Widevine L1 support for HD Netflix.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Backup the TA partition<\/h2>\n\n\n\n<p>As explained in the <a href=\"https:\/\/blog.andresgomez.org\/2020\/09\/07\/installing-lineageos-in-the-sony-xperia-xz2-compact-dual-in-gnu-linux-1-5-downgrading-sonys-stock-firmware\" data-type=\"URL\" data-id=\"https:\/\/blog.andresgomez.org\/2020\/09\/07\/installing-lineageos-in-the-sony-xperia-xz2-compact-dual-in-gnu-linux-1-5-downgrading-sonys-stock-firmware\" target=\"_blank\" rel=\"noreferrer noopener\">previous post<\/a>, enable developer mode in the phone.<\/p>\n\n\n\n<p>Following <a href=\"https:\/\/forum.xda-developers.com\/xperia-xz2\/development\/xz2-xz2c-xz2p-xz3-temp-root-exploit-via-t4099131\" data-type=\"URL\" data-id=\"https:\/\/forum.xda-developers.com\/xperia-xz2\/development\/xz2-xz2c-xz2p-xz3-temp-root-exploit-via-t4099131\" target=\"_blank\" rel=\"noreferrer noopener\">this guide<\/a>, <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/topjohnwu\/Magisk\/releases\" data-type=\"URL\" data-id=\"https:\/\/github.com\/topjohnwu\/Magisk\/releases\" target=\"_blank\">download<\/a> the latest Magisk release. At the time of writing this it&#8217;s v20.4.<\/p>\n\n\n\n<p>Download the <a rel=\"noreferrer noopener\" href=\"https:\/\/forum.xda-developers.com\/attachment.php?attachmentid=5024311&amp;d=1590158031\" data-type=\"URL\" data-id=\"https:\/\/forum.xda-developers.com\/attachment.php?attachmentid=5024311&amp;d=1590158031\" target=\"_blank\">tama-mroot.zip<\/a> with the needed exploit.<\/p>\n\n\n\n<p>Push both archives into the phone (you may need to give consent in a pop up dialog in the phone):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root$ adb push tama-mroot\/tama-mroot.zip Magisk\/Magisk-v20.4.zip \/data\/local\/tmp\ntama-mroot\/tama-mroot.zip: 1 file pushed. 0.5 MB\/s (21355 bytes in 0.039s)\nMagisk\/Magisk-v20.4.zip: 1 file pushed. 32.0 MB\/s (5942417 bytes in 0.177s)\n2 files pushed. 25.4 MB\/s (5963772 bytes in 0.224s)<\/pre>\n\n\n\n<p>Get into the phone and follow the steps to get a root shell:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root$ adb shell\nH8324:\/ $ cd \/data\/local\/tmp\nH8324:\/data\/local\/tmp $ unzip tama-mroot.zip\nArchive: tama-mroot.zip\ninflating: magisk-start.sh\ninflating: magisk-setup.sh\ninflating: tama-mroot\nH8324:\/data\/local\/tmp $ chmod 755 tama-mroot magisk-setup.sh magisk-start.sh\nH8324:\/data\/local\/tmp $ .\/magisk-setup.sh\n\n[...]\n\nH8324:\/data\/local\/tmp $ cd \/data\/local\/tmp\nH8324:\/data\/local\/tmp $ .\/tama-mroot\n\n[...]\n\nroot_by_cve-2020-0041:\/data\/local\/tmp # .\/magisk-start.sh -1\n\n[...]\n\nroot_by_cve-2020-0041:\/data\/local\/tmp # .\/magisk-start.sh -2\n\n[...]\n\nroot_by_cve-2020-0041:\/data\/local\/tmp # .\/magisk-start.sh -3\n\n[...]<\/pre>\n\n\n\n<p>We can verify now that we have really <em>root<\/em> privileges:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root_by_cve-2020-0041:\/data\/local\/tmp # id\nuid=0(root) gid=0(root) groups=0(root),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats),3009(readproc),3011(uhid) context=u:r:magisk:s0\nroot_by_cve-2020-0041:\/data\/local\/tmp # uname -a\nLinux localhost 4.9.186-perf+ #1 SMP PREEMPT Fri Jan 17 01:22:05 2020 aarch64<\/pre>\n\n\n\n<p>Hence, let&#8217;s go ahead and back up the TA partition:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root_by_cve-2020-0041:\/data\/local\/tmp # dd if=\/dev\/block\/bootdevice\/by-name\/TA of=TA-locked.img\n4096+0 records in\n4096+0 records out\n2097152 bytes (2.0 M) copied, 0.039839 s, 50 M\/s\nroot_by_cve-2020-0041:\/data\/local\/tmp # chown shell:shell TA-locked.img\nroot_by_cve-2020-0041:\/data\/local\/tmp # sync\nroot_by_cve-2020-0041:\/data\/local\/tmp # sync<\/pre>\n\n\n\n<p>Now, from another terminal in the computer, pull the created backup:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root$ adb pull \/data\/local\/tmp\/TA-locked.img<\/pre>\n\n\n\n<p>That&#8217;s it, we have finished backing up the TA partition!<\/p>\n\n\n\n<p>Now, we can continue to <a href=\"https:\/\/blog.andresgomez.org\/2020\/09\/09\/installing-lineageos-in-the-sony-xperia-xz2-compact-dual-in-gnu-linux-3-5-installing-lineageos\" data-type=\"URL\" data-id=\"https:\/\/blog.andresgomez.org\/2020\/09\/09\/installing-lineageos-in-the-sony-xperia-xz2-compact-dual-in-gnu-linux-3-5-installing-lineageos\" target=\"_blank\" rel=\"noreferrer noopener\">install the LineageOS system<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WARNING I have no responsibility whatsoever if this guideline causes any harm to your device. The intention of these posts are solely as personal notes for myself. Follow them at your own risk. WARNING Through these steps I will unlock &hellip; <a href=\"https:\/\/blog.andresgomez.org\/es\/2020\/09\/08\/installing-lineageos-in-the-sony-xperia-xz2-compact-dual-in-gnu-linux-2-5-backing-up-the-trim-area-ta-partition\/\">Sigue leyendo <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,6,7,20],"tags":[],"class_list":["post-975","post","type-post","status-publish","format-standard","hentry","category-english","category-free-software","category-general","category-mobile"],"_links":{"self":[{"href":"https:\/\/blog.andresgomez.org\/es\/wp-json\/wp\/v2\/posts\/975"}],"collection":[{"href":"https:\/\/blog.andresgomez.org\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.andresgomez.org\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.andresgomez.org\/es\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.andresgomez.org\/es\/wp-json\/wp\/v2\/comments?post=975"}],"version-history":[{"count":6,"href":"https:\/\/blog.andresgomez.org\/es\/wp-json\/wp\/v2\/posts\/975\/revisions"}],"predecessor-version":[{"id":996,"href":"https:\/\/blog.andresgomez.org\/es\/wp-json\/wp\/v2\/posts\/975\/revisions\/996"}],"wp:attachment":[{"href":"https:\/\/blog.andresgomez.org\/es\/wp-json\/wp\/v2\/media?parent=975"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.andresgomez.org\/es\/wp-json\/wp\/v2\/categories?post=975"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.andresgomez.org\/es\/wp-json\/wp\/v2\/tags?post=975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}