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

UEFI-64 & MBR-booting with persistence

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.

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

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

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

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.


Modifying the menus

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


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