Friday, 23 December 2016

Add the SystemRescueCD + persistence (MBR and UEFI) to E2B


The SystemRescueCD contains several useful features:

Description: 
SystemRescueCd is a Linux system rescue disk available as a bootable CD-ROM or USB stick for administrating or repairing your system and data after a crash. It aims to provide an easy way to carry out admin tasks on your computer, such as creating and editing the hard disk partitions. 
It comes with a lot of linux software such as system tools (parted, partimage, fstools, ...) and basic tools (editors, midnight commander, network tools). It can be used for both Linux and windows computers, and on desktops as well as servers. This rescue system requires no installation as it can be booted from a CD/DVD drive or USB stick, but it can be installed on the hard disk if you wish. The kernel supports all important file systems (ext2/ext3/ext4, reiserfs, btrfs, xfs, jfs, vfat, ntfs), as well as network filesystems (samba and nfs).

It can be used with E2B for MBR-booting just by adding the ISO file (no persistence, no danger of the .iso file getting infected or corrupted).

The current (2019) version is version 6 and is based on Arch Linux (see end of article for details)...



UEFI-64 & MBR-booting with persistence (v4 & 5 only)

Here are the steps required to convert the .iso file to a .imgPTN file that will be 64-bit UEFI bootable as well as 32-bit and 64-bit MBR bootable and be persistent:

1. Convert ISO to FAT32 .imgPTN file - just drag-and-drop onto the MPI-FAT32 Windows Desktop shortcut (add to the suggested size to allow for persistence storage - e.g. add 200MB). You will need to install the E2B MPI Tool Pack first (use a recent or latest version). Copy the new SysRescueCD.imgPTN file to your E2B drive, e.g. the \_ISO\UTILITIES folder or wherever you wish.

2. Switch to .imgptn using \_ISO\SWITCH_E2B.exe or the E2B menu system.

Check that the Easy2Boot USB drive now contains a \e2b folder - if not then you have not selected the .imgPTN file and replaced the E2B partition!

3. Use RMPrepUSB - Create ext3 file to make a file in the root called \sysrcd.bs (any volume name will do) - size should be just under whatever you added in step 1 - e.g. 195MB. Specify ext3.

Note that the sysrcd.bs file must be on a FAT32 (which is what we have) or ext partition - it is not found if it is on an NTFS partition.

4. Edit \syslinux\syslinux.cfg (see below)

or \sysresccd\boot\syslinux\sysresccd_sys.cfg

5. Edit \boot\grub\grub-490.cfg  (see below)

or \boot\grub\grubsrcd.cfg

6. Now you can MBR or UEFI-boot - remember to tick the 'Save session for future logins' checkbox on shutdown\reboot to save any changes.

                Remember to tick the Save session checkbox on exit.
Tip: If adding parameters such as backstore=off - you must add them before the two minus symbols (--) on the syslinux command line or they will not take affect.


Modifying the menus (v4 and 5 only)

There are two menu files in the image:

  • \syslinux\syslinux.cfg      for MBR booting
  • \boot\grub\boot-490.cfg   for UEFI booting
Boot parameters can be found documented here.

There are many menu entries for 32-bit and 64-bit systems. You may need to modify each menu entry that you want to use.

Note: When adding any boot parameters, they must be added before the -- string or else they will not take affect!

Persistence

If you are booting from a real system and the E2B USB drive is a 'Removable' type of flash drive, then the backing store persistence should just work. However, if you are booting from a 'Fixed-disk' type of E2B USB drive or from a Virtual Machine (which emulates the USB drive as a Fixed-disk), you will need to add the backstore=alldev switch.

A simple check to see if persistence is going to work, is to type df in the terminal console window. If you see /dev/loop1 mounted as /livemnt/memory, then the backing store has worked.

Look for /dev/loop1 to ensure persistence is enabled.

You can move the \sysrcd.bs file to a different location, but you must also change the boot parameters, e.g.

backstore=alldev,/e2b/sysrcd.bs


Remember to add it before the --- symbols!

Language

You can use the setkmap parameter to specify a keyboard type and thus avoid the user prompt.

Desktop

To boot straight to the Desktop, use the dostartx boot parameter

Syslinux.cfg example

Original
LABEL rescuecd_std
MENU LABEL 1) SystemRescueCd: default boot options
KERNEL ifcpu64.c32
APPEND rescue64 scandelay=1 -- rescue32 scandelay=1
TEXT HELP
Boot standard kernel with default options (should always work). You should
use this entry if you don't know which one to use. You can press [TAB] and
add extra boot options after rescue32 or/and rescue64 if required
ENDTEXT

