Jump to content











Photo

Please help me learning how grub/syslinux work

grub syslinux add iso

  • Please log in to reply
7 replies to this topic

#1 verzasoft

verzasoft
  • Members
  • 4 posts
  •  
    Italy

Posted 10 December 2015 - 12:52 AM

I try to be short.

 

I made a usb stick with 2 iso (loaded as grub4dos iso image emulation).

They work correctly.

Then, I want to rename one of the isos: from "pmagici686.iso" to "pmagic.iso". So i rename the file in \images folder and the name of the iso in text files \menu.lst and \boot\syslinux\syslinux.cfg.

Surprisingly it does NOT work anymore correctly: Parted Magic loads, it extracts some files, then it hangs during extraction of PMAGIC_2013_05_01.SQFS, that cannot find. For the same reason i cannot simply add isos and manually modify the menus.

 

The question is: why it hangs simply due to renaming the file??? If the iso has been found and started as it did before, it should go until the end of the loading.
What am I forgotting?

 

Thank you.


Edited by verzasoft, 10 December 2015 - 12:52 AM.


#2 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13745 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 10 December 2015 - 03:06 PM

The question is: why it hangs simply due to renaming the file??? If the iso has been found and started as it did before, it should go until the end of the loading.
What am I forgotting?

You are forgetting to post the contents of your menu.lst and of your syslinux.cfg (there are several ways one can load a .iso and it has to be seen which one are you using), additionally a specific version/release of the .iso (and of grub4dos or of Syslinux) may need a different approach, so please post the specific info about the versions you are using.

 

Apart this, you are assuming that the booting of a .iso image consists only in loading it through either grub4dos or syslinux.

 

This - generally speaking - is correct, but it does not apply to *all* .iso's, it may depend both from the way you actually load/chainload them (see above) and from the actual specific .iso, some have a "fixed name" or need to be sent a "cheatcode", an additional parameter that specify the name of the .iso file such as for Parted Magic- but again it may depend on version - "iso_filename=".

 

See also:

http://reboot.pro/to...all-iso-images/

 

Some examples taken from: http://www.rmprepusb...ub4dos_examples

 

title Parted Magic /ISO/pmagic_2013_02_28.iso (booting the kernel)
map /ISO/pmagic_2013_02_28.iso (0xff)
map --hook
root (0xff)
kernel /pmagic/bzImage edd=off load_ramdisk=1 prompt_ramdisk=0 rw vga=normal sleep=10 loglevel=0 max_loop=256 vmalloc=384MiB keymap=us iso_filename=/ISO/pmagic_2013_02_28.iso
initrd /pmagic/initrd.img

title pmagic_2012_06_07.iso
#name must be in pmagic-yyyy_mm_dd.iso format and in root folder or will not find the .sqfs file
find --set-root /pmagic_2012_06_07.iso
map --heads=0 --sectors-per-track=0 /pmagic_2012_06_07.iso (0xff)
map --hook
root (0xff)
chainloader (0xff)

title Parted Magic 4.10 ISO
find --set-root /pmagic.iso
map /pmagic.iso (hd32)
map --hook
root (hd32)
kernel /pmagic/bzImage noapic load_ramdisk=1 prompt_ramdisk=0 rw vga=791 sleep=10 loglevel=0 keymap=uk iso_filename=/pmagic.iso
initrd /pmagic/initramfs
map --unmap=0:0xff

title Parted Magic 5.2 (direct memory mapping and booting the kernel)
find --set-root /pm52.iso
map --mem /pm52.iso (hd32)
map --hook
root (hd32)
kernel /pmagic/bzImage noapic load_ramdisk=1 prompt_ramdisk=0 rw vga=791 sleep=10 loglevel=0 keymap=us iso_filename=/pm52.iso
initrd /pmagic/initramfs
map --unmap=0:0xff

 

 

:duff:

Wonko



#3 verzasoft

verzasoft
  • Members
  • 4 posts
  •  
    Italy

Posted 10 December 2015 - 05:27 PM

Hello Wonko,

 

Stating that I have a very little linux knowledge, I am using syslinux and grub versions provided with xboot 1.0 beta14. The usb stick bootloader is syslinux.

 

This is text contained in G:\boot\syslinux\syslinux.cfg:

MENU title XBOOT DVD
INCLUDE /boot/syslinux/theme.cfg
TIMEOUT 100

### MENU START
LABEL -
MENU LABEL Parted Magic
LINUX /boot/syslinux/grub.exe
APPEND --config-file="ls /images/pmagici686.iso || find --set-root /images/pmagici686.iso;map --heads=0 --sectors-per-track=0 /images/pmagici686.iso (0xff) || map --heads=0 --sectors-per-track=0 --mem /images/pmagici686.iso (0xff);map --hook;chainloader (0xff)"
TEXT HELP
ENDTEXT
### MENU END

and this is text contained in G:\menu.lst

color magenta/white white/magenta black/white black/white 
timeout 10

### MENU START
title Parted Magic\n
ls /images/pmagici686.iso || find --set-root /images/pmagici686.iso
map --heads=0 --sectors-per-track=0 /images/pmagici686.iso (0xff) || map --heads=0 --sectors-per-track=0 --mem /images/pmagici686.iso (0xff)
map --hook
chainloader (0xff)
### MENU END
 
