Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Cloning EMMC-booting PCplus

Featured Replies

NOTE: Despite similar topic names, a search did not find a topic which even remotely  addressed my topic on this site.

 

I have an OrangePi Pcplus on which I have successfully transferred my working system from SD card to the on-board EMMC.

Now, on the assumption that the EMMC may eventually become corrupted or the board dies. (Hey, __it happens!) I need to

create, from the currently running system,  an SD card which I can plug into a brand new Orange Pi PCplus and have it boot

from that card the system I was was running on the old board at the time I made the backup - which I can then transfer to

the new board's EMMC.  Obviously, this same SD card image would be very useful for making multiple systems.
    At present, the only VERY UNSATISFACTORY procedure that seems to be available is to tar the entire EMMC, make an SD

card from the same image I originally used to build the original system and untar the whole lot over the top which may or

may not work at all, I haven't tried that and I am very skeptical that it would work without a lot of editing.

 

Can anyone shed some (lucid) light on this problem?

 

Peter.

 

3 hours ago, OldBikerPete said:

Can anyone shed some (lucid) light on this problem?


Three things that matters:

- tar of filesystem is just fine

- you need to adjust UUID in /boot/armbianEnv.txt on a new system

- transfer boot loader

 

Or you want that Armbian developers also finance development of SATISFACTORY backup and restore applications that will cover this job for you? Well, you can also do that. 

  • Author

I have put together an answer that worked for me.

 

No, I don't want to fund Armbian developers to write SATISFACTORY backup program/s. Firstly,
very capable multi-purpose backup program suites already exist for Linux and secondly, this
particular backup problem is too deep in the bits and bytes - especially given the clues
you have given me.

 

 

To produce the micro SD card I have described there are a number of simple steps, all 
executed from the command line interface.
The following is quite wordy and tries to be appropriate for users who are not familiar with
Linux command line and its suite of utilities.

1.  Find or produce an at-least-minimally-set-up appropriate Armbian system on a micro SD card,
    preferably the same version of Armbian that you are running on your EMMC memory. We are
    going to extract the bootloader off this SD card and it needs to be appropriate to the
    Armbian on the EMMC. Alternatively, you may be able to download a binary image, if so,
    skip steps 3 and 4.

2.  Log in as root (for preference) on a command-line terminal to your EMMC-centred PC+ by some
    means. If you do not log in as root, you will have to preface most (all) of the typed
    commands given below with 'sudo' and re-enter your password several times.
    
3. Insert this SD card into the OrangePi PC Plus that you wish to clone the Armbian from.
   Wait a few seconds for Armbian to recognise it then type    'ls /dev/mmcblk*'
     Armbian should respond with something like:
        /dev/mmcblk0    /dev/mmcblk1             /dev/mmcblkboot1
        /dev/mmcblk0p1  /dev/mmvblk1boot0        /dev/mmcblk1p1
     mmcblk0 is the SD card and mmcblk1  is the EMMC memory.

4. Plug a USB stick into one of the USB2 ports on the board. Armbian will recognise this as
    /dev/sda   with a file system in /dev/sda1  and mount it at /media/<USERNAME>
     where <USERNAME> is some username that you were logged in as the last time you plugged
     in a USB stick.

5. Type the command 'dd count=8192 if=/dev/mmcblk0 of=/media/<USERNAME>/bootloader.img
    (do not add any spaces around the equals signs) and the bootloader binary image will be
    copied off the SD card onto the USB stick in less than a minute.

6. Having a copy of the required bootloader on the USB stick, if you do not wish to over-write
   the contents of the SD card, replace it with one at least as large as the EMMC memory.
   Type the command 'fdisk /dev/mmcblk1' then press 'p' and 'Enter' then 'q' and 'Enter'. Be
   very careful to not do anything else here because this program CAN destroy your EMMC
   system if mishandled.
      Armbian on my PC+ displayed:
      Device          Boot Start      End   Sectors  Size  Id  Type
      /dev/mmcblk1p1        8192 15117183  15108992  7.2G  83  Linux

