[HOW TO] Install Android system on SATA (SSD or HDD)

21 12231
gaara  
Edited by gaara at Sat Mar 21, 2015 11:48

I have worked few days to put my Android system on an SSD (Sandisk 64GB), and I share here my method, because it's really faster to run with it.

Prerequisite:
- Knowing to build an Android image, with all working drivers. See the mattrix post.
I'm using Kubuntu 14.10 x64 to do it, but 14.04 is better (with make version 3.8)
- Knowing to burn the image with Phoenix Card (100% works with win7 x64)
- Install cfdisk and dd on your Ubuntu system
- A usb - sata adapter to plug the sata drive on Ubuntu
- A SD card reader on Ubuntu system

The steps:
1) Modify the source to redirect system to load from the SATA drive
2) Compilation
3) Burnig the SD card
4) Cloning the card on the SATA drive
5) Create a new partition in the drive
6) Format the new partition
7) Plug all (SD and SATA drive) on the Banana/Orange Pi)
8) START !

All is good ? So let's go !

Details:

1) There's just one file to modify
/ANDROID/android/device/softwinner/sugar-lemaker/init.sun7i.rc

At the begining of this file, there are some lines which are here to mount the differents partitions. We are going to modify it:

a) on early-init
- Comment mkdir /mnt/sata 0000 system system -> #mkdir /mnt/sata 0000 system system
  1. #mkdir /mnt/sata 0000 system system
Copy the Code
The others line on this block are the same.

b) on early-fs
- Change /dev/block/system to /dev/block/sda7
  1. mount ext4 /dev/block/sda7 /system wait noatime nodev barrier=0
Copy the Code
c) on fs
- Add a block to mount /sdcard, it will be in the future partition (the largest partition)
  1. on fs
  2. # try to mount /sdcard
  3.     wait /dev/block/sda4
  4.     mount vfat /dev/block/sda4 /mnt/sdcard defaults
Copy the Code
- Modify the # try to mount /data block:
Replace all the /dev/block/data by /dev/block/sda8 (5 x)
  1. # try to mount /data
  2.     wait /dev/block/sda8
  3.     mount ext4 /dev/block/sda8 /data wait noatime nosuid nodev barrier=1
  4.     setupfs /dev/block/sda8
  5.     umount /data
  6.     exec /system/bin/logwrapper /system/bin/e2fsck -y /dev/block/sda8
  7.     exec /system/bin/busybox mount -t ext4 -o noatime,nosuid,nodev,barrier=1,journal_checksum,noauto_da_alloc /dev/block/sda8 /data
Copy the Code
- Optionnal: modify the # try to mount /cache:
The cache is the swap of the system, if you have HDD no problem you can modify it.
For a SSD it's better to have the cache in the SD card, so don't modify it. (but I'm a bad guy, I have done it, unless I have a SSD)
Replace all the /dev/block/cache by /dev/block/sda10
  1. # try to mount /cache
  2.     mount ext4 /dev/block/sda10 /cache wait noatime nosuid nodev barrier=1
  3.     setupfs /dev/block/sda10
  4.     umount /cache
  5.     exec /system/bin/logwrapper /system/bin/e2fsck -y /dev/block/sda10
  6.     exec /system/bin/busybox mount -t ext4 -o noatime,nosuid,nodev,barrier=1,journal_checksum,noauto_da_alloc /dev/block/sda10 /cache
Copy the Code
- # try to mount /private
No need to modify it, this stay on the SD card.

- Modify the # try to format /databk:
Replace all the /dev/block/databk by /dev/block/sda13
  1. # try to format /databk
  2.     wait /dev/block/sda13
  3.     mount ext4 /dev/block/sda13 /databk wait noatime nosuid nodev barrier=1
  4.     setupfs /dev/block/sda13
  5.     umount /databk
  6.     rmdir /databk
Copy the Code
The end of this file is the same!
Save and quit your text editor.
Note: this file contains also all the insmod, the drivers you can load at the startup. But it's another thing, it should be done before this.

2) Compile the Android image (all the details are in the Mattrix post)

3) Burn it with Phoenix Card

