Jump to content

[Guide] How to backup and successfully restore the system partition.


Recommended Posts

Posted

Moving on from the original hudl (RK3188 based) to the later hudl2 (Intel Atom based) it's been evident to me, just how thin on the ground commercial development tools are for the Intel Atom tablets - from the point of view of availability via the internet to non commercial developers/end users. With all the available RK3188 tools out there, the original hudl is well catered for, whereas it's still early days for the hudl2 - hopefully this will change soon .......

In this thread "This will definately come in useful" which points to the original xda thread, vampirefo has supplied both CWM and TWRP tethered recoveries that boot and work on our hudl2's. Until recently, I didn't think any more about it - they work great for rooting and just assumed they'd be able to create nandroid backups, now having had some spare time, the nandroid backups that are produced are not exactly 100% and needed to return to basics to create a reliable partition backup process.

The system partition, in my view, is a very important partition to have a working backup of, I could think of many ways in which it could become semi or totally screwed (enough to cause boot loops and boot failures), so having a working backup that you can restore back, to a known state is ideal.

In this guide, I'll be posting and referencing in one place, multiple sources of information that have taken a while to pull together and organise into a meaningful flow to allow someone to create a backup system partition and how to successfully restore it.

CAUTION: This information is provided as a best effort forum post - USE THIS INFORMATION AT YOUR OWN RISK.

Pre-requisites are as follows: -

  • A computer running Windows (this procedure has been tested using a laptop with Windows 10 64-bit).
  • A rooted hudl2 running any ROM version.
  • A microSD card with at least 2GB free (optional but recommended and used here).
  • A microUSB cable to connect the hudl2 to your computer.
  • Download and unzipped ANDROID_IMG_REPACK_TOOLS by A.S._id from xda website.
  • Downloaded and unzipped ADB / Fastboot tools from Paul's post.
  • Correctly installed Google ADB interface and ADB Fastboot drivers (if required from xda or equivalent).
  • Ensure USB debugging is enabled. In 'Settings -> About', tap the 'build number' like a madman until a message appears stating developer mode has been enabled. Then use 'Settings -> Development' to enable USB debugging.
  • Plug the device into your computer using the microUSB cable. A message will pop up on screen asking you to authorise the connection.

 Before we can create a raw system partition backup we need to be able to determine which flash block contains that partition: -

  • Open a command prompt / terminal window to the location where you extracted the files e.g. C:\Hudl_test
  • Type 'adb devices' - you should see a device is found and listed as attached.
c:\Hudl2_test>adb devices
List of devices attached
170914PE5145927 device
  • Type 'adb shell' - this now connects us to our hudl2 and the prompt should change to something like 'shell@HTF8A4:/ $'
c:\Hudl2_test>adb shell
shell@HTF8A4:/ $
  • We need to change to root so that we have the right permissions to be able to carryout all the commands - at this point you may be prompted on your hudl2 to approve this change via your SuperSu app, just tap 'GRANT'. The prompt will now change from '$' to '#'.
shell@HTF8A4:/ $ su
su
root@HTF8A4:/ #
  • Now lets list the partition table, to find the block names, type 'cat /proc/partitions'.
root@HTF8A4:/ # cat /proc/partitions
cat /proc/partitions
major minor  #blocks  name

 179        0   15269888 mmcblk0
 179        1     133120 mmcblk0p1
 179        2      33792 mmcblk0p2
 179        3      16384 mmcblk0p3
 179        4      16384 mmcblk0p4
 179        5      16384 mmcblk0p5
 179        6      32768 mmcblk0p6
 179        7      32768 mmcblk0p7
 179        8     131072 mmcblk0p8
 179        9     131072 mmcblk0p9
 179       10     131072 mmcblk0p10
 179       11    1572864 mmcblk0p11
 179       12    1048576 mmcblk0p12
 179       13    2097152 mmcblk0p13
 179       14       2048 mmcblk0p14
 179       15    9852908 mmcblk0p15
 179       16   31166976 mmcblk1
 179       17   31162880 mmcblk1p1
  • To find out which block relates to the system partition, type 'ls -al /dev/block/platform/intel/by-label'. We can now see the system partition is located at /dev/block/mmcblk0p13.
