under construction

Contents


Pre-amble
Credits

Chapter A sidux instructions

Chapter B Menuentry

Chapter C Generic iso TIPS

Chapter D Do you know the (grub2) correct pathway?

Chapter E Using TAB key to autocomplete

Chapter F Errors

Chapter G Distros




Pre-amble


I have not (atm) seen any wiki or howto do this feat. But others have used the feature as I have found links which are in my credits.
In case you have come to this page from a google search, I am not a member of any Grub dev team. I am not an expert. Try at your own risk.

hd=hard drive
"hd pathway" refers to how a booted up hd system sees your folder structure.
"correct pathway" refers to grub2's pathway which can be different from hd pathway.

On a booted up hd system, sux means
http://manual.sidux.com/en/term-konsole-en.htm#sux

On a booted up hd system, if you can only use sudo which is NOT supported by sidux, adjust commands to
sudo command 


This wiki is not the same as the grub legacy manual page
http://manual.sidux.com/en/hd-install-opts-en.htm#fromiso



Credits


Stefan Lippers-Hollmann (slh)
for source script for sidux users
https://svn.berlios.de/svnroot/repos/fullstory/grub2-fll-fromiso/trunk/60_fll-fromiso

Joaquim Boura (x-un-i)
for uploading the script and helping me understand what boot=string means.

Daniel Guzanof
http://www.linux.com/community/blogs/Boot-an-ISO-via-Grub2.html

Pawel Konczalski
http://www.panticz.de/MultiBootUSB

Jim Wright for unpack of initrd.img ( I could have used anyone but google gave me this link)
http://www.linux-archive.org/centos/308254-adding-kernel-module-iso-installer-initrd.html

sidux user
silentnights for testing and reporting on init script issues, Isolinux issues etc

Chapter A sidux instructions


Warning to sidux users....please read

This wiki was designed using sidux 2009-02. Dev team may release a grub2 release, possible candidate is 2009-04. When ever the grub2 release occurs, irrespective of its release number, sidux users are not to use Chapter A wiki script, as by then, sidux team have developed a replacement script. From that date, sidux manual will be updated for grub2 and sidux users must use the manual and not the wiki.


Chapter A Part A The script
sidux devs have created a script which is very much appreciated. However, that script is designed for devs and not simple users like myself. Therefore I have modified it and it boots my sidux distro. Copy and paste contents of code box contents and name the file grub2script. You do this in your home folder. Feel free to move or make backups. Its only in a code box to highlight it.



#! /bin/sh -e

# grub-mkconfig helper script.
#
# Copyright © 2009 Stefan Lippers-Hollmann <s.l-h@gmx.de>
#
# This program is free software; you can redistribute it and/or modify it under the terms of the
# GNU General Public License as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# Source code is found at https://svn.berlios.de/svnroot/repos/fullstory/grub2-fll-fromiso/trunk/60_fll-fromiso

# PLEASE READ ALL AND MODIFY AS SUGGESTED

# Modified by aus9 for English/German and /home folder users....maybe for others as well.
# removed quiet, screen=1400x1050, xrate=100 from FLL_GRUB2_CHEATCODE
# Comments by slh appear above the action line while my explanations/requests appear below the relevant line.
# override tool behaviour through /etc/default/grub2-fll-fromiso
if [ -r /etc/default/grub2-fll-fromiso ]; then
	. /etc/default/grub2-fll-fromiso 
fi

FLL_GRUB2_ISO_LOCATION="${FLL_GRUB2_ISO_LOCATION:-"/home/gordy/isos/"}"
# Edit above line please.........................^^^^^^^^^^^^^^^^^^

FLL_GRUB2_ISO_PREFIX="${FLL_GRUB2_ISO_PREFIX:-"sidux"}"
# target iso(s) to be added to menuentry...must start with name sidux

