Thursday, 12 May 2016

Booting Dr.Web LiveDisk ISO with persistence from grub2

The Dr.Web ISO boots fine in MBR mode from E2B and can be booted from the ISO with persistence by adding a .mnu file.

However, during testing of the new GRUB2 menu system for E2B, I tried the Dr.Web LiveDisk ISO (drweb-livedisk-900-cd.iso - free), but it did not boot using the grub2 menu that I 'borrowed' from the 'Multiboot USB Flash drive' project here (I got a 'squashfs not found' type error).

After many attempts to get it booting from an ISO using the cheat code 'iso-scan/filename=', I finally looked at the 'casper' linux shell script file located inside the initrd file in the scripts folder (using 7Zip), and found this code...

parse_cmdline() {
    for x in $(cat /proc/cmdline); do
        case $x in
                export SHOWMOUNTS='Yes' ;;
                export PERSISTENT="Yes" ;;
                export PERSISTENT="" ;;
                export PERSISTENT_PATH="${x#persistent-path=}" ;;
                export UNIONFS="${x#union=}";;
                if [ "${STATICIP}" = "" ]; then
                export STATICIP ;;
                UUID=${x#uuid=} ;;
                UUID="" ;;
                export LIVE_MEDIA_PATH
                echo "export LIVE_MEDIA_PATH=\"$LIVE_MEDIA_PATH\"" >> /etc/casper.conf ;;
                export TORAM="Yes" ;;
                export TODISK="${x#todisk=}" ;;
    if [ "${UNIONFS}" = "" ]; then
        export UNIONFS="DEFAULT"

From this I could find no 'fromiso' or 'isoscan/filename' cheat code with which to tell the kernel what ISO file to find the squashfs files in! There was no mention of 'iso-scan' in any other script either! So it looks like booting from an ISO file is not going to be possible using cheat codes.

Next, I tried a 'flat-file' boot by extracting the contents of the ISO file to my USB drive (2nd partition for the grub2 menu ssytem).

After some experimentation, I found that the key to getting it to work was to use the 'ignore_uuid' cheat code. This told the kernel not to try looking for the 'cdrom'.

For the final .grub2 menu file, I ended up with this menu (note that some long lines may wrap over to the next line):

# only tested on FAT32 so far
#drweb-livedisk-900-cd.iso  extract iso to \ISO_Extract\drweb  (probably only casper folder needed)
#EFI64 MBR64 EFI32 MBR32
if [ -e "$root2$isoextpath/drweb/casper/vmlinuz" ]; then
menuentry "DrWeb live CD (extracted)" --unrestricted --class drweb{
set root=$root2
set fldname=drweb
# must use ignore_uuid  !!!
linux  $isoextpath/$fldname/casper/vmlinuz  boot=casper live-media-path=$isoextpath/$fldname/casper ignore_uuid --
initrd $isoextpath/$fldname/casper/initrd.lz

Folder structure
\ISO_Extract\drweb\casper (folder)
\ISO_Extract\drweb\install (folder)

You can have persistence by creating a 200MB ext2 file using RMPrepUSB - Create ext2 file - casper-rw - casper-rw - 200 on a spare USB drive, and then copy the file the \ISO_Extract\drweb folder.

I will provide a ready-made 200MB file in the grub2 download which you can unzip and use.
Dr.Web with persistent desktop and updates.
This works under both MBR and UEFI and on both 32-bit and 64-bit systems even though there are no UEFI boot files in the ISO!

I have not tested NTFS yet, but I see some people have reported that it does not boot on NTFS partitions.

P.S. I just retested this and now it stops and prompts me with:
'Please provide a name for this disk' 
Same disk, same file, same menu!

I don't know what I changed! Usually this message means it is looking for a .disk folder in the root, but even if extract it from the ISO and put it there (and in several other places!), I still get the message and it doesn't boot! grrrrr...
It can be made to continue by typing  ALT+F1 - enter some random text e.g. "xxx" - then press [ENTER] key and it should continue to boot (press ALT+F7 to return to message console if required).