4) Cloning the SD card into the SSD/HDD:
I'm using Ubuntu to do it.
First, you must know where are the SD card and your SATA drive. For this I'm using Gparted but others solutions can be used.
For me, SD is /dev/sdc
and SSD is /dev/sdd
So X an Y must be yours.
The command to clone is:
  1. sudo dd if=/dev/sdX of=/dev/sdY bs=4M
Copy the Code
Be carreful with dd, it's a dangerous command with your Ubuntu system if you go wrong.
It take about 5 min to copy all the SD card.

5) Create a new partition in the SATA disk (/dev/sda4 in Android, but /dev/sdY4 in Ubuntu)
  a) I'm using cfdisk to do it.
  1. sudo cfdisk /dev/sdY
Copy the Code
You should see 12 partitions in there (even if /dev/sdY13 exist). In fact, /dev/sdY4 don't exist, we will create it.
Navigate at the end of the partitions, there's free space.

With the menu, select this:
- New
- type the size you want (It should be possible to create 2 or 3 partitions if you want*)
- Type -> navigate up and select W95 FAT32 (first page, the menu is big)

- Write -> confirm with typing "yes"
- Quit

  b) We need to format the new partition in Fat32:
  1. sudo mkfs -t vfat /dev/sdY4
Copy the Code
(it can be sdb4 or sdc4, be careful)

Now, all is done !
You can remove the SD card and the drive from your Ubuntu system, and plug it on your Banana/Orange Pi.

Turn on your board and enjoy the new speed !!!

You can verify your storage, mine is 51.26GB


*TODO: increase the size of /data partition. It's actually 1GB and already 150Mo is used. With time it should be full. If I find a solution I will post it.
Sure, if you find, don't hesitate!
Excellent, thx!

gaara  
Thanks for your approbation

kbrowne  
gaara replied at Sat Mar 21, 2015 10:27
Thanks for your approbation

Hi.  Thanks very much for your excellent quick  response.

My only query is that I cannot find  the android source code anywhere so I am going to attempt to modify a live SD image via $abd shell.

I am happy with the  Android 4.2.2 image which I am currently using so the issue is to just port this across to the HDD..

Thanks once again!!

gaara  
You can find the sources here: https://github.com/Tony-HIT/lemaker_android
And unfortunately, you must compile it with my changes to have the Android system working on sata drive.

kbrowne  
gaara replied at Sat Mar 21, 2015 11:22
You can find the sources here: https://github.com/Tony-HIT/lemaker_android
And unfortunately, you mu ...

Hi.. got this message

Repository unavailable due to DMCA takedown.

And when I tried to git clone it is asking me for a username and password.


So it looks like the early bird caught the worm..lol

gaara  
Maybe you ca ask the password to Tony in private, I don't know... I had the source before it had been locked !

kbrowne  
gaara replied at Sat Mar 21, 2015 11:47
Maybe you ca ask the password to Tony in private, I don't know... I had the source before it had bee ...

Hi.. finally got the source files.. just need to build a quicker Ubuntu machine... which I am hoping to have finished tonight...

liab  
@gaara
Thank you for the good manual, works on the first try. Only copy was a long time, 250 GB SDD with usb-adapter and cfdisk made a error, so I used fdisk.

You can change the partition size in

/ANDROID/lichee/tools/pack/chips/sun7i/configs/android/sugar-bpi/sys_partition.fex
example
;------------------------------>mmcblk0p7/nandd
[partition]
    name         = system
    size         = 2097152
    downloadfile = "system.fex"
    user_type    = 0x1

;------------------------------>mmcblk0p8/nande
[partition]
    name         = data
    size         = 4194304
    user_type    = 0x1

Boot is faster (30 sec) with a small android. Ca. 15 sec faster than from a sd-card. Now I shall test it with a full android.

gaara  
Edited by gaara at Sun Mar 22, 2015 11:05

@liab
Thanks for your try! Yep, 250GB via usb is a little slow xD
I will try today to change the partition size with your help. I just hope the SD partition size is set automatically (like the end of the card), because my 8GB SD is already full with the defaults settings.
In one day of use (and some apps installed), my /data is now 319Mo/1GB ... So yes, 4GB will not too much.

Edit: 4194304 sectors is not 4GB like I thought, but 2GB. And 2097152 sectors 1GB. This works after burning the SD card, I will set the double.

Too bad I can't edit my tutorial, I should add your "update".

You have to log in before you can reply Login | Sign Up

Points Rules