#FLL_GRUB2_LANG="${FLL_GRUB2_LANG:-"de_DE"}"
FLL_GRUB2_LANG="${FLL_GRUB2_LANG:-"en_AU"}"
#FLL_GRUB2_LANG="${FLL_GRUB2_LANG:-"en_US"}"
# Language preference can be found inside /usr/share/i18n/SUPPORTED
# Choose the first 5 keystrokes similar to en_AU but for your language and your Country please.
# Uncomment yours if you can see here, German, Aussie, American and comment mine out 
# Otherwise edit my aussie line please.

#FLL_GRUB2_TZ="${FLL_GRUB2_TZ:-"Europe/Berlin"}"
FLL_GRUB2_TZ="${FLL_GRUB2_TZ:-"Australia/Perth"}"
# Timezone location, uncomment German line if relevant and comment out mine or edit to your area please
# Refer to /usr/share/zoneinfo/ and select Regionname/Cityname as your preference. 

FLL_GRUB2_CHEATCODE="${FLL_GRUB2_CHEATCODE:-"vga=791 noeject"}"

# source overrides
# [ -r /etc/default/grub2-fll-fromiso ] && . /etc/default/grub2-fll-fromiso

# we need isoinfo if it's not there go out
ISOINFO=`which isoinfo`
if [ -z "${ISOINFO}" ]; then
	exit 
fi

# find ISO
FROMISO=`find ${FLL_GRUB2_ISO_LOCATION} -name ${FLL_GRUB2_ISO_PREFIX}*.iso`
# for example script may find FROMISO="${FLL_GRUB2_ISO_LOCATION}/sidux-snapshot-kde-full-i386-amd64-200908230118.iso"

# no iso found quit
if [ -z "${FROMISO}" ]; then
	exit
fi

# assemble cmdline
CMDLINE="boot=fll lang=${FLL_GRUB2_LANG} TZ=${FLL_GRUB2_TZ} ${FLL_GRUB2_CHEATCODE} "

# create a temp device.map as the actual can be not uptodate
DEVICE_MAP_TMP=`mktemp` 
grub-mkdevicemap -m "${DEVICE_MAP_TMP}"

for iso_image in $FROMISO; do

	cur_device=`grub-probe --device-map=${DEVICE_MAP_TMP} --target=device ${iso_image}`
        cur_uuid=`grub-probe --device-map=${DEVICE_MAP_TMP} --target=fs_uuid ${iso_image}`

	mountpoint=`awk -v var="$cur_device" '{if ($1 == var){print $2}}' /proc/mounts`
	stripped_path="${iso_image##$mountpoint}"


	if [ "${mountpoint}" = "/"  ]; then
		stripped_path="/${stripped_path}"
	fi

	kernels=`${ISOINFO} -J -l -i ${iso_image} |awk '/vmlinuz/{print $12}' |sed 's/vmlinuz\-//'`

	for kernel in ${kernels}; do
		cat << EOF
menuentry "${FLL_GRUB2_ISO_PREFIX} ($kernels)" {
	search --no-floppy --fs-uuid --set ${cur_uuid}
        loopback loop ${stripped_path}
	linux (loop)/boot/vmlinuz-${kernel} fromhd=UUID=${cur_uuid} fromiso=${stripped_path} $CMDLINE
	initrd (loop)/boot/initrd.img-${kernel}
}
EOF
	done

done


Please use your filemanager to make it executable or run
chmod +x grub2script



The reason for the modifying the dev script is, IMHO by using the commands associated with the script, the output of the script
is saved to 40_custom script. Any upgrade of grub 2 should not change any existing 40_custom script. I am suggesting that an
update of grub2 may overwrite /usr/sbin/grub-mkconfig while my "way" keeps the scripts independent of each other.

I prefer you do not replace /usr/sbin/grub-mkconfig unless you really know what you are doing.

Chapter A Part B Commands to use with script

Chapter A Part B Section 1
Assuming you are in home folder, have one sidux iso or different release numbers of sidux we do this:
sux
./grub2script >> /etc/grub.d/40_custom && update-grub


So the grub2script generates one or more menuentries....which are added to the 40_custom script and then update-grub uses the 40_custom script to modify our /boot/grub/grub.cfg

Chapter A Part B Section 2
However, if you have multiple sidux*.iso files from the same release cycle, you are likely to have the same kernel which if we use the above command, generates duplicate entries. Therefore, we change to
sux
./grub2script >> /etc/grub.d/40_custom 

and then as per Menuentry Chapter, we modify one or more menuentries to give them different names.
eg menuentry "sidux 2.6.30 kde"
.....and its entry stuff
...menuentry "sidux 2.6.30 xfce"
......and its entry stuff

Then run update-grub to modify our grub config file.

Chapter A Part C Checking 40_custom


To show the Part B commands with grub2script have added one or more entries to our 40_custom script, we can run.
# cat /etc/grub.d/40_custom 

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry "sidux (2.6.30-1.slh.3-sidux-686)" {
	search --no-floppy --fs-uuid --set ba23e80d-f21f-4c43-9d7e-0701bb041a66
        loopback loop /home/gordy/isos/sidux.iso
	linux (loop)/boot/vmlinuz-2.6.30-1.slh.3-sidux-686 fromhd=UUID=ba23e80d-f21f-4c43-9d7e-0701bb041a66 fromiso=/home/gordy/isos/sidux.iso boot=fll  lang=en_AU TZ=Australia/Perth vga=791 noeject  
	initrd (loop)/boot/initrd.img-2.6.30-1.slh.3-sidux-686
}


If your isofile is not on boot partition, and you have any errors, modify your 40_custom and re-run update-grub so you have a line above loopback to load a module
insmod loopback.

At the moment, I have no explanation why this work-a-round works. But no harm is done by inserting a module that may be attempted to be loaded twice.

Please use root powers to inspect contents of /boot/grub/grub.cfg.
Above entry assumed grub2script found only one sidux* iso file in nominated folder. It could contain 2 or more sidux entries

Chapter A Part D a more simple script

It crossed my mind, what differences were there in using my failed "generic" way compared to script? Well the extra lines above loopback command for a start.
And I did not have a fromhd entry. So I went into command mode and tested and booted my sidux iso using a much simpler technique.

So if you inserted or amended this into 40_custom
menuentry "sidux (2.6.30-1.slh.3-sidux-686)" {
loopback loop /home/gordy/isos/sidux.iso
linux (loop)/boot/vmlinuz-2.6.30-1.slh.3-sidux-686 fromhd=/dev/sda1 fromiso=/home/gordy/isos/sidux.iso boot=fll vga=791
initrd (loop)/boot/initrd.img-2.6.30-1.slh.3-sidux-686
}

Then ran update-grub.

It looks even better when its only commands...and using TAB to autocomplete all but fromhd and fromiso strings.

loopback loop /home/gordy/isos/sidux.iso
linux (loop)/boot/vmlinuz-2.6.30-1.slh.3-sidux-686 fromhd=/dev/sda1 fromiso=/home/gordy/isos/sidux.iso boot=fll vga=791
initrd (loop)/boot/initrd.img-2.6.30-1.slh.3-sidux-686

Further testing suggests it works well only if isofile is on same boot partition. Errors can occur when they differ. Adding the absolute pathway was not resolving all issues. Instead for different partitions I had to change this format.

insmod loopback
loopback loop (hd0,2)/isos/sidux.iso
linux (loop)/boot/vmlinuz-2.6.30-1.slh.3-sidux-686 fromhd=/dev/sda2 fromiso=/dev/sda2/isos/sidux.iso boot=fll vga=791
initrd (loop)/boot/initrd.img-2.6.30-1.slh.3-sidux-686

The above format works well for sidux due to the structure of the sidux scripts.


Chapter A Part E sidux only distro errors or issues

Sequentially they start from the beginning so