This works perfectly.
Then, I thought that renaming in both files the text "pmagici686.iso" in "pmagic.iso" and renaming the file in such way, it would work, but not.
Also a "reinstall bootloader (syslinux)" does not solve. It starts (i can select to start partedmagic in italian, it starts, but then it hangs after some operations seeking the .sqfs file.
 
I cannot figure out why. Do you?
 


#4 IAmTheTrueMeaningOfCovfefe

IAmTheTrueMeaningOfCovfefe

    Silver Member

  • Advanced user
  • 558 posts
  • Location:In hiding
  • Interests:An investigation is underway to determine whether Trump has any ties to America.
  •  
    United States

Posted 10 December 2015 - 06:35 PM

Why not just leave the filename and menu.lst/syslinux.cfg alone, since they worked before? It seems you're intentionally breaking something just so you can post here to complain. You created your own problem and know how to fix it. Post again when you have a real issue that you can't figure out.



#5 verzasoft

verzasoft
  • Members
  • 4 posts
  •  
    Italy

Posted 10 December 2015 - 07:12 PM

AnonVendetta,

 

the problem, obviously, is not simply "how to make this specific thing work". I am not yet so stupid to cause a problem, know how to solve and complain about that. I am not complaining against anyone. I don't want to know how to make this thing work without touching it: we already know how.

 

I am doing experiments to learn HOW grub/syslinux work and as I said in the topic title I am seeking information about this, and why (in this case) such a slight modification breaks the thing: since I see that ony that two files have a reference to the iso name I expected that changing the iso filename and the text in those two files would work, but it does not.

The second step, after understanding how the thing work, will be to manually copy ISOs and manually modify the files to have them listed in menus and working. Maybe in the future I will make my own tool.


Edited by verzasoft, 10 December 2015 - 07:14 PM.


#6 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13745 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 10 December 2015 - 07:41 PM

Ok, let me explain.
If that stick is (senselessly) booting to Syslinux, it's only business is to load grub.exe as a Linux kernel passing it some parameters.
The menu.lst is not used at all in that configuration.
However the parameters passed to grub.exe are the same as the contents of the menu.lst 
ls /images/pmagici686.iso || find --set-root /images/pmagici686.iso
map --heads=0 --sectors-per-track=0 /images/pmagici686.iso (0xff) || map --heads=0 --sectors-per-track=0 --mem /images/pmagici686.iso (0xff)
map --hook
chainloader (0xff)
The first line tries to look for the file "pmagici686.iso" inside the directory /images/ of "current root" and if it can't find it, tries to look for it in the same path but on other devices (normally when you boot from a USB stick, it becomes the root device, but there may be cases when this doesn't happen).
Second lines tries to map the .iso to a grub4dos virtual drive (CD-like) or, if this fails (typically because the .iso is not contiguous) it attempts to map the .iso to a virtual dirve but residing in memory.
Third line "hooks" the mapping, i.e. makes the mapping "static".
Fourth line chainloads the boot sector of the virtual drive.
Till now everything is fine and dandy, BUT chainloading the  bootsector means to have it call the *whatever* bootloader the .iso has (namely in this case it will be most probably be Isolinux), from this point on everything that was made before (with the exception of the mapping of the.iso to a virtual drive in BIOS) is "lost" as the Isolinux will load it's own .cfg which is INSIDE the .iso.
So what is really executed and passed to the kernel is the contents of the /boot/syslinux/syslinux.cfg or the /boot/isolinux/isolinux.cfg inside the .iso.
This has no "cheatcodes" and (evidently) the .iso is made to have a "default" name of "pmagici686.iso" and a "default" path of "/images/" OR XBOOT while building the stick corrects the .cfg adding these data.
 
If you think about it, you should gather the futility of the whole approach in this case, you boot to syslinux that loads syslinux.cfg to load grub4dos that loads menu.lst to load a bootsector that loads isolinux that loads syslinux.cfg that loads the kernel and initrd :frusty:.
 
Once you are in grub4dos, it makes more sense to directly chainload the kernel and initrd, giving it whatever parameters they need, try adding to the menu.lst an entry *like* (adapting it to your needs):

title Parted Magic /ISO/pmagic_2013_02_28.iso (booting the kernel)
map /ISO/pmagic_2013_02_28.iso (0xff)
map --hook
root (0xff)
kernel /pmagic/bzImage edd=off load_ramdisk=1 prompt_ramdisk=0 rw vga=normal sleep=10 loglevel=0 max_loop=256 vmalloc=384MiB keymap=us iso_filename=/ISO/pmagic_2013_02_28.iso
initrd /pmagic/initrd.img

 
This way you get directly to the kernel and initrd.
 
:duff:
Wonko
 
