Friday, 14 April 2017

Add Fedora with persistence to E2B

Updated 2021-04-12 for Fedora 33

Linux ISOs + persistence

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.

You will need to change the  name of the ISO in the title line and a line below the title line.

You will need to create a ext2\3\4 persistence file (ext3 recommended as ext2 files are easily corrupted) using RMPrepUSB.

See here for instructions.

Fedora + persistence

However, Fedora is different!

The sample menu provided in the E2B \_ISO\docs\Sample Mnu Files folder for Fedora+persistence only works if you have a FAT32 E2B USB drive - Fedora does not like NTFS volumes when 'flat-file' booting.

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

(also Fedora-Workstation-Live-x86_64-33-1.2.iso worked).

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). 

Rename the file extension to .imgPTN23 if you have agFM on your E2B USB drive.

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

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 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 rhgb rd.luks=0 rd.md=0 rd.dm=0 xdriver=vesa nomodeset
initrd /syslinux/initrd.img
boot

Tip: add vga=ask after nomodeset if you cannot see a Desktop and try a different graphics mode.

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). See section below for 2020/2021 versions of Fedora.

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.

Persistence for later versions of Fedora

Later versions (e.g. 33) require there to be some empty directories in the persistence file before it will be recognised as a valid persistence file:
  1. Boot to the .imgPTN23 image using the new 'Fedora + persistence' menu entry
  2. Activities - Show Applications - Disks
    Look for the fedora.img file (in my case it was /dev/loop2 - see screenshot below)
  3. At the Desktop, open a Terminal console (Activities - (Search) - 'terminal')
  4. In the terminal console type
    mount
    look for the same loop device. In my case is was mounted as /run/initramfs/overlayfs
  5. Type
    cd /run/initramfs/overlayfs/   (or whatever your mount point was)
    (you can type ls to ensure it is empty except for lost+found)
  6. Type
    sudo mkdir overlayfs
    sudo chcon --reference=/. overlayfs
    sudo mkdir ovlwork
Now reboot (using the Restart menu) and boot to Fedora+Persistence again.

Step 2. Look for your image file

After creating the two new folders you should see this...


Ref: github source here.

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 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

Add the splash parameter after the quiet parameter if you want to see the splash screen instead of boot messages.


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
}
}


No comments:

Post a Comment