After modification:
LABEL rescuecd_std
MENU LABEL 1) SystemRescueCd: default boot options
KERNEL ifcpu64.c32
APPEND rescue64 scandelay=1 setkmap=uk backstore=alldev dostartx -- rescue32 scandelay=1 setkmap=uk
TEXT HELP
Boot standard kernel with default options (should always work). You should
use this entry if you don't know which one to use. You can press [TAB] and
add extra boot options after rescue32 or/and rescue64 if required
ENDTEXT

You can also modify the help text and the title, etc. if you wish.

grub-490.cfg example

Original
menuentry "SystemRescueCd (64bit, default boot options)" {
set gfxpayload=keep
linux /syslinux/rescue64
initrd /syslinux/initram.igz
}


After modification:
menuentry "SystemRescueCd (64bit, default boot options)" {
set gfxpayload=keep
linux /syslinux/rescue64 setkmap=uk backstore=alldev dostartx
initrd /syslinux/initram.igz
}

Direct boot from ISO with persistence (v4 and 5 only)

To boot directly from the .iso file with persistence, we could use RMPrepUSB - Create ext3 FS to create a \sysrcd.bs file. However, the sysrcd.bs file does not work if it is placed on an NTFS partition. For this reason, we cannot easily implement persistence when directly booting from the .iso file on an NTFS E2B drive (e.g. by using TAB in the syslinux menu to add in a backstore=alldev parameter.)

You could create a file (e.g. sysrescd.ptn), load it as (hd0,2) in grub4dos and then boot to the SystemRescueCD and create the sysrcd.bs file as outlined in the SystemRescueCD instructions. However, I will leave this up to you if you wish to follow this route...

SysRescueCD.mnu
title SysRescue + persistence \n Must create a sysrcd.bs file in //dev//sdx3 first\n sysresccd-backstore create /mnt/backstore/sysrcd.bs 256
partnew (hd0,2) 0x83 /_ISO/UTILITIES/sysrescd.ptn
/%grub%/qrun.g4b force.isodef  /_ISO/UTILITIES/systemrescuecd-x86-4.9.0.iso
boot

You may also need to modify the syslinux menu entry each time you boot, because the syslinux.cfg file is embedded inside the .iso file. Change 0x83 to 0 after creating the sysrcd.bs file so that hd0,2 will be free to use by E2B.

Alternatively you could add some grub4dos commands before the boot command...

title SystemRescueCD + Persistence\n Must create a sysrcd.bs file in //dev//sdx3 first\n sysresccd-backstore create /mnt/backstore/sysrcd.bs 256
partnew (hd0,2) 0  /_ISO/UTILITIES/sysrescd.ptn
set iso1=/_ISO/UTILITIES/systemrescuecd-x86-4.9.0.iso
/%grub%/qrun.g4b force.isodef %iso1%
kernel /isolinux/rescue64  scandelay=1 setkmap=uk backstore=alldev dostartx -- rescue32 scandelay=1
initrd /isolinux/initram.igz
boot

SysRescueCD 6.0.3

Note: SysRescuecd v6 uses Arch linux and is completely different!  We need to make two files:

\_ISO\LINUX\sysrescuev6.imgptn   - FAT32 partition image
\_ISO\LINUX\sysrescuev6                    - ext3 with volume label of 'arch' - made using Make_Ext.exe


Tip change the file extension to .imgPTN64AUTO

Switch to these partitions by running \_ISO\SWITCH_E2B.exe or booting to the E2B drive and selecting the .imgPTN file.

Now edit these files (changes in red)...

\boot\grub\grubsrcd.cfg (v6)

menuentry "Boot SystemRescueCd using default options" {
set gfxpayload=keep
linux /sysresccd/boot/x86_64/vmlinuz archisobasedir=sysresccd archisolabel=SYSRCD603 cow_label=arch
initrd /sysresccd/boot/intel_ucode.img /sysresccd/boot/amd_ucode.img /sysresccd/boot/x86_64/sysresccd.img
}

where arch is the volume label of the ext3 file.

\sysresccd\boot\syslinux\sysresccd_sys.cfg (v6)

MENU LABEL Boot SystemRescueCd using default options
LINUX boot/x86_64/vmlinuz
INITRD boot/intel_ucode.img,boot/amd_ucode.img,boot/x86_64/sysresccd.img
APPEND archisobasedir=sysresccd archisolabel=EASY2BOOT cow_label=arch

where arch is the volume label of the ext3 file.

'SYSRCD603' may have been changed by MakePartImage to EASY2BOOT and you should not need to change it.

If you get syslinux boot errors when MBR booting, edit the \sysresccd\boot\syslinux\sysresccd.cfg file and change the first line which is DEFAULT select to DEFAULT sys, OR you can type sys and press ENTER to load the syslinux menu, OR you can add a grub4dos menu to the end of the \menu.lst file - e.g.

this is four lines and assumes 'arch' is the persistent volume label...

