Friday, 14 April 2017

Add Fedora with persistence to E2B

To set up most linux ISOs with persistence, find a suitable .mnu file in the \_ISO\docs\Sample mnu Files folder on the E2B USB drive and read the instructions at the top of the file.

However, Fedora is different!

The sample menu provided in the E2B \_ISO\docs\Sample Mnu Files folder for Fedora only works if you have a FAT32 E2B USB drive - Fedora does not like NTFS volumes when booting (and it's only the year 2017!).

Here is a way to add Fedora+persistence to an NTFS E2B USB drive (MBR and UEFI).



The maximum size for the persistence file is 4GB because we will add it to a FAT32 .imgPTN partition.

Let us start with MBR-booting

1. Download your Fedora Live ISO file - I used Fedora-Workstation-Live-x86_64-25-1.3.iso

2. Install the MPI Tool Kit onto your Windows system

3. Drag-and-Drop the ISO onto the MPI_FAT32 Desktop shortcut.

When prompted for a size, you must add the amount of space you want to use for persistence - e.g. add 500MB to the suggested size. Do not add more than 4GB as we cannot create a file >4GB for the persistence file.

4. Copy the resultant .imgPTN file to your E2B USB drive (e.g. \_ISO\LINUX\Fedora-Workstation-Live-x86_64-25-1.3.imgPTN)

5. Run the \_ISO\SWITCH_E2B.exe utility and double-click on the .imgPTN file to switch in the partition.

Check in Explorer that you can now see a \LiveOS folder on the USB drive.

6. Edit the \menu.lst to add in the following lines to the bottom of the file...

title FEDORA 25 with persistence (/fedora.img)\n Boot to Fedora with persistence
uuid () > nul
set UUID=%?%
echo UUID=%UUID%
if not exist /fedora.img echo WARNING: Changes will not be remembered unless a /fedora.img ext file is created! && pause
kernel /syslinux/vmlinuz root=live:UUID=%UUID% rd.live.overlay=/dev/disk/by-uuid/%UUID%:/fedora.img rd.live.dir=/LiveOS rootfstype=auto rw rd.live.image quiet splash vga=791 rhgb rd.luks=0 rd.md=0 rd.dm=0 xdriver=vesa nomodeset
initrd /syslinux/initrd.img
boot

7. Run a recent version of RMPrepUSB.exe, select the USB drive and click on the Create Ext2\3\4 button, then use the following settings:

Ext Filename: fedora.img  (all lower case)
Volume Name: LIVE (anything you like here!)
Size: YYY  (where YYY is the remaining amount of free space in the FAT32 partition - use Explorer to tell you how much free space there is)
Ext type: ext3   (ext3 is more resilient than ext2 - you can use ext4 if you wish but it may run Fedora slightly slower than ext3)

10. Now boot on a real system in MBR mode and check it works. If you change the Desktop wallpaper, the change should be persistent.

Note: Only after booting on a real system first, was I then able to successfully boot under VBox!

FAIL! The persistence file is not the correct name or is not present
As it boots, look out for any messages about 'unable to find persistent overlay' about 3-10 seconds into the boot process (see piccy).

For a verbose boot, change quiet to noquiet and splash to nosplash to see more progress messages. If you have early boot display issues, change vga=791 to vga=ask.
xdriver=vesa nomodeset are included for reliability reasons - you can try omitting them.

If it was working OK, but then stops booting to the Desktop, delete and re-create the persistence file as it may have become corrupted.

UEFI-booting

If you also want to UEFI-boot with persistence, we need to also edit the grub.cfg menu

This assumes the volume name (label) of the .imgPTN file is 'EASY2BOOT'

1.  Add the following 4 lines so that they are the first menuentry in the \EFI\BOOT\grub.cfg file:

menuentry 'Start Fedora-Workstation-Live 25 Persistent' --class fedora --class gnu-linux --class gnu --class os {
linuxefi /images/pxeboot/vmlinuz root=live:LABEL=EASY2BOOT rd.live.overlay=LABEL=EASY2BOOT:/fedora.img rd.live.dir=/LiveOS rw rd.live.image quiet
initrdefi /images/pxeboot/initrd.img
}

2. Change the set default="1" line to set default="0"

Optional: Change the set timeout=60 line  to 5  to change the timeout to 5 seconds


Here is an example:

set default="0"

function load_video {
  insmod efi_gop
  insmod efi_uga
  insmod video_bochs
  insmod video_cirrus
  insmod all_video
}

load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2

set timeout=5
### END /etc/grub.d/00_header ###

#search --no-floppy --set=root -l 'Fedora-WS-Live-25-1-3'

menuentry 'Start Fedora-Workstation-Live 25 Persistent' --class fedora --class gnu-linux --class gnu --class os {
linuxefi /images/pxeboot/vmlinuz root=live:LABEL=EASY2BOOT rd.live.overlay=LABEL=EASY2BOOT:/fedora.img rd.live.dir=/LiveOS rw rd.live.image quiet
initrdefi /images/pxeboot/initrd.img
}

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Start Fedora-Workstation-Live 25' --class fedora --class gnu-linux --class gnu --class os {
linuxefi /images/pxeboot/vmlinuz root=live:LABEL=EASY2BOOT rd.live.image quiet
initrdefi /images/pxeboot/initrd.img
}

menuentry 'Test this media & start Fedora-Workstation-Live 25' --class fedora --class gnu-linux --class gnu --class os {
linuxefi /images/pxeboot/vmlinuz root=live:LABEL=EASY2BOOT rd.live.image rd.live.check quiet
initrdefi /images/pxeboot/initrd.img
}
submenu 'Troubleshooting -->' {
menuentry 'Start Fedora-Workstation-Live 25 in basic graphics mode' --class fedora --class gnu-linux --class gnu --class os {
linuxefi /images/pxeboot/vmlinuz root=live:LABEL=EASY2BOOT rd.live.image nomodeset quiet
initrdefi /images/pxeboot/initrd.img
}
}

Note: Fedora did not seem to like booting under Virtual Box ('Started User Manager for UID 42' issue), so always test on a real system first!