Thursday 1 December 2016

Add a Manjaro Live install image to E2B

The manjaro live cd ISO does not seem to support a live persistence volume (AFAIK).



However, we can add a full manjaro image (MBR boot only) to E2B so that we can boot to a fully installed OS which will be updatable and persistent just like a normal installation.

Here are the steps to add a full linux OS to an Easy2Boot USB drive.
We will create an empty partition file (manjaro) and then use Virtual Box + DavidB's VMUB to install to that partition file. We will then boot from a .imgPTN file and via grub4dos, boot to the linux partition.

Use the latest MPI Tool Pack (v.0.054 2015-08-21 or later). This includes CSM menu support for grub2/syslinux installations on the 3rd partition.

I used manjaro-xfce-16.10.2-stable-x86_64.iso for the procedure below.


Brief Instructions (not for beginners!)

Important Note: Before you begin, save the MBR sector of your E2B USB drive in case anything goes wrong. Use RMPrepUSB - Drive>File - name=E2BMBR.BIN, start=0, size=32SEC, filestart=0. Save the file to your Windows hard drive for safe keeping. If you find that you cannot return back to the E2B menu, restore the original MBR using RMPrepUSB - File>Drive.
Warning: You should be familiar with VBox+VMUB and linux installs and MakePartImage before you attempt this!

If you have an old version of the MPI Tool Kit, please update it now or it may not work!

I used a Windows10 64-bit host system for this procedure, with a SSD USB 3.0  USB  drive as my E2B USB drive.

manjaro-xfce-16.10.2-stable-x86_64.iso should be on your Windows hard disk somewhere (not on the E2B drive)

1. Create an empty folder on the Windows Desktop ( I named the folder EMPTY because I was watching Spok on Star Trek at the time and it seemed logical!) and then drag-and-drop the empty folder onto the MPI_FAT32 Desktop shortcut. 

manjaro.imgPTN  FAT32   (38MB - accept default size)

Create the OS partition using Make_Ext.exe (\_ISO\\docs\Make_Ext\Make_Ext.exe) - make sure you use the same format that you intend to use for the OS - e.g. ext4.

\manjaro              ext      (set size as required for full manjaro installation - e.g. 15000 for 15GB)

Now copy and move the two files to your E2B USB drive. You now should have:

\_ISO\LINUX\manjaro.imgPTN   (38MB)
\_ISO\LINUX\manjaro                 (15GB) - or any size you like!

Boot to E2B and select the manjaro.imgPTN file from the Linux E2B sub-menu. 

You will need to make the files contiguous.

2. Create a new linux diskless VM in VBox.

No virtual hard disk should be present in the VM. Try to match the disk controller type (e.g. SATA) and chipset with the final target system type (otherwise you may need to boot using the 'Fallback' menu option).

3. In VBox Manager - Settings, add a virtual CD using the ISO file as the content of the virtual CD to the new VM that you created. Ensure that the CD-ROM is first in the boot order.

The first slot for Primary Master IDE (or SATA 0) should be empty - it will
be automatically populated by VMUB when you run it.


4. Run VMUB (see VBox+VMUB) (using the VMUB utility and run it as Administrator) and allow the VM to boot from the ISO which should be on your Windows drive somewhere (not the USB drive). Do not boot directly using the VBox Manager, you must use VMUB to run VBox.

Set up an entry for the new VM in VMUB and click Start.

5. You should see the LiveCD boot menu because VBox should boot from the ISO...
  • Select Start Manjaro Linux

6. Now we need to do a custom install of manjaro onto \dev\sda3 (the empty partition on our E2B USB drive). Proceed to install manjaro as follows...
  • Run the Install Manajro Linux (Calamares)  Desktop icon
  • Select Country, TimeZone, Keyboard
  • Select Manual Partition  (I had an 8GB for my manjaro file in this example)
  • double-click on the sda3 partition in the table (it should be many GB in size)...




Note: Do NOT change the File System type.

Make sure the boot loader installs to / and NOT /dev/sda !!!
Note: You must NOT change any of the partition positions or create new partitions or change \dev\sda1!  If you do, you will totally destroy the contents of your E2B drive!

You should only format \dev\sda3 and no other partition or portion of the USB drive.

If you have kept the partition type the same, then it will just want to format the existing partition. Do not allow it to delete and create a new partition.

Note: if the partition is detected a \dev\sda2 then it is not going to boot correctly because grub2 will attempt to boot from \dev\sda2 instead of \dev\sda3. I suggest you start the install and then cancel it and reboot and try again until the partition is recognised as \dev\sda3.

Now enter your credentials as desired and finally confirm...


Ensure you have everything set as /dev/sda3 and that the boot loader will be installed to /.

The installation will then proceed (it seems to take quite a while at the 19-21% point but it will eventually finish!).

7. Shutdown manjaro.

You should now be able to use the grub4dos CSM menu.
  • Boot to Partition 2
If you do not see this entry, use Option 0 to restore the E2B partition and then select the Manjaro file again from the E2B menu. It should then be visible.

If you have problems booting due to using different target PC h/w from that of the VM (e.g. 'mount: /new_root:' error) try the Advanced - Manjaro Fallback menu entry.