P.S.: as a side note, you won't ever learn anything about syslinux or grub4dos if you use a "wrapper" (such as XBOOT) which is nowadays way obsolete besides never having been particularly "smart" or flexible, you'll learn much more things reading the grub4dos or the syslinux subforums and/or perusing Steve6375's site for RMPREPUSB and/or Easy2boot (the latter being another "wrapper" but at the same time simpler and much more evolved than XBOOT and using a recent - of not the very last - version of grub4dos).
Also, you should study the (now getting a bit outdated, newer versions of grub4dos have many additional capabilities, but it remains a valid "base") diddy's guide:
http://diddy.boot-la...os/Grub4dos.htm

 
Finally Grub (which has been senselessly renamed "grub legacy") is NOT grub4dos, Grub 2 (which has now been senselessly renamed Grub) is NOT grub4dos, grub4dos is grub4dos and should be called grub4dos to avoid confusion with the other two.

#7 verzasoft

verzasoft
  • Members
  • 4 posts
  •  
    Italy

Posted 10 December 2015 - 08:21 PM

 

This has no "cheatcodes" and (evidently) the .iso is made to have a "default" name of "pmagici686.iso" and a "default" path of "/images/" OR XBOOT while building the stick corrects the .cfg adding these data.

 

I downloaded the iso as "pmagic_2013_05_01_i686.iso", then XBOOT renamed that way while copying it onto the usb key. 

If i look into the pmagic_2013_05_01_i686.iso on my pc i can see:

LABEL italian
MENU LABEL ^Italian
COM32 linux.c32
APPEND /pmagic/bzImage initrd=/pmagic/initrd.img edd=off load_ramdisk=1 prompt_ramdisk=0 rw vga=normal loglevel=9 max_loop=256 vmalloc=384MiB keymap=it it_IT

while if i look into pmagici686.iso onto the usb stick i see:

LABEL italian
MENU LABEL ^Italian
COM32 linux.c32
APPEND /pmagic/bzImage initrd=/pmagic/initrd.img edd=off load_ramdisk=1 prompt_ramdisk=0 rw vga=normal loglevel=9 max_loop=256 vmalloc=384MiB keymap=it it_IT iso_filename=pmagici686.iso

and that last setting was added by XBOOT. You were right!

 

(now i have only to understand why this is necessary and why the "inside" of the iso knows to be an iso but maybe this goes beyond my comprension  :heh: )

 

 

 

If you think about it, you should gather the futility of the whole approach in this case, you boot to syslinux that loads syslinux.cfg to load grub4dos that loads menu.lst to load a bootsector that loads isolinux that loads syslinux.cfg that loads the kernel and initrd  :frusty:.

 

absolutely.

 

Once you are in grub4dos, it makes more sense to directly chainload the kernel and initrd, giving it whatever parameters they need, try adding to the menu.lst an entry *like* (adapting it to your needs):

title Parted Magic /ISO/pmagic_2013_02_28.iso (booting the kernel)
map /ISO/pmagic_2013_02_28.iso (0xff)
map --hook
root (0xff)
kernel /pmagic/bzImage edd=off load_ramdisk=1 prompt_ramdisk=0 rw vga=normal sleep=10 loglevel=0 max_loop=256 vmalloc=384MiB keymap=us iso_filename=/ISO/pmagic_2013_02_28.iso
initrd /pmagic/initrd.img

 

Hmmm. If I add this to \menu.lst nothing changes, because this is never called. The usb stick starts with syslinux (\boot\syslinux\syslinux.cfg) that calls \boot\syslinux\grub.exe and passes parameters, but the menu of grub is never shown.

If it seems to you a good idea, I can try to make a xboot usb stick choosing grub bootloader, so that uses menu.lst and so one passage is jumped. Or, thinking opposite, I can make the iso start from syslinux without calling grub (is it possible?)

 

Further, If i understood well the code, this will make directly parted magic start, jumping the initial parted magic in which i can select language and other things. Am I right?



#8 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13745 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 10 December 2015 - 08:36 PM

You were right!

You mean you were doubting it? :w00t:

 

(now i have only to understand why this is necessary and why the "inside" of the iso knows to be an iso but maybe this goes beyond my comprension  :heh: )

Well this is part of your homework, but it's not difficult if you re-read the thread.


 

Hmmm. If I add this to \menu.lst nothing changes, because this is never called.The usb stick starts with syslinux (\boot\syslinux\syslinux.cfg) that calls \boot\syslinux\grub.exe and passes parameters, but the menu of grub is never shown.

Sure :) another part of your homework is how to "break" the current chain in such a manner that grub4dos grub.exe actually loads the menu.lst.

 

If it seems to you a good idea, I can try to make a xboot usb stick choosing grub bootloader, so that uses menu.lst and so one passage is jumped. Or, thinking opposite, I can make the iso start from syslinux without calling grub (is it possible?)

Both are possible ways out, though bypassing grub4dos will require the use of memdisk (part of syslinux) and that normally is part of a more advanced topic.


 

Further, If i understood well the code, this will make directly parted magic start, jumping the initial parted magic in which i can select language and other things. Am I right?

Yep :), correct, but nothing prevents you from rewriting the (relevant - I mean are you going to ever use the German or Nowegian entry?) entries in your "custom" menu.lst, I mean, you are trying to "customize" something, so do customize it to get exactly what you want (and nothing more) while you are at it.

:duff:
Wonko






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users