Jump to content

Copied entire / tree from good Armbian SD card to a single partition of another SD card. How to boot from the second?


Recommended Posts

Posted

I have a working Armbian SD card and I used it for some time made some changes in the system (disabled some services, installed some libraries and made new services etc...). I use this SD card with Cubieboard-3 (Cubietruck). And I have a backup of the entire root filesystem from that SD card. Now I've got second Cubieboard-3 device and I need a second SD card to boot the second device into the same OS with actual changes. The good approach would be to backup only CHANGES in some manner that would allow me to install fresh armbian to new SD card and them roll my changes to it. But instead, i started a stupid approach of doing this: just copied the entire filesystem to backup and to a second SD card. Then I inserted the SD card to my Ubuntu laptop, ran Gparted and made the partition bootable. This had no happy end: device didnt booted from the new SD card. As I understand, i must flash U-Boot into it somehow. Maybe reading this https://linux-sunxi.org/U-Boot would help me, but I have no idea is it the good path to go (clone U-Boot, install cross-compiler, compule U-Boot, flash the U-Boot). Is there any easier way? Maybe pre-compiled U-Boot for the cortex-a7 and some instructions for flashing it? All this seems interesting, because i always wanted to dive into some low-level linux stuff, but the time waste too much for now.

Posted

I think that something like this should work (I've done similar in the past, but I'm working from memory, so I may have missed something):

Flash the new SD card with the same OS image used for the original card (a similar image may also work if u-boot isn't too different). 

Boot the card and allow it to expand the partition (or expand the partition using gparted or similar to about 80-90% of the SD card).
Back up /etc/fstab from the new SD card to a safe location (it's a good idea to backup the /boot directory as well).


Mount the new SD card RW on a Linux computer.  You will need to be root or sudo su for most of the following.
Delete all directories and files except for the /boot directory and it's contents from the new SD card.
The new SD card root file system should now only contain /boot and it's contents.
Rename /boot to /boot-backup

Copy all files retaining permissions and attributes including /boot directory from the original SD card to the new SD card.
https://www.makeuseof.com/preserve-file-permissions-in-linux-while-copying-them/

Replace /etc/fstab on the new card with the fstab that you backed up.
Or edit the /etc/fstab on the new SD card '/' to match the UUID in your backed up fstab (this method only required if your original has extra non standard fstab entries).

Change the UUID in /boot/armbianEnv.txt to match the entry in /boot-backup/armbianEnv.txt.  (something like rootdev=UUID=f0920bd6-7fea-42cb-a9cd-3db938a68382).  It should also match the '/' UUID in /etc/fstab.

Good luck and let us know how it goes.

Posted

Used this manual to make my SD card bootable: https://linux-sunxi.org/Bootable_SD_card#Bootloader

  1. Git-cloned the U-Boot and cross-compiled it for default Cubieboard config.
  2. dd u-boot to my new SD card with the root filesystem copied by .tgz from working SD card, changed UUID in the /boot/armbianEnv.txt
  3. system booted OK

BUT! The weird thing happened. Ethernet networks works single-directional: cubietruck do not see any packets coming to it, but everyone else see the packets coming from it. For example, when Cubietruck tries to get IP address using DHCP, the DHCP-server see DHCPDISCOVER and respond with DHCPOFFER, but this process has no continuation: DHCP server does not see DHCPREQUEST, DHCPACK from the Cubieboard. The interesting thing is: when i boot this Cubieboard with the "Original" SD card, everything works great. Also, when i boot some proprietary linux from NAND flash soldered to Cubieboard (i dont know what that linux does, but it talks BOOTP/DHCP after boot) the DHCP-process goes perfect too.

So, i've got strange single-directional ethernet connection with my u-booted SD card!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines