Saturday 6 September 2014

How to make your own linux ISO .mnu files

I was asked today about LXLE with persistence. This distro is based on Lubuntu and the user wanted to get persistence working. There was a lubuntu-13.04-desktop-i386_Persistent.mnu menu available but not one for LXLE.

I thought I would describe how I went about changing this lubuntu-13.04-desktop-i386_Persistent.mnu file to get it working with LXLE.

  • First I copied the lubuntu-13.04-desktop-i386_Persistent.mnu file and the lxle ISO file to the \_ISO\MAINMENU\MNU folder of my E2B NTFS USB drive which I use for testing.
  • Next, I renamed the file to lxle-1404-x64_Persistent.mnu.
  • Next, I edited the .mnu file in Notepad to change all occurrences of the  lubuntu-13.04-desktop-i386.iso file to lxle-1404-x64.iso.
  • Next, I changed all occurrences of the persistent file lubuntu-rw to lxle-rw
  • Finally, I made a persistent ext2 file in the root of the E2B USB drive using RMPartUSB's - Create ext2 FS button. When prompted I used:
               File Name = lxle-rw
               Volume Name = casper-rw
               Size = 500
  • I then ran WinContig on the drive (RMPrepUSB - Ctrl+F2).

Unfortunately, I got an error when I tried to boot from the menu entry in E2B


This indicated that the file \casper\initrd.lz was not actually present inside the .iso file.

Looking inside the ISO file using 7Zip to view it, I found:


Normally, in a linux ISO that uses isolinux to boot, there is an isolinux folder which holds several .cfg files, the main one being isolinux.cfg. If grub is used, there may be a \grub folder containing config files. If grub4dos is used, it may have a \menu.lst file and other .lst files.

I double-clicked isolinux.cfg to open it up in Notepad ++ (if you try to use Windows NotePad, it will merge all the lines together due to a CR/LF problem - see below).

The isolinux.cfg main LiveCD menu entry seems to be:

label live
  menu label live - boot the Live System
  kernel /casper/vmlinuz
  append  file=/cdrom/preseed/custom.seed boot=casper initrd=/casper/initrd.gz quiet splash --

So I converted this to grub4dos as follows:

kernel /casper/vmlinuz file=/cdrom/preseed/custom.seed boot=casper persistent quiet splash --
initrd /casper/initrd.gz 

As you can see, we just need to re-arrange a few things. The reason for the error is now apparent, because the file used for the initial ramdrive (initrd) is initrd.gz and not initrd.lz as it was in the Lubuntu .mnu file.

Warning: Do NOT copy and paste whole lines from a linux .cfg file into a grub4dos .mnu file. The carriage-return/line-feed end-of line characters are not the same in a linux file and although it may look OK in NotePad, it won't work in grub4dos due to embedded invisible CR/LF characters! It is better to type them in manually rather than copy and paste in lines from a linux text file!

We need to add in the 'persistent' parameter so that it will look for a casper-rw volume when it boots.

In the end, after tidying up the .mnu file a bit to make it easier to modify for the end user, we have:

# Make a ext2 file using latest version of RMPrepUSB in the root of the drive 
# File Name=lxle-rw  Volume Name=casper-rw
# Place this .mnu file and the ISO in either \_ISO\MainMenu\MNU or \_ISO\Linux\MNU
# This menu will work even on an NTFS USB boot drive
# IMPORTANT: you MUST run WinContig (Ctrl+F2) before booting E2B.
# e.g.
#\lxle-rw
#\_ISO\MAINMENU\MNU\lxle-1404-64.iso
#\_ISO\MAINMENU\MNU\lxle-1404-64_Persistent.mnu


iftitle [if exist $HOME$/lxle-1404-64.iso] LXLE 14.04\n Boot using .mnu file with persistence

set ISO=$HOME$/lxle-1404-64.iso
set PER=/lxle-rw

if exist CD echo WARNING: Cannot use partnew command! && pause && configfile (bd)/menu.lst
if "%E2BDEV%"=="" set E2BDEV=hd0 && pause E2BDEV forced to hd0!
#enable parttype output
debug 1
# make empty table entry in 3rd position in ptn table
parttype (%E2BDEV%,2) | set check=
debug off
set check=%check:~-5,4%
if "%check%"=="0x00" partnew (%E2BDEV%,2) 0 0 0
if not "%check%"=="0x00" echo WARNING: PTN TABLE 3 IS ALREADY IN USE - PERSISTENCE MAY NOT WORK! && pause
debug 1
if not exist %PER% echo WARNING: %PER% persistence file not found! && pause
errorcheck off
if "%check%"=="0x00" partnew (%E2BDEV%,2) 0x0 %PER%
errorcheck on
#map ptn 4 to ISO
partnew (%E2BDEV%,3) 0x0 %ISO%
map %ISO% (0xff)
map --hook
root (0xff)
kernel /casper/vmlinuz file=/cdrom/preseed/custom.seed boot=casper persistent quiet splash --
initrd /casper/initrd.gz 


This .mnu file will be in the Sample mnu Files folder in the next E2B 1.56Beta download and is also in the Alternate Download area now (though it may be removed later when 1.56 is released).




No comments:

Post a Comment