root@HTF8A4:/ # ls -al /dev/block/platform/intel/by-label
ls -al /dev/block/platform/intel/by-label
lrwxrwxrwx root     root              2015-08-14 10:13 ESP -> /dev/block/mmcblk0p2
lrwxrwxrwx root     root              2015-08-14 10:13 boot -> /dev/block/mmcblk0p3
lrwxrwxrwx root     root              2015-08-14 10:13 cache -> /dev/block/mmcblk0p11
lrwxrwxrwx root     root              2015-08-14 10:13 config -> /dev/block/mmcblk0p10
lrwxrwxrwx root     root              2015-08-14 10:13 data -> /dev/block/mmcblk0p15
lrwxrwxrwx root     root              2015-08-14 10:13 factory -> /dev/block/mmcblk0p8
lrwxrwxrwx root     root              2015-08-14 10:13 fastboot -> /dev/block/mmcblk0p5
lrwxrwxrwx root     root              2015-08-14 10:13 logs -> /dev/block/mmcblk0p12
lrwxrwxrwx root     root              2015-08-14 10:13 misc -> /dev/block/mmcblk0p9
lrwxrwxrwx root     root              2015-08-14 10:13 panic -> /dev/block/mmcblk0p7
lrwxrwxrwx root     root              2015-08-14 10:13 recovery -> /dev/block/mmcblk0p4
lrwxrwxrwx root     root              2015-08-14 10:13 reserved -> /dev/block/mmcblk0p1
lrwxrwxrwx root     root              2015-08-14 10:13 reserved_1 -> /dev/block/mmcblk0p6
lrwxrwxrwx root     root              2015-08-14 10:13 rom -> /dev/block/mmcblk0p14
lrwxrwxrwx root     root              2015-08-14 10:13 system -> /dev/block/mmcblk0p13

Now let's create a raw backup of the system partition: -

  • To create a raw backup of the system partition to your microSD card, type 'dd if=/dev/block/mmcblk0p13 of=/storage/sdcard1/system.raw.img'. This will take some time as the raw system partition's size is 2GB. Once the copy has finished the prompt will return.
root@HTF8A4:/ # dd if=/dev/block/mmcblk0p13 of=/storage/sdcard1/system.raw.img
/storage/sdcard1/system.raw.img                                               <
4194304+0 records in
4194304+0 records out
2147483648 bytes transferred in 828.271 secs (2592730 bytes/sec)
root@HTF8A4:/ #
  • Type 'exit' twice to close our connection to the hudl2.
root@HTF8A4:/ # exit
exit
shell@HTF8A4:/ $ exit
exit

Technically, that's it for creating a raw backup of the system partition. To be on the safe side, transfering to and storing it on your PC would be a better safeguard against disaster. In it's current 'raw' state, you could go on to mount it on a linux computer, add / remove files and then unmount it. But that's not going to be much good unless we can restore it back to the hudl2.

Converting a 'raw' system partition into a flashable 'sparse' system partition: -

The 'raw' 2GB system partition file can't be restored to our hudl2 in it's current state - the fastboot utility that we'll be using to flash it back to our hudl2 requires it to be in a 'sparse' format. But that's just a simple matter of processing it with one of the Android IMG Repack Tools, so lets continue.......

  •  However you wish, copy the 2GB 'system.raw.img' file from your sdcard to your computer and save it into our working directory from before i.e. C:\Hudl_test.
  • Ensure all our files are in the same directory or accessible from this directory.
 Directory of c:\Hudl2_test

