Cubietruck image file copy to sdcard

Setup / Background

The process in this post came about when trying to get an lubunutu-desktop-v1.03-card0-4gen.img file to deploy to an already setup SD card.
Here is the SDCards partition table:

$ fdisk -l /dev/mmcblk0
Device Boot        Start      End     Blocks    Id    System
/dev/mmcblk0p1      2048   133119      65536    83    Linux
/dev/mmcblk0p2    133120  1578119    7812500    83    Linux
/dev/mmcblk0p3  15757120  31383119   7812500    83    Linux

The partitions are as follows:

  1. Boot (copied / dd’d boot image for cubietruck)
  2. Server build – 8GB (for testing server build)
  3. Desktop build – 8GB (yet to deploy…. this article)

The Issue

There is an empty partition for the deployment of desktop-image.
The image file comes as a full-disk-image with (at least) 2 partitions, one for the boot and the other for the OS.
The ‘standard’ deployment method will destroy my existing (server) partition.


Partition Access

$ fdisk -l lubuntu-desktop-xxxxxx-.img
Units = sectors of 1 * 512 = 512 bytes
     Start      End   Blocks Id System
      2048   133119    65536 83 Linux
    133120  6424575  314572  83 Linux
The important bits of data are the sectors and start (bits) as this will give us the begnning of the mount.
Calculating the offset =  sectors * start for the particular partition that you want to mount.

$ loset --offset $((133120*512)) /dev/loop1 lubuntu-xxxxx-.img
fsck /dev/loop1 #this is just to run a quick disk scan to check it

Copying image

Now that the source data is accessible, its easy and quick to get the image onto the correct partition on the sdcard.
$ sudo dd if=/dev/loop1 of=/dev/mmcblk0p3 bs=1M

Setting the boot OS

The choice of which OS to boot is a manual config in the boot file, this is partly on-purpose (in my case).

$ sudo mkdir /mnt/sdcard
$ sudo mount -t ext2 /dev/mmcblk0p1 /mnt/sdcard
Edit the file “/mnt/sdcard/uEnv.txt”, and change line with the ‘root=’ parameter

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s