[Atrix 4G Android Development] sendust7:
Dual Boot: Clone Existing ROM and Data to SD Card

Since launching this thread, there's been substantial interest in cloning an existing ROM (and data) to sdcard. Here's how I did it. Note this is a “one-shot” in that data would not shared between identical ROMs in a dual boot configuration.

Let me if you think this effort warrants another thread. If there's enough positive response, I'll consider doing this, and maybe try to automate the procedure in the form of a shell script or flashable zip.

Instructions

Boot to CWM 5.0.2.0 and connect phone to computer. Using adb, enter phone shell and then unmount /cache and mount /sdcard. If necessary, create sdcard partitions for /system, /data and /cache, as described in my original “Dual Boot Atrix” thread on XDA. If these already exist but are not empty, erase them (some patience required):

~ # dd if=/dev/zero of=/dev/block/mmcblk1p2
dd: writing '/dev/block/mmcblk1p2': No space left on device
675841+0 records in
675840+0 records out
346030080 bytes (330.0MB) copied, 129.953894 seconds, 2.5MB/s

~ # dd if=/dev/zero of=/dev/block/mmcblk1p3
dd: writing '/dev/block/mmcblk1p3': No space left on device
1351681+0 records in
1351680+0 records out
692060160 bytes (660.0MB) copied, 252.087508 seconds, 2.6MB/s

~ # cat /dev/zero > /dev/block/mmcblk1p4

I think the “no space left” errors occur due to a slight mismatch in partition sizes between emmc and sdcard.

Now, ensure that /sdcard is mounted and that emmc /system, /cache and /data are unmounted...

~ # mount
rootfs on / type rootfs (rw)
tmpfs on /dev type tmpfs (rw,relatime,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
/dev/block/mmcblk1p1 on /sdcard type vfat (rw,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)

Clone ROM1 to SD Card

~ # dd if=/dev/block/mmcblk0p12 > /dev/block/mmcblk1p2
655360+0 records in
655360+0 records out
335544320 bytes (320.0MB) copied, 133.545277 seconds, 2.4MB/s

~ # dd if=/dev/block/mmcblk0p15 > /dev/block/mmcblk1p3
1310720+0 records in
1310720+0 records out
671088640 bytes (640.0MB) copied, 276.158175 seconds, 2.3MB/s

~ # cat /dev/block/mmcblk0p16 > /dev/block/mmcblk1p4
~ #

For me, cloning the /data partition (mmcblk0p16) (2GB) took about 6 minutes.

Modify Boot Image

To boot ROM1 off sdcard, the ROM1 boot image must first be modified to redirect the /system, /cache and /data mount commands from emmc to sdcard (just three lines of code in “init.olympus.rc”). In my case, ROM1 = CM9. So I modify Joker “stock” CM9 boot image to create “boot-cm9-sdcard.img”, linked here: http://www.mediafire.com/?ecehjm3awppalae. See my original thread “Dual Boot Atrix” for more detail.

Now power down, enter fastboot and flash the modified boot image:

root@ubuntu:~/Desktop# fastboot flash boot boot-cm9-sdcard.img
sending 'boot' (2842 KB)...
OKAY [ 0.194s]
writing 'boot'...
OKAY [ 0.254s]
finished. total time: 0.448s
root@ubuntu:~/Desktop# fastboot reboot
rebooting...

finished. total time: 0.000s
root@ubuntu:~/Desktop#

I did so and my CM9 clone booted, complete with apps. Of course, this took a little longer than usual since CM9 was rebuilding cache. Also, it was booting off my Class 4 sdcard instead of internal memory.

Now I will cross-verify that CM9 was cloned to sdcard using the android “mount” command. Note the device partitions for /system, /cache and /data.

shell@android:/ # mount
rootfs / rootfs ro,relatime 0 0
tmpfs /dev tmpfs rw,nosuid,relatime,mode=755 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
none /dev/cpuctl cgroup rw,relatime,cpu 0 0
/dev/block/mmcblk1p2 /system ext4 ro,noatime,nodiratime,barrier=1,data=ordered 0 0
/dev/block/mmcblk1p4 /data ext4 rw,nosuid,nodev,noatime,nodiratime,barrier=1,data=ordered,noauto_da_alloc 0 0
/dev/block/mmcblk1p3 /cache ext4 rw,nosuid,nodev,noatime,nodiratime,barrier=1,data=ordered,noauto_da_alloc 0 0
/dev/block/mmcblk0p13 /osh ext4 rw,nodev,noatime,nodiratime,barrier=1,data=ordered,noauto_da_alloc 0 0
/dev/block/loop0 /pds ext3 rw,relatime,data=ordered 0 0
/dev/block/vold/179:33 /mnt/sdcard vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/block/vold/179:33 /mnt/secure/asec vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
tmpfs /mnt/sdcard/.android_secure tmpfs ro,relatime,size=0k,mode=000 0 0
/dev/block/vold/179:18 /mnt/emmc vfat

Done. Cheers.