If it seems to boot to grub-rescue and not the CSM menu, then you did not install the boot loader to / - to fix this, run RMPrepUSB - File>Drive and use the E2BMBR.BIN file you made earlier to write to LBA 0 on the drive.
(what? you didn't bother to make that file? Well you can try re-installing grub4dos to the MBR using RMPrepUSB, but you will also have to copy LBA0 to LBA30 as well to make Switch_E2B like the drive!).
If you wish, you can remove the menu entries #1 and #2 by editing the \menu.lst file, edit the menu to say 'Boot to Manjaro' and edit the menu heading, etc. You can change the file extension to .imgPTNAUTO to avoid the partition switch prompt and set the default and timeout value in the \menu.lst file so that it boots straight into manjaro from the E2B menu.

You can install many different linux distros using this technique, as long as they only need a single partition to install to (i.e. no separate boot or swap partition is needed).

You can simply copy the two files to any other E2B USB drive if you wish.

Please tick the Reactions box if you found this useful.

12 comments:

  1. Hey Steve, i went through your tutorial and (after fighting with MOVE_IMGPTN for a long time) were able to install manjaro succesfully. However i can't boot it, there is no option to boot from Partition 2 and the EFI boot files may be missing: https://ibb.co/R2WXs4C

    ReplyDelete
    Replies
    1. You probably did not tick the boot checkbox - see Summary screenshot in article.
      What ISO did you use?

      Delete
    2. Yes i did check the boot flag (on the first try the lba-flag was checked by default too, on the second try i only checked the boot flag).
      The iso is: manjaro-xfce-18.0.4-stable-x86_64.iso

      (wow fast reaction speed btw :-* )

      Delete
    3. I tried the same ISO and got the same result. If you use the CSM menu to restore the E2B partition and then switch again to Manjaro.imgPTN then for some reason, I do then get the CSM menu option to boot to partition 2.
      However, it only loads grub2 rescue and fails to boot. This is because the install process has made an incorrect grub.cfg file! The grub.cfg file has been configured to boot to hd0,msdos2 instead of hd0,msdos3 and so it fails to boot to the grub menu!
      I even created a grub4dos menu in the \menu.lst file

      title MANJARO
      root (hd0,2)
      uuid () > nul
      set UUID2=%?%
      kernel /boot/vmlinuz-4.19-x86_64 root=UUID=%UUID2% rw
      initrd /boot/intel-ucode.img /boot/initramfs-4.19-x86_64.img
      boot

      This starts to boot and then fails with a 'Can't find UUID=' message even though the ext4 partition is present.
      Sorry, but it seems this process is broken for this Manjaro version :-(

      Delete
    4. P.S. I tried the same procedure using linuxmint 19.1 64-bit ISO and it worked perfectly.

      Delete
    5. Hey Steve, thank you a lot for your help.
      Reading your second last comment i started some testing: Installing manjaro-xfce-17.1.12 did work, then i installed the next version 18.0 on top of it, it still worked. Following an intuition i again installed the latest verion 18.0.4 ...and booting from partition 2 still worked. I truly have no idea WHY as i always chose Format in the "Edit existing partition"-Window.

      I startedng from scratch with a new manajaro.imgPTN and manjaro file just to be sure: Nothing works anymore, not even the older version 17.1.12 !! :-D

      But since i have a working test partition now (for an unknown reason), is there a way to copy its configuration over? e.g. grub.cfg?

      PS: Btw is it not possible to create disk images from any system and boot it with easy2boot? Could not find any information or tutorial on that.

      Delete
    6. Maybe, the installer needs to see an ext partition before it gets the grub.cfg right?
      So maybe, if you tried 18.0.4 again using the same two files that previously failed 18.0.4 then it would work?
      You can make a .imgPTN from any partition by drag-and-drop onto MPI_FAT32 or MPI_NTFS. You can make a auxiliary file (e.g. swap file or bootable partition) using RMPrepUSB - Drive>File and then save the desired partition to a new file (e.g. Start=P1, Size=P1) save to fred. Then drag-and-drop EMPTY folder onto MPI_FAT32 to make a fred.imgptn file.
      When you boot to fred.imgPTN file, the saved image will be available as hd0,2 (hd0,msdos3 in grub), but it will need to contain boot files (e.g. core.img) or you may need to make a new entry in the \menu.lst file to boot to the other partition. See List of Tutorials page.

      Delete
    7. This comment has been removed by the author.

      Delete
    8. Another try: installed 17.1.12, restored E2B partition and then swithed again to manajro.imgPTN (partition 2 is there but boot fails), installed 18.0.4 on top of it -> boot from partition 2 is a success
      ....

      Yeah i am not sure what the reasion is because just installing manajaro on the existing ext partition is itself not the solution (tried that before too)

      Delete
    9. The difference seems to be that when you first do a fresh install, the installer thinks that the partition is \dev\sda2 (wrong!). But when you re-install, it (correctly) detects the partition as \dev\sda3.

      Delete
    10. Yes that seems to be the case :-)

      Delete
    11. OK, I have worked out what is going on. If it offers to delete and create a new partition then it will not boot. The trick is to create the large second partition using Make_Ext.exe and make sure that it is the same file system that you want to use (e.g. ext4). Then the Manjaro Installer will only format the existing partition (not create a new partition). I have changed the instructions in the blog. You then need to boot using the Advanced - Fallback menu (for some reason I still can't figure out!).

      Delete