Using 2 OS images on eMMC for safe upgrades
#1
One of the things Solaris & AIX have for safe patching & upgrades, are alternate boot environments. AIX solves this by having an OS boot mirror device that can be detached and made bootable as a backout plan. Solaris 11 does this through a mostly automated procedure with ZFS snapshots & file system clones, using the "beadm" command. The intent is to allow easier restoration of service without having to perform a full restore. (Either from backups, if you have them. Or re-install.) Simply reboot to the previous OS image.

At home, with Linux, I've done 3 different methods for backing out changes & updates. First method applies here, using a second OS partition for the backout plan. This is what I will describe for the Pinebook Pro, with Manjaro on eMMC. This can work for other Linux distros, but I will not be describing them at present.

It's a bit more clumsy on the Pinebook Pro right now, as we can't use Grub menus to select the prior OS in case of complete failure. If the default OS is completely un-bootable, then you have to boot and use a SD card to perform the change back.

To start, you need to re-partition your eMMC to something like below. If this is beyond your skill set, then it's likely the rest would be too.

part 1 - /boot
part 2 - / (root 1, about 15GB)
part 3 - / (root 2, same size as root 1)
part 4 - /comm (common for rest of the space)

What you call the "/comm" is up to you. I normally use the host name. Basically you should put your home directory, and other things that should be common for both OS images in a separate partition.

I will assume you have the root file system on partition 2 booting fine under Manjaro.

Manjaro uses the file system label in the U-Boot configuration file. So, we use a different file system label for the second root OS. Here we make a second file system, with different label, mount it and copy it.

Code:
mke2fs -b 4096 -t ext4 -j -m 1 -L ROOT_MNJRO2 /dev/mmcblk2p3
mkdir /mnt/usb
mount -t ext4 /dev/mmcblk2p3 /mnt/usb
rsync -aAHSXxv --stats / /mnt/usb/

To test, make this the default OS image by editing "/boot/extlinux/extlinux.conf" and changing the file system label for ROOT to use this second partition. Then reboot. You should now see this partition in use after booting using the "df -h" command.

Now perform any updates you want.

Your old previously working OS image is still good and available in case of problems. To go back, simply edit the configuration file "/boot/extlinux/extlinux.conf" and change the file system label for ROOT again.

To perform any further updates, simply mount the other OS file system and this time, run the RSync command with the delete option like this;

Code:
rsync -aAHSXxv --delete --stats / /mnt/usb/

One method to get "/home" on the common location is to;
Code:
mv /home /comm/
cp -p /etc/fstab /etc/fstab.`date +%Y%m%d`
chmod a-w /etc/fstab.`date +%Y%m%d`
vi /etc/fstab

/comm/home        /home  none    bind            0      0

Let me know if you have any questions or need clarification.

While I can't make this work for you, it DOES work for me. And I have been using one form or another of alternate boot environments at home for more than 10 years. (And at work, years before then.) About once every 6 months I need to use one for backout, on one of my other Linux computers at home.
--
Arwen Evenstar
Princess of Rivendale


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to rewrite uboot to emmc pineitup 5 8,687 12-27-2020, 10:35 AM
Last Post: nightranger73
  How to install Ubuntu to eMMC and to install KDE (Neon) Wizzard 66 97,690 12-22-2020, 03:05 PM
Last Post: Wizzard
  How to boot Manjaro from NVME with uboot on eMMC as400 47 55,754 06-07-2020, 02:37 AM
Last Post: as400
  Restoring the OS using the eMMC Adapter xircledev 3 6,839 02-20-2020, 05:16 PM
Last Post: Thovthe

Forum Jump:


Users browsing this thread: 1 Guest(s)