7.   Using 'End' sector number, now over-write the SD card with command:
                    'dd count=15117183 if=/dev/mmcblk1 of=/dev/mmcblk0'
     Note that we are copying the file system plus the first 8192 sectors which contains the
     bootloader and the master boot record (MBR). We are going to write the bootloader we saved 
     earlier into that low space and need to leave room. 
     
8.   Copy the bootloader obtained earlier into that space of 8192 sectors at the start of the SD
     card:
         type 'dd count=8192 if=/media/<USERNAME>/bootloader.img'
     In the process we will over-write the first sector on the SD card which contains MBR and
     the partition table with the MBR from from the earlier SD card which will contain data
     almost certainly irrelevant to the file structure we originally copied from the EMMC.

9.   The next step is to again copy data from the EMMC to the new SD card, limiting the copy
     to just the first sector, restoring the MBR and partition table data to correctly duplicate
     that structure to be relevant to the partition we earlier copied from the EMMC. 
            type  'dd count=1 if=/dev/mmcblk1 of=/dev/mmcblk0' 

10.  The final step is to mount the newly prepared SD card and edit the UUID in its Boot
     folder.
          type 'mount /dev/mmcblk0p1 /mnt'
     This attaches the SD partion to the /mnt folder.
          type 'cd /mnt/boot'   make our area of work the default.
          type 'blkid | grep mmcblk0p1 >newUUID.txt'
     This saves the UUID we must use into the file /mnt/boot/armbianEnv.txt
          'cat newUUID.txt'  will show the saved UUID and more  eg:
          /dev/mmcblk0p1: UUID="48a407c4-ca6e-4a21-ac94-71a9eac17295" TYPE="ext4" PARTUUID="709ff8b6-01"

     You must now edit the file ./armbianEnv.txt  with an editor such as 'nano' (I prefer joe)
     and replace the UUID in the line such as the following with the one obtained by the above method.
          rootdev=UUID=828b3b50-226d-4f90-b607-2bccb4031c24

All done.  I suggest that the next operation should be to save an image of the SD card just           
created onto the USB stick, eg:
          dd count=15117183  if=/dev/mmcblk0 of=/media/<USERNAME>/ArmbianSystem.img
unmount the USB stick eg:
          umount /dev/sda1
and the new SD card eg:
          umount /dev/mmcblk0p1
then make a backup copy of that image by your usual file backup procedures.  If you have another
Orange Pi PCplus, you should plug the new SD card in and test it before packing up and opening
a well-earned beer.

Peter.

PS.  The above assumes an 8192-sector-sized bootloader at the start of the EMMC and SD cards.
     I have seen some SD cards formatted by Windows for which this is not the case.
     You should check for this using fdisk before proceeding.
     
     

1 hour ago, OldBikerPete said:

very capable multi-purpose backup program suites already exist for Linux


I am well aware of that, but they lack key elements, otherwise you would use it.

 

1 hour ago, OldBikerPete said:

this particular backup problem is too deep in the bits and bytes - especially given the clues you have given me.


Actually not, but I don't know your background so I don't know how deep I need to go. I can't explain everything everytime.

 

1 hour ago, OldBikerPete said:

that worked for me.


We always try to look how to make things for our common good. Usually the same amount of work is needed. Your method will work for most of the Allwinner boards, but not elsewhere since each hw looks for boot bits elsewhere.

Each of our bootloader package contains two things defined in a standard way:

- binary or binaries needed for boot

- a method of flashing

 

This is a good ground to make a general backup solution, a plugin for existing, ... 

  • Author

Just a suggestion that may save others from suffering from this problem in the first place.

 

I have been developing a garden watering system for my family's households. It consists of an 'engine' written in 'C' which uses the Wiring OP library to turn on valves and is programmed using text configuration files. These files are created. modified and managed by a web server using python scripts. The web server is accessed using any web browser such as on a smart phone via WiFi.  A major design goal achieved has been that the smartphone or other device does not require assist software such as javascript.

 

I made the mistake of moving the system under development from the SD card onto the EMMC early on, then continuing development.  DON'T DO THIS.   Save moving the system until a stable system is ready for deployment, it's much easier to back up an SD card.

 

I haven't tackled updating an EMMC memory with a later version yet, that is an adventure yet to be enjoyed(?).

Peter

 

 

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.