Dual Booting On x86_64

So I know dual booting with openwrt is nothing new, and is pretty standard on several boards, but from what I can tell, info is pretty scarce for x86 platforms. Especially ones using ext4. Only thing i saw was:
There doesn't seem to be any built in features for a sysupgrade either (I have seen this mentioned several times in other topics). What I have is an x86 running 18.06 and I would like to upgrade. Problem is this is in a production environment at a business and unless I want to use Debian or similar on a live-usb to re-flash, I must remove the machine from the rack, take off the lid, etc... to manually re-flash the HD. Quite a pain either way. PXE or TFTP may be viable options but i wanted to look into dual booting first so I always have a backup.

What I would like to do is have 2 partitions, each with a functioning openwrt file system which can be selected in grub. This would allow re-flashing the other while running. I could easily make a script to change the default in grub. This is what my plan is:

  1. Build both images without grub. (possibly use the "install partition" option in menuconfig?)
  2. manually install grub to the MBR from another Linux system.
  3. use gparted or equivalent to create two partitions (no file system)
  4. Install 1st image to 1st partition, 2nd to 2nd partition
  5. get PARTUDID of each partition, add to grub.cfg of each image
  6. select default in grub.cfg

Or alternatively, create 3 partitions with a separate /boot partition with grub, both kernels and then the remaining file systems on the remaining two. Again, i'm sure I could easily make a script to automate most of it.

Any thoughts or apparent issues I am not accounting for?


Hello thermochromic, I was just testing my dual boot mods and utils/LuCI page for 17.01.4 when 19.07 appeared already, so I decided to do further work for the new version if I find some time.

On LEDE-17.01.04 my image mods work fine, but I still couldn't figure out how to build a target profile for, say, an APU2 x86_64 platform, so that it would fit nicely into the OpenWrt build system w/o affecting standard x86 scripts.

Thus, I can only offer patches to base files for the x86_64 target of OpenWrt 17.01 at this time, but I'm currently working on porting the dual boot image to 19.07 as time allows.

However, my modifications do not meet all your needs beside the different versions, b/c it is based on grub. It allows to install firmware into the backup image while running from a startup image. It saves the image selections (startup/backup) in a grub environment and allows to restore config files from one to the other firmware image on updates. It also requires an ext4 (not a squashfs) filesystem.

A bootcfg utility allows to switch between images or to show the system versions installed in the images etc. A LuCI page for modifying the boot config is available, too.

Would you like to help porting the mods to OpenWrt 18.06? If so, send a PM please.

R1D2, thanks for the reply sorry it took so long I have been quite busy. I don't plan to use 18.06 with the dual boot feature. That is what I am runnig currently but I plan to upgrade to 19.07 at the same time I impliment this and just leave the 2nd partition (or "partition group" rather) blank for now, then copy to it on the following upgrade. I am using ext4. I will have to look into the bootcfg utility. Your saying that your approach does all this in the grub shell enviroment? Ya i was hoping to do it from a running image similar to how managed switches work. As my images are ext4, copying (in my setup) /etc/config, /root,/etc/profile,/etc/openvpn,/etc/banner, and /etc/ssh over after the image has written to the not-in-use partition seems pretty trivial.

Only thing I am not sure of is if I should create 4 partittions then install grub to the MBR seperate from the openwrt installs, then build images without grub, and install new kernel and filesystem on seperate partititons so it would look like:

Or alternativly like this:


So on 19.07 are the any functions in the librarys that would need to be patched? From what I can tell the patches you applied were pretty much only related to the sysupgrade command right?

Hello thermochromic, sorry for the late reply. My patches realize the second layout in your reply: sda1 contains grub and both kernels, sda2 and sda3 the two rootfs and sda4 can contain an additional filesystem.

Yes, patches involve sysupgrade for the x86 target, patches to the grub config file, patches to the target config for menuconfig, a web page for LuCI and and utility to select the next image to boot from (called bootcfg). No patches for libraries needed. Anyway, it is somewhat difficult to me to provide patches for the maintainers, since they affect the x86 target as well as the LuCI package and a new package for the bootcfg utility.

I also tried to create an own x86 profile for my platform (apu2) to separate modifications from the Generic profile, but failed to do so. Thus, I currently have only quilt patches for the v17.01.4-302-gfad29d2 version. If this would help you, I can send them to you. Please note that porting to 19.07 still needs some more time and unfortunately I'm very busy currently with other tasks.

1 Like