Cloning UP Board disk

From UpWiki
Jump to: navigation, search

Cloning and Restoring UP Board disk

Create an image of an existing installation

The steps below assume a Ubuntu installation with default partition layout.


Required:

Ubuntu USB Live disk.

USB Storage Disk EXT4 formatted greater then the size of UP Board eMMC disk to be cloned.


  • Plug the Ubuntu Live Disk and storage disk into the UP Board to be cloned
  • Power cycle board and press F7 for boot options.
  • Select the Ubuntu Live Disk and press Enter
  • Make sure the storage disk is mounted in
/media/upboard/<storage disk name>/
  • Create an image of the eMMC disk.
sudo dd if=/dev/mmcblk0 of=/media/upboard/<storage disk name>/upboard_image.img bs=1M status=progress

Resize image file

This step is useful where the new target disk is smaller then the original source disk.

  • Map the image file created in the previous steps to a loopback block device.
sudo losetup -f /media/upboard/<storage disk name>/upboard_image.img
  • Get the loopback block device name setup in previous step
losetup | grep upboard_image | cut -d " " -f1
/dev/loop1
  • Resize the image partitions using gparted
sudo gparted /dev/loop1

Gparted resize partition.jpg


  • When finished resizing in Gparted, detach the image file from the loop device
sudo losetup -d /dev/loop1
  • Shrink the size of the image file to some size in bytes, big enough to contain all the partitions along with some free space at the end.
truncate upboard_image.img -s 15572402176

Restore image file onto new UP Board

  • Plug Ubuntu Live Disk and storage disk with image file into UP Board
  • Power cycle board and press F7 for boot options.
  • Select Ubuntu Live Disk and press Enter
  • Make sure the storage disk is mounted in
/media/upboard/<storage disk name>/
  • Copy the image file to the UP Board

sudo dd if=upboard_image.img of=/dev/mmcblk0 bs=1M status=progress && sync

Warning Warning: The UP Board secondary GPT data is stored at the end of the eMMC storage device. If this GPT data is overridden in the above steps the board will be BRICKED!!!. It is important to complete the following step to ensure valid secondary GPT data before rebooting the device
sudo gdisk /dev/mmcblk0 

At the gdisk prompt enter the options to repair the GPT parition table:

v and Enter to verify disk

x and Enter to enter expert mode

e and Enter to relocate backup data structures to end of disk

w and Enter to write changes to disk

q and Enter to quit gdisk

  • Re-scan the partition table and create a block device for each partition
sudo partprobe /dev/mmcblk0
  • Check and fix any filesystem errors on the partitions
sudo fsck -f -y /dev/mmcblk0p1
sudo fsck -f -y /dev/mmcblk0p2
  • Power of the board, remove the Ubuntu live USB stick and disk with image file
sudo poweroff