Saturday, 14 June 2014

How to boot Ubuntu via UEFI with persistence from Easy2Boot

You can fully-install many linux distros to a .imgPTN file (see blog post here), however I was asked recently how to boot Ubuntu 14.04 64-bit from an Easy2Boot USB HDD when using partition image files (.imgPTN files) so that you can UEFI boot with persistence.

Note: 14.04 and many later versions of Ubuntu (and linuxmate based on Ubuntu) have a bug! They do not fully boot and give an initramfs error if you use a casper-rw partition. It works OK with a casper-rw file, but not a partition. Sometimes it may work if the ext partition is located after the FAT32 partition - but this depends on the order of the two files (xxxx.imgPTN and xxxx.) so using a casper-rw partition cannot be guaranteed to always work! See later bog post here.


Here is how to do it:

1. Drag-and-Drop the ubuntu-14.04-desktop-amd64.iso file onto the MPI ToolKit Windows Desktop shortcut MPI_FAT32 to make a ubuntu-14.04-desktop-amd64.imgPTNLBAa partition image file.

Tip: The MPI_FAT32 cmd file produces a minimum sized OS partition. It may be advisable to drag-and-drop the ISO onto the MakePartImage shortcut and specify a larger size for the image file than the default size. This allows linux to store some files on the OS partition (which it seems to need to do on some occasions).

2. Copy the file to the E2B \_ISO\MAINMENU folder and rename it to remove the first dot - i.e. ubuntu-14_04-desktop-amd64.imgPTNLBAa. You can use a different folder if you wish - e.g. \_ISO\AUTO or \_ISO\LINUX, etc.

3. Use RMPrepUSB - Create Ext2 FS button to make a file called ubuntu-14_04-desktop-amd64  with a volume label of casper-rw  (the filename must exactly match the filename of the .imgPTNLBAa file). I recommend using ext3 (all types of media) or ext4 (USB HDD spinning disks only as does lots of journal writes) and not ext2 as it is easy to corrupt!

4. Copy the \ubuntu-14_04-desktop-amd64 to the same folder as the ubuntu-14_04-desktop-amd64.imgPTNLBAa file. Ensure there is no dot in the name or it will be listed by E2B as a menu item!

so you should now have:

\_ISO\MAINMENU\ubuntu-14_04-desktop-amd64.imgPTNLBAa    - ubuntu payload parition image
\_ISO\MAINMENU\ubuntu-14_04-desktop-amd64                            - ext3 file

5. We now need to edit the ubuntu-14_04-desktop-amd64.imgPTNLBAa image. To access the files inside the image you can either mount the image file using ImDisk (right-click - Mount as ImDisk Virtual Drive) or boot from the E2B USB drive and select and run the ubuntu-14_04-desktop-amd64.imgPTNLBAa file from the menu so that the partitions are swapped over.

6. Edit the \menu.lst file (i.e. the large one inside the image NOT the small one on the E2B drive) and add the following lines to the bottom of the file:

title Ubuntu 14 with Persistence\n Run Ubuntu 14 with persistence
kernel /casper/vmlinuz.efi  boot=casper persistent noeject noprompt quiet splash --
initrd /casper/initrd.lz

You can place this menu entry anywhere in the menu.lst file to have it appear in a different order if you wish (not at the very beginning of the file though - it should be after the first 'title' menu entry).

7. Edit the \boot\grub\grub.cfg file and add in  persistent cheat code word and edit the menuentry text:

menuentry "Try Ubuntu without installing - Persistent" {
set gfxpayload=keep
linux /casper/vmlinuz.efi  file=/cdrom/preseed/ubuntu.seed boot=casper persistent quiet splash --
initrd /casper/initrd.lz
}

If you wish you can add an extra entry rather than modify the existing entry - then you will have both a persistent and non-persistent boot entry in the UEFI menu. e.g.

menuentry "Try Ubuntu without installing - Non-Persistent" {
set gfxpayload=keep
linux /casper/vmlinuz.efi  file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash --
initrd /casper/initrd.lz
}

menuentry "Try Ubuntu without installing - Persistent" {
set gfxpayload=keep
linux /casper/vmlinuz.efi  file=/cdrom/preseed/ubuntu.seed boot=casper persistent quiet splash --
initrd /casper/initrd.lz
}

8. If you used ImDisk to mount the image, then right-click on the virtual drive and dismount it to save the changes.

9. Make all files on the E2B USB drive contiguous (e.g. RMPrepUSB - Ctrl+F2)

Now boot from the E2B drive and test it.


If you choose menu items 1 or 2 then you can run Ubuntu in MBR mode without persistence.
If you choose item 3 then it will load Clover and then you can UEFI boot to Ubuntu with persistence.
If you choose item 6 then it will MBR-boot to Ubuntu with persistence
If you boot from a computer using the USB UEFI-boot menu option, it will show the menu below and you can UEFI-boot to Ubuntu with persistence.


Take care to shutdown Ubuntu nicely or you may corrupt the persistence file!

Note that if you want to also boot from the ubuntu-14.04-desktop-amd64.iso file with persistence and use the same persistence file, then this is also possible. Just follow the instructions in the Sample Ubuntu 13.04 .mnu file but use the existing \_ISO\MAINMENU\ubuntu-14_04-desktop-amd64 persistence file by changing the .mnu file - you will need to specify the full path in the .mnu file for the ext3 file - e.g.

set ISO=$HOME$/ubuntu-14.04-desktop-amd64.iso
set PF=()/_ISO/MAINMENU/ubuntu-14_04-desktop-amd64 

If you want to do a similar thing for other linux distros, then different modifications will be required.
Looking at the sample .mnu files should give you a clue as to what changes are required, but it is not a job for beginners!

Note: It advisable to use different persistence files for different ISOs. If linux does not behave correctly when booting with persistence (but is OK when booting without persistence), you will probably need to make a new persistence file.


Please tick 'funny' 'interesting' or 'cool' or add a comment to let me know which posts you most enjoy.

No comments:

Post a Comment