14/08/2015  12:33    <DIR>          .
14/08/2015  12:33    <DIR>          ..
16/10/2014  15:23           819,200 adb-windows.exe
16/10/2014  15:23            96,256 AdbWinApi.dll
16/10/2014  15:23            60,928 AdbWinUsbApi.dll
04/03/2015  14:09         3,265,340 cygwin1.dll
20/11/2014  02:08            81,437 cygz.dll
28/04/2015  00:55           575,282 ext2simg.exe
16/10/2014  15:23           160,256 fastboot-windows.exe
28/04/2015  00:55            10,882 file_contexts
28/04/2015  00:55            96,729 img2simg.exe
28/04/2015  00:55           587,891 make_ext4fs.exe
28/04/2015  00:55            82,979 mkbootfs.exe
28/04/2015  00:55            76,474 mkbootimg.exe
28/04/2015  00:55             1,583 mkuserimg.sh
28/04/2015  00:55            70,649 sgs4ext4fs.exe
28/04/2015  00:55            96,538 simg2img.exe
28/04/2015  00:55            97,599 simg2simg.exe
01/01/1970  01:59     2,147,483,648 system.raw.img
28/04/2015  00:55            73,343 unpackbootimg.exe
              18 File(s)  2,153,737,014 bytes
  • Convert from 'raw' to 'sparse' partition formats, type 'ext2simg system.raw.img system.sparse.img'
c:\Hudl2_test>ext2simg system.raw.img system.sparse.img
  • We can now see the partition size has shrunk from 2GB to approx 1.5GB
01/01/1970  01:59     2,147,483,648 system.raw.img
14/08/2015  12:47     1,579,316,908 system.sparse.img

Restoring and flashing our backup system partition: -

  • Open a command prompt / terminal window to the location where you extracted the files e.g. C:\Hudl_test
  • Ensure your hud2 is connected to you computer via the microUSB cable.
  • Type 'adb devices' - you should see a device is found and listed as attached.
c:\Hudl2_test>adb devices
List of devices attached
170914PE5145927 device
  • Reboot the hudl2 into bootloader mode, type 'adb-windows reboot bootloader'. 
c:\Hudl2_test>adb-windows reboot bootloader
adb server is out of date.  killing...
* daemon started successfully *

Your hudl2 will now reboot into bootloader mode, at this point please ensure that you have no unknown devices or devices with yellow '?' in your windows device list, in device manager. On my machine, the hudl2 is now listed as a 'Fastboot interface (Google USB ID)' within the 'ADB Interface' branch.

Your hudl2 should be sitting waiting on the 'Droidboot' screen and the bottom of the screen should be like below.

E:installer device ignored
FASTBOOT INIT...
E:installer device ignored
FASTBOOT CMD WAITING...
E:installer device ignored
E:No valid installer medium found. 
  • To restore the system image back to your hudl2, type 'fastboot-windows -i 0x1d4d flash system system.sparse.img'.

While the download is happening the bottom green line will be animated and the second from bottom line will read 'RECEIVING DATA...' at this point you MUST NOT DISCONNECT your hudl2 until the process has finished or you could end up with a bricked device.

When the process has completely finished the bottom of your hudl2 screen should say 'RESULT: OKAY' and your computer command prompt output should be similar to that shown below.

c:\Hudl2_test>fastboot-windows -i 0x1d4d flash system system.sparse.img
target reported max download size of 1260710570 bytes
sending sparse 'system' (1212025 KB)...
OKAY [ 78.676s]
writing 'system'...
OKAY [ 58.232s]
sending sparse 'system' (330276 KB)...
OKAY [ 20.635s]
writing 'system'...
OKAY [ 16.770s]
finished. total time: 174.329s

c:\Hudl2_test>

IF YOU CAN SEE the 'RESULT: OKAY' on your hudl2 screen, you can now select 'REBOOT' by pressing the 'vol-' key and selecting it by pressing the 'power' button. Your hudl2 will now reboot and should boot normally all the way to your android desktop / lock screen.

IF YOU SEE 'FLASH FAILED' or something similar on your hudl2 screen, the flash process has failed and could be due to various reasons - mainly the system partition you're trying to flash is incorrect or in the wrong format i.e. not a sparse image. One of the safer ways of recovering from this situation would be to carry out the 'flash-windows' command again but with a known good system image build - BEFORE YOU DO ANYTHING ELSE LIKE REBOOT YOUR HUDL2. To do this reference Paul's thread and download his latest or relevant build depending on your circumstances.

  • To reflash with Paul's last system partition build, type 'fastboot-windows -i 0x1d4d flash system system.hudl2.rooted.20150106.154003.ONLY.r1.img'

This isn't ideal but at least it should place your hudl2 into a known build state - I've used this 20150106 image many times, even though it's been flashed on top of a later 20150529 build.

 

Hopefully the above is helpful to some people and some may appreciate everything (mainly) being in the one post.

:ninja:

 

(For reference extra background info can be found here relating to dumping android partitions.)

Posted (edited)

Just Tried this and it works Thanks very much

Your welcome, don't worry I wouldn't have posted it if I hadn't tried it a couple of times - the code sections are the actual outputs from one of the trials.

The final section on converting the 'raw' image to a flashable 'sparse' image was the hardest step for me to find out. At least now, there's nothing to stop anyone creating 'stock' or 'rooted' system partition builds if they want to ....

Edited by Guest
Guest hudl2student
Posted (edited)

Thanks CaptainMidnight for sharing and explaining all the steps clearly, it is very much appreciated

I look forward to giving this a go at some stage. Just to clarify - images can be made and restored in this way from both rooted and stock unrooted devices?

Edited by hudl2student
Posted (edited)

Good question - so far I've only tested this on a rooted device.

Update: You can only do this (via an android terminal app) with root permissions because of the  'dd' command not being able to access the block directory.

u0_a890HTF8A4:/ $ dd if=/dev/block/mmcblk0p13 of=/storage/sdcard1/test.img
/dev/block/mmcblk0p13: cannot open for read: Permission denied

 

Edited by Guest
Posted (edited)

After some initial issues and some well timed updates and thanks to robin0800 and vampirefo:

My previous post reply to hudl2student wasn't the most rounded it could have been, so is updated here instead after giving the above thanks: - 

  • Stock hudl2 - use either tethered recoveries (i.e. CWM or TWRP) while they're sitting at their menus, 'adb shell' to your hudl2 and you'll find you're automatically sitting at a root prompt (#) - so you can use the 'dd' command. But note here you'll have to change your destination from '/storage/sdcard1/' to '/external_sd/'.
  • Rooted hudl2 - use the same methods for stock hudl2 above or as per my 1st post.

 

 

Edited by Guest
  • 2 weeks later...
Guest hudl2student
Posted

Thanks CaptainMidnight for that.

Do you happen to know if it's possible from tethered CWM/TWRP to create full working nandroid backups?

Posted

Do you happen to know if it's possible from tethered CWM/TWRP to create full working nandroid backups?

I can't see why they wouldn't work ....... but bare in mind, to re-install such backups your hudl2 would have to be able to boot enough for adb to work - otherwise even though you have a nandroid backup you won't be able to restore it.

  • 2 weeks later...
Guest gingerneil
Posted

Thanks CaptainMidnight for that.

Do you happen to know if it's possible from tethered CWM/TWRP to create full working nandroid backups?

I did this last night - backed up my wife's hudl2 using tethered CWM and then restored it back to mine, again using tethered CWM. Worked perfectly... but wish I'd seen this method of doing just the system image first! Took ages to do all her data!

Posted

At least it's  coming in handy for people, which was the point of trying to put it in it's own thread.

  • 3 weeks later...
Guest bbthebeard
Posted

Worked for me thanks. Only problem i had was you state that you only need a windows pc! However the only way i could get the Android img repack tool to work was with a Linux computer. Can you get it to work on a pc? If so how

Posted (edited)

Worked for me thanks. Only problem i had was you state that you only need a windows pc! However the only way i could get the Android img repack tool to work was with a Linux computer. Can you get it to work on a pc? If so how

Are we talking of different things?

All listed commands and output were lifted from a command shell on a Windows 10 Po (x64) build laptop while I wrote the guide.

As per the guide I posted I used the 'ext2simg' utility from the linked xda site to 'convert' the dd raw output to a sparse image format that is used when restoring. I've not repacked the system image file, I've just changed the format from raw to sparse. 

If i wanted to 'adjust' the contents within the system image, then yes, I'd ideally revert to making that change via a computer running Linux or booted with a live Linux cd.

Edited by Guest

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.