user failed to copy and paste script corrrectly
user failed to amend script at relevant sections to hd pathway and other choices
user has no sidux iso in pathway...DOH!
user failed to make file executable....run file grub2script to check its really executable
user failed to run root commands and chose the wrong section 1 versus 2 leading to some issues with the entries
user had to choose section 2 and forgot to run update-grub
user failed to check the 40_custom script was updated for new entries
user did not use >> so 40_custom was NOT appended or added to but maybe overwritten
user has unresolved "update-grub" issues from past that were not fixed...refer to other pages in wiki.
user has done it all but menuentry does not appear correctly?
....Possible syntax error in 40_custom...use vi to display colours, it may offer a clue.
script uses UUID, user kept this format and has issues booting isofile
.....Try adopting to simple /dev/sdXn way to see if resolved
user adopted simple script and has booting issues
....Try adopting back to normal sidux script
iso starts to boot and hangs at "failed to detect media"
....sidux iso needs both the fromhd and isofrom inputs
iso starts to boot and hangs at some kernel related error
....try amending kernel cheat codes and retry
iso starts to boot but hangs quite early at /dev/mapper area
....Your pc is too fast for kernel...send it to me for further testing (joke)
....No honestly I have had some quirks...reboot and try again...its ok to fail once

I or someone else has tampered with script so the script fails....is a product of user submitted wikis. Refer to the source code and amend your script.
I have a copy of my own script so can fix if alerted to change. pm me if you are concerned with other user edits.....unless its slh or dev team.


Chapter B Menuentry

Chapter B Part A Using a text editor to create entries
You may not need to read this section. However, for non-sidux distros, we have knowledge of successful commands to boot the iso. Use root commands to edit /etc/grub.d/40_custom to add each menu you need. I use a text editor.

Text placed into a code box to highlight it
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry "grml" {
 loopback loop (hd0,2)/isos/grml.iso
 linux (loop)/boot/grmlmedium/linux26 boot=live isofrom=/dev/sda2/isos/grml.iso
 initrd (loop)/boot/grmlmedium/initrd.gz
}


WARNING Ensure you click onto a new empty line before saving file if using a text editor please. This is because the append command >>as menitoned in this wiki starts from the last saved cursor position.

You may notice that the grml entry has no.."fromhd=string"

If you prefer not to use a text editor, vi is useful to show colours.
image

Notice we drop the boot command but add a menuentry line.

Next using root powers run the command
update-grub

Then check /boot/grub/grub.cfg with root powers to see if entry looks ok and reboot to test it.

Assuming you are a sidux user, take care to append (=add) menus to your 40_custom file after running the sidux script. If you delete your sidux entry, you will need to run the script again. Remember, each time you run update-grub it calls and actions all scripts including the 40_custom one. Be aware, each time you upgrade your kernel, the kernel scripts will likely run update-grub as well.

Chapter B Part B Using commands to create Menuentry
If you do not have a text editor its possible to use commands to edit that custom file. If your terminal has ability to copy and paste, open one terminal and copy from a source file like this
cat <<EOF>> /etc/grub.d/40_custom
menuentry "iso" {
 loopback loop (hd0,2)/isos/grml.iso
 linux (loop)/boot/grmlmedium/linux26 boot=live isofrom=/dev/sda2/isos/grml.iso
 initrd (loop)/boot/grmlmedium/initrd.gz
}
EOF

If your terminal can not use copy or paste...you can do it line by line. After entering the first line....the prompt changes to show
>
and will pre-pend each line of input until you complete and enter the last line of EOF. (= End of file.)

Don't forget to run update-grub with root powers to modify your grub.cfg file

Chapter C Part A Generic iso TIPS


Research the iso file, without booting it up in a virtual machine. That means we treat it like a data disc.

How do we know what pathway to use, assuming you have not burnt the iso to cd? We boot up the normal hd system and create a folder on some
partition that will have free space to allow a live cd to be mounted. We do not use a virtual machine to unpack it. Pretend its your home partition so
$ mkdir mnt/
$ sux
# mount -o loop /pathway2file/someiso.iso mnt/