title SysRescueCD with Persistence\n
kernel /sysresccd/boot/x86_64/vmlinuz archisobasedir=sysresccd archisolabel=EASY2BOOT cow_label=arch
initrd /sysresccd/boot/intel_ucode.img /sysresccd/boot/amd_ucode.img /sysresccd/boot/x86_64/sysresccd.img
boot

In the \menu.lst file, you can comment out the  #GENERIC BOOT MENU iftitle line and #syslinux via /syslinux.bin iftitle menu entries and set the default using the timeout and default menu entry to this new menu persistence entry (default was 12 in my case).

Type 'setkmap' in ArchLinux to see possible keyboard types and then add setkmap=uk after cow-label=arch to set a UK keyboard (for instance).

Boot parameter kernel options are detailed here.



cowspace shows it is using partition 3 for persistence



Persistence can be tested by adding a folder to the Desktop (must use File System Explorer - using right-click on Desktop does not work). You can also change wallpaper, theme, etc.

3 comments:

  1. Hi, thx for recipe! But i'm not getting persistence. I think followed all steps, including editing the cfg files. The MBR boot fails with error ""Undef symbol FAIL: init_fpu, Failed to load libcom32.c32, Failed to load COM32". Only Clover boot works, but no persistence.

    Here's my \syslinux\syslinux.cfg:

    PATH /sysresccd/boot/syslinux/
    DEFAULT loadconfig

    LABEL loadconfig
    CONFIG /sysresccd/boot/syslinux/sysresccd.cfg
    APPEND /sysresccd/

    cow_label = sysrescuev6

    ----------

    Here's my \boot\grub\grubsrcd.cfg:

    # Global options
    set timeout=90
    set default=0
    set fallback=1
    set pager=1

    # Display settings
    if loadfont /boot/grub/font.pf2 ; then
    set gfxmode=auto
    insmod efi_gop
    insmod efi_uga
    insmod gfxterm
    insmod all_video
    insmod videotest
    insmod videoinfo
    terminal_output gfxterm
    fi

    menuentry "Boot SystemRescueCd using default options" {
    set gfxpayload=keep
    linux /sysresccd/boot/x86_64/vmlinuz archisobasedir=sysresccd archisolabel=EASY2BOOT
    initrd /sysresccd/boot/intel_ucode.img /sysresccd/boot/amd_ucode.img /sysresccd/boot/x86_64/sysresccd.img
    }

    menuentry "Boot SystemRescueCd and copy system to RAM" {
    set gfxpayload=keep
    linux /sysresccd/boot/x86_64/vmlinuz archisobasedir=sysresccd archisolabel=EASY2BOOT copytoram
    initrd /sysresccd/boot/intel_ucode.img /sysresccd/boot/amd_ucode.img /sysresccd/boot/x86_64/sysresccd.img
    }

    cow_label = sysrescuev6

    ReplyDelete
    Replies
    1. hi
      well the UEFI grub2 file you need to edit is sysresccd_sys.cfg
      Also the cow_label=sysrecuev6 is in the wrong place - it should be after the archisolabel=EASY2BOOT parameter (as shown in the example!). Why on earth did you put it on a separate line outside the menu!

      The MBR Syslinux is obviously not working because it is using syslinux 604 which is very experimental! It is probably easiest to modify the \menu.lst file and add

      ### END OF MPI MENU.LST ###


      title SysRescueCD\n
      kernel /sysresccd/boot/x86_64/vmlinuz archisobasedir=sysresccd archisolabel=EASY2BOOT cow_label=arch
      initrd /sysresccd/boot/intel_ucode.img /sysresccd/boot/amd_ucode.img /sysresccd/boot/x86_64/sysresccd.img
      boot

      to the end of the file. I assume the volume label is arch in this example!





      Delete
  2. "Why on earth did you put it on a separate line outside the menu!"
    my ignorance, wasn't sure where to put it.

    i restored the 2 cfg files to their original state.

    Now i added the following to sysresccd_sys.cfg:

    ...
    APPEND archisobasedir=sysresccd archisolabel=EASY2BOOT cow_label=sysrecuev6
    ...

    and

    ...
    APPEND archisobasedir=sysresccd archisolabel=EASY2BOOT copytoram cow_label=sysrecuev6
    ...

    If MBR is "experimental", then i don't need it. Just want a reliable setup. I added the following to the end of menu.lst:

    ### END OF MPI MENU.LST ###


    title SysRescueCD\n
    kernel /sysresccd/boot/x86_64/vmlinuz archisobasedir=sysresccd archisolabel=EASY2BOOT cow_label=arch
    initrd /sysresccd/boot/intel_ucode.img /sysresccd/boot/amd_ucode.img /sysresccd/boot/x86_64/sysresccd.img
    boot

    "I assume the volume label is arch in this example"
    - not sure if i need to change anything for that...

    Will test this now...

    ReplyDelete