Then use your file manager or commands like.... ls ....cat ......file..... to research folders and files.

file is used to identify filetypes, if you are unsure if its a kernel or compressedfile for squashfs, cramfs, unionfs etc.
eg
file mnt/boot/grmlmedium/linux26 
mnt/boot/grmlmedium/linux26: Linux kernel x86 boot executable bzImage, version 2.6.28-grml (grml.org@buildserv, RO-rootFS, swap_dev 0x2, Normal VGA


Look into any boot folder you might find. In particular look for any grub sub-folder which might hold a menu that shows boot= or root=

Look also at any special foldername that is non-FHS such as /sidux, /live, etc

Higher level search may be required if you can not find the cheatcodes. This means we need to unpack the initrd. First create a folder where target initrd will be able to be unpacked...mine is /home/gordy/unpack/
Next I prefer to copy and rename the target initrd from our mount folder (mnt)
Next extract or unpack the initrd.
Now do your research into each folder and run file against any likely candidate if your file manager can not show filetypes.

Don't forget to unmount mnt/

Chapter C Part A research initrd


mkdir unpack/
sux
mount -o loop /pathway2iso/sidux.iso mnt/
cp mnt/boot/initrd.img-2.6.30-1.slh.3-sidux-686 /home/yourname/unpack/initrd.img
cd unpack/
gunzip -c initrd.img | cpio -i

(Research then shows I need to issue next command)
ls scripts/
fll  functions  init-bottom  init-premount  init-top  local  local-bottom  local-premount  local-top  nfs
cd ..
umount mnt/


image

You can tell by green colour its a script. Use your file manager or use cat command to view this script if you wish. Of interest me, was the error script section for
"failed to detect live media" which was a message I saw on one of my failed attempts.

Therefore, if you missed seeing the grub/menu.lst and its cheatcode...the unpacked initrd reveals the script is called fll for sidux. So boot=fll.

TIP: Your research may show the name of a script. The scriptname can be tried for the kernel cheatcode as boot=scriptname

If you have multiple distros to research, sidux has bash-completion, and command history, as do most other good distros. If you have never used bash-completion...it is simiilar to my Chapter E. If you have never used command history before, you press the up arrow in a terminal to recall previous commands. You can use a text editor to cull your /.bash_history if its too big. Therefore the command
cp mnt/boot/initrd.img-2.6.30-1.slh.3-sidux-686 /home/yourname/unpack/initrd.img
will change for the beginning but I require you to always use the same last bit =/home/yourname/unpack/initrd.img. This allows you to repeat most commands with very few keystrokes and modifications.

Chapter C Part A Research minirt.gz

Not all distros have an initrd file.
One distro I am researching atm has a minirt.gz

Copy the minird.gz to home folder and unpack it there with
 gunzip -d minirt.gz


If you run..... file minirt..(the result of gunzip command..you will see its cpio archive so my gfxmenu command still works on these.
copy minirt to /home/yourname/unpack.

Ensure unpack/ was empty before copying please. (In case you used it for other research)


cd /home/yourname/unpack
sux
cpio -iv < minirt



You can now research what is there. And the script name is called init.


Chapter C Part B Essential Elements to succeed


Depending on whether you try out command mode or create menuentries, you must know and understand the following:

What is correct pathway to iso file?
If you using UUID, what is correct UUID?
What is isofile (=cd) pathway to some kernel?
If needed, what is isofile (=cd) pathway to some initrd?
What kernel cheatcodes are essential for this distro?
....In particular, does it use a boot=(string) or a root=/dev/something
....If its designed as a pure live cd, does it expect a minimum ramdisk size?
You may need to insert extra modules for non-boot iso partitions...see below

Some distro sites may name the cheatcodes that work specifically for them.
http://manual.sidux.com/en/cheatcodes-en.htm#cheatcodes

Chapter C Part C Possible generic commands

Which can then be used to create menuentry

loopback loop (hdX,Y)/pathway to /filename.iso
linux (loop)/pathway 2 kernel/(kernelname) fromhd=/dev/sdW(number) isofrom=/dev/sdW(number)/pathway to /filename.iso boot=(as per research) vga=791
initrd (loop)/pathway to initrd/(initrdname)
boot


Its a formula so even if we are on /boot partition we adopt absolute pathways in top line (hdX,Y)
(kernelname) = vmlinuz or vmlinuz-(version) or bzImage or something as per research
fromhd= added to formula so I know you always use it
isofrom= no surprises there
boot= may not exist with research....unpack of initrd.img or researched grub on cd may reveal a boot=/dev....instead
vga=791 Most of us on grub2 can handle nicer font sizes?
initrd line no changes in formula
boot no changes in formula

Part D was written after this part. I am now thinking for those who use menuentries....most of us...UUID may be easier? For those using the command mode it is not.


Chapter C Part D Using UUID menuentries


We need a simpler way of creating UUID menuentries when the /dev/sdx type menu fails.

Firstly, research your current UUIDs

image

 ls -al /dev/disk/by-uuid


We can copy and paste the string into /etc/grub.d/40_custom.

Secondly, we need the syntax to use to allow grub2 to use UUID

So lets review one sidux entry to know how to use it. Placed into a code box to hightlight it
menuentry "sidux (2.6.30-1.slh.3-sidux-686)" {
	search --no-floppy --fs-uuid --set ba23e80d-f21f-4c43-9d7e-0701bb041a66
        loopback loop /home/gordy/sidux.iso
	linux (loop)/boot/vmlinuz-2.6.30-1.slh.3-sidux-686 fromhd=UUID=ba23e80d-f21f-4c43-9d7e-0701bb041a66 fromiso=/home/gordy/sidux.iso boot=fll lang=en_AU TZ=Australia/Perth vga=791 noeject 
	initrd (loop)/boot/initrd.img-2.6.30-1.slh.3-sidux-686
}


So the key bits are on line
search --no-floppy --fs-uuid --set ba23e80d-f21f-4c43-9d7e-0701bb041a66

Replace that string with yours please

and same again for the kernel (linux) line

fromhd=UUID=ba23e80d-f21f-4c43-9d7e-0701bb041a66


You still need to study Chapter D knowing the correct pathway. But it may increase the chance of success?

So a rough formula where isofile is ON or NOT ON boot partition becomes

menuentry "isoname" {
	search --no-floppy --fs-uuid --(string for UUID)
        loopback loop /correct pathway2/isofile.iso
	linux (loop)/pathway2/(somekernelname) fromhd=UUID=(UUID string) fromiso=corrrectpathway2/isofile.iso boot=(researchresult) (researched cheatcodes) 
	initrd (loop)/pathway2/(some initrdname)
}


Note it may not be boot=(reseach script) but maybe root=/dev/ram0 or root=/dev/null or someother root=string


This UUID menuentry does not need to use (hd0,6) or some other absolute grub2 method of describing your 6th partition as UUID fixes that.

This means you study Chapter D ....not to use (hdx,y) but to understand you may need to drop the hd pathway /home/yourname to just /yourname.

I am now thinking this is a better generic menuentry compared to what I wrote before. More testing may assist?

I have done a lot of testing at command mode and just discovered...that UUID is not enough to resove issues with booting an isofile that is not on the same boot
partition. I have no idea why. But I found a work-a-round....without the extra command ...sidux iso on non-boot partition sometimes fails.

Failure message
"Failed to mount iso9660 filesystem from iso image"

MY work-a-round....add a insmod loopback command to menuentry. So it would appear as this.

menuentry "isoname" {
	search --no-floppy --fs-uuid --(string for UUID)
	insmod loopback
        loopback loop /correct pathway2/isofile.iso
	linux (loop)/pathway2/(somekernelname) fromhd=UUID=(UUID string) fromiso=corrrectpathway2/isofile.iso boot=(researchresult) (researched cheatcodes) 
	initrd (loop)/pathway2/(some initrdname)
}


Interestingly, re-running that insmod command at command mode...never reports any errors. In other words, no harm is done by having the command.


Chapter D Do you know the (grub2) correct pathway?

There are some quirks in how grub2 sees your partitions which is not ALWAYS the same to how a booted up hd system sees your partitions and pathways.

This is going to take some time to explain.WARNING I am subject to aussie download limits and speeds so have no interest in downloading and testing lots of distros. It is possible your success may be limited to grub legacy or grub2 iso files, YMMV. The explanation shows booting to menu and using commands. I am not suggesting you need to do this, but do it if your menuentry fails. The command mode gives you the option of using the TAB key to autocomplete. By understanding the examples of different patitions that your iso file can be on, you will know whether to drop the first part of the folder name or not.

So /home/yourname/isos/file.iso can be /home/yourname/isos/file.iso or /yourname/isos/file.iso. Advanced partition builders can have even more complex folder structures mounted on their hd system leading to more folders being dropped from the pathway.

Chapter D Part A Follow my example


Daniel's link was my first success. But I elected to choose medium edition to confirm my thinking. Download the medium edition from http://grml.org/download/
Rename it to grml.iso but where it is placed or copied to, depends on which Section you need to folllow.

Chapter D Part B Where /boot and iso file are on same partiton


This may be a single partition system common for most newbies. This may mean /boot is a sub-folder to / and typically /home may be a sub-folder as well. Lets pretend so and let hd pathway to iso be /home/yourname/isos/grml.iso. We assume / partition is /dev/sda1 which in grub 2 speak is (hd0,1)

However, this chapter also includes those who use a separate /boot partition and place the iso file within.
However, the other part of your menuentry and setup....has already linked mbr to this partition so there no need to
run a new set root=(hdx,y) in any menu or command in this chapter.

Let me re-phrase that. If you are at the menu stage of booting ....you have reached the /boot partition already.

Our first attempt will use "relative" pathway on the loopback line. If it fails, use the "absolute" pathway and line changes to
loopback loop (hd0,1)/home/yourname/isos/grml.iso


At grub 2 menu stage of booting....... Press C for commands and
.................. then press enter at end of each line please.

Commands are:
loopback loop /home/yourname/isos/grml.iso
linux (loop)/boot/grmlmedium/linux26 isofrom=/dev/sda1/home/yourname/isos/grml.iso boot=live
initrd (loop)/boot/grmlmedium/initrd.img
boot

Explanation of commands and other info.

On my system, there was no need to insert the loopback module with insmod loopback. Running line 1 and then running command lsmod
revealed the loopback module was automagically loaded by calling the loopback command. EDIT that was good for same boot partition but I am now thinking
it is safer to load that module for any isofile that is not the same boot partition.

loopback and loop will be setting up a device (optical) loopback or using losetup which is a feature Linux has had for some time.
Line 1 defines where grub 2 is to look for the file to be used for the image.

(loop) forces grub 2 to know its a loopback device pathway.

There is mention in the links of findiso but I prefer you use only one technique to ease troubleshooting.

isofrom tells grub the pathway to file, in partition and folder terms.

boot=live is a parameter required by initrd image for grml distro. Not all distros need boot=string

Initial ram disk image defines the pathway to target file.

Command mode needs a boot command which is not needed when we create menuentries.

Using the generic instructions we can research the "data" disc to see, that /boot/grmlmedium/ holds linux26 = the kernel and initrd.gz
= initial ram disk image.

"relative" pathway means not using "absolue" pathway. Meaning no (hdX,y). File.iso must be on same partition as boot to use relative pathway. When in doubt use absolute.
"absolute" pathway means including the correct (hdX,y) to the balance of the folders/filename. It is expected that you remember grub2 counts hard drives from zero but partitions from one. There should be no gap in the absolute pathway so its (hdX,y)/path/folder2/folder3/file.iso

Chapter D Part C Using separate partition to boot partition

Assume:
hd pathway is /home/yourname/isos/grml.iso
/dev/sda1 is the /boot partition
/dev/sda2 is /home partition which is (hd0,2) in grub 2 speak.

Commands are:
insmod loopback
loopback loop (hd0,2)/yourname/isos/grml.iso
linux (loop)/boot/grmlmedium/linux26 isofrom=/dev/sda2/yourname/isos/grml.iso boot=live
initrd (loop)/boot/grmlmedium/initrd.img
boot

Remember we drop the "/home" label and now need an absolute pathway using (hd0,2) for loopback.
Let me re-phrase that. If you used a live cd to ONLY mount the / partition, it would see the /home label but
using a file manager or commands to look inside it would show its empty. Its just a mount point. If you used a live cd
to ONLY mount the /home partition, looking at it would show only the sub-folder and files with no mention of /home.

EDIT insmod loopback added for safety's sake

Chapter D Part D using non-FHS partition
Because I know my root password, I can create a non Filesystem Hierarchy Standard such as /data...or /isos or something else.
http://proton.pathname.com/fhs/

The rule for dropping the "fstab label= mount point label" still applies.
Assume:
hd pathway is /isos/grml.iso
/dev/sda1 /boot partition
/dev/sda2 is /isos partition which is (hd0,2) in grub 2 speak.

Commands are:
insmod loopback
loopback loop (hd0,2)/grml.iso
linux (loop)/boot/grmlmedium/linux26 isofrom=/dev/sda2/grml.iso boot=live
initrd (loop)/boot/grmlmedium/initrd.img
boot

This requires some planning in building your system to begin with. But a lot people do have a /data type partition so may apply?

Chapter E Using TAB key to autocomplete

This feature of grub2 does not work for the isofrom section but works for all of the other pathways. This feature is only available in command mode.

Lets pretend we needed to run command loopback loop /home/yourname/isos/grml.iso
loopback loop /h...Press the TAB key to autocomplete home
loopback loop /home/g....Press the TAB key to autocomplete my username gordy
loopback loop /home/gordy/i....Press the TAB key to autocomplete isos
loopback loop /home/gordy/isos/g...Press the TAB key to autocomplete grml.iso

You can achieve similar results on the other lines. You can also use it to autocomplete various commands like boot or loopback.

The TAB key to autocomplete in grub2 command mode, is similar to using the TAB key to autocomplete commands and pathways in a hd booted up system.

Hopefully you can tell this feature has been used to determine the correct pathway!
If I typed /h and TAB did not autocomplete....change it to /g and see if autocompletion works.

I can not stress enough .....how important the use of TAB key is to resolve.....correct pathway issues.



Chapter F Errors

Not all distro may be bootable.

You might find fromhd is not required, eg grml and Slitaz don't need it.

I found one issue where isofile resides on different partition to boot. Current work-a-round is to use menuentry or commands to load loopback module
by running
insmod loopback
either in command mode or menuentry before trying the loopback command. (I have no explanation as to why it works better).

Distros that are built with Isolinux (Syslinux) can be a challenge.

Distros that do not use an initrd but some other form such as rootfs can be a challenge but I succeeded with rip.

It goes back to how good your research was..in finding what is the main kernel (linux) cd line. Does it contain a boot=string or a root=/dev/ram or what?
Be aware that a /boot/grub found on live cd...may be a folder to be copied onto hard drive and so may be misleading. Check the menu.lst or grub.cfg for a clue please.

If a kernel line is filled with cheatcodes...try a small amount first. It is not always necessary to define ramdisk_size when using root=/dev/ram.

Chapter G Distros

I have succeeded with
sidux
grml
RIPLinux
Slitaz

See Pawel's link for a number of distros and their menuentries.


Grub2Intro