Jump to content











Photo
- - - - -

GeeXBox and Grub4dos

geexbox grub4dos multimedia isofile boot

  • Please log in to reply
13 replies to this topic

#1 COD11

COD11

    Member

  • Members
  • 63 posts
  •  
    Germany

Posted 11 February 2013 - 07:09 PM

GeeXBoX 3.0 is a versatile Media Center/Home Theatre Linux Distribution (Debian based) with an impressive graphical design. Multiple Processor architectures are supported : Intel/AMD 32/64bit, but also PowerPC and ARM devices. A nice gadget is CuBoX (a 5 x 5 x 5 cm boxed ARM PC with 3W power consumption and less than 100g weight !) which uses GeeXboX as operating system.

 

By reading this thread I suppose that you don't want to burn the downloadable ISO image files to an optical disc to test it, but to use Grub4dos (G4D) on a bootable flash storage medium for this purpose. The running ISO has its own installer for flash media. Creating an image file from such a bootable flash drive offers a method to boot it with G4D again... and to integrate it in a multiboot environment.

 

My intention is to give you as much information as possible, so that you are able to comprehend the results of my tests.

 

Downloads (Sources and Tools)

 GeeXboX 3.0 ISO image files:
 - 32bit Intel/AMD: http://download.geex...ox-3.0-i386.iso
 - 64bit Intel/AMD: http://download.geex...-3.0-x86_64.iso
 - MD5 hash for the downloaded ISO Image (same URL without *.iso) to check integrity

 

 Tools:
 - 7Zip (latest GUI version, used for extracting files from ISO): http://sourceforge.n...ad?source=files
 - RMPrepUSB (latest version, used to create a bootable flash medium and a casper ext2 file): http://www.rmprepusb...b-beta-versions
 - Wincontig (to get ISO files contiguous) contained in RMPrepUSB or http://wincontig.en....ic.com/download
 - PartedMagic (latest version, used for creating (and resizing) a flash storage medium image): http://exo.enarel.eu...or/partedmagic/
 - Notepad2 (tiny Windows TXT-(Script)-Editor with selectable Linux line endings): http://www.flos-free..._4.2.25_x86.zip

 

1. Testing GeeXBoX ISO image on a USB flash drive or flash card (non-persistent, i.e. all customization has gone on reboot)
 
 - Create a Grub4dos bootable USB flash medium ( on an  e m p t y  flash storage medium of at least 1GB) and test it !
   Use RMPrepUSB, follow steve6375's instructions ( creation and testing on  r e a l  machine ).
 - Write ( or copy and paste content from below to) a 'menu.lst' file with Notepad2 (select Linux line endings (0x0A)) and store it on the flash medium (root folder; n o t  folder 'root').
 - Copy the appropriate GeeXboX Iso file to the same location.
 - Test it on your machine.
   * Change boot sequence in BIOS.
   * BIOS does N O T support hot plugging, the flash medium must be connected  b e f o r e  you boot and enter BIOS.
   * Be sure that only  o n e  external storage medium ( the booting one ) is present otherwise you will be dropped to a shell, because main system 'rootfs' is not found automatically.

 

   menu.lst 1 (non-persistent, for testing; lines with leading number sign/# are comments and may be omitted)

#Initializing commands for Grub4dos menu
color yellow/light-blue
timeout 10
default 0

iftitle [find /geexbox-3.0-i386.iso]   GeeXBoX 3.0 (ISO direct / Grub4dos)\nPersistence is not possible, so it's just for having a look at it.
set ISO=/geexbox-3.0-i386.iso
# You may of course use (a) subfolder(s). Just adapt the above path accordingly.
# The following command uses cdbob's partnew suggestion (http://reboot.pro/topic/9916-grub4dos-isohybrided/page-2#entry88531),
# elaborated by steve6375 (http://www.rmprepusb.com/tutorials/72---easyboot---a-grubdos-multiboot-drive-that-is-easy-to-maintain)
ls (hd0,0)%ISO% > nul && partnew (hd0,3) 0x0 %ISO% > nul
# For faster boot ISO images should be contiguous (not fragmented), otherwise they get memory mapped with the following commandline
# which slows down booting tremendously. Use 'Wincontig' to defrag, if necessary.
map %ISO% (0xff) || map --mem %ISO% (0xff) || map --mem --heads=0 --sectors-per-track=0 %ISO% (0xff)
# GeeXBoX needs a hint where to find the main system file ('rootfs')
# The following lines assumes that only one external storage medium exists and that it is the booting one.
# Grub4DOS doesn't offer a way to detect the later Linux device name directly. Of course you know, that it's (hd0,3) here.
set root=/dev/sda4
# Up to 4 built-in HDDs are supposed. Add more lines if needed.
geometry (hd1) > nul && set root=/dev/sdb4
geometry (hd2) > nul && set root=/dev/sdc4
geometry (hd3) > nul && set root=/dev/sdd4
geometry (hd4) > nul && set root=/dev/sde4
#
#  ... just for the record
# geometry (hd25) && set root=/dev/sdz4
# geometry (hd26) > nul &&  set root=/dev/sdaa4
# geometry (hd27) > nul &&  set root=/dev/sdab4
# ...geometry (hd31) > nul &&  set root=/dev/sdaf4
# Maximum for Grub4Dos reached !
#(hd32) -> (hd255) use ISO 9660 sector size (2048B instead of 512B)!
# 
# If you drop to a shell, type "cat /proc/partitions | grep 139264" (no quotation marks)
# at the prompt and you will see the device name to fill into the kernel line: root=/dev/sd...
# On a non-US keyboard use keycodes via numpad for the special characters
# Activate [NumLK] : slash = [Alt] + 47, pipe = [Alt] + 124
# 139264 is the size of the "ISO-Partition" (= ISO file) in kiB ("blocks" of 1024 B)
# Size of the ISO file : 142,606,336 B = 139,264 kiB = 136 MiB
# Show selected device name :
echo -e \r\n ... using root=%root% \r\n && pause --wait=5 > nul  
map --hook > nul
root (0xff) > nul
kernel /vmlinuz root=%root% vga=789 quiet splash loglevel=3
# The following kernel line starts the persistent(!) installation of GeeXbox on another flash storage medium.
# Select target carefully, HDDs are also shown ! You may accidently loose all their content !
# Flip Comment sign (#) of kernel lines to activate the appropriate function or create a second menu item
# kernel /vmlinuz root=%root% vga=789 quiet loglevel=3 nocache systemd.unit=installator.target
initrd /initrd 

 

2. Persistent installation of GeeXBoX


There are two possibilities to get a persistent installation of GeeXbox :

A. Using its own installator (See commented-out kernel line in menu.lst 1)

Advantage:
You get a Syslinux booting ext4 (super)floppy with instantly running root filesystem 'rootfs' (squashfile needs not to be mounted externally),
resulting in a somewhat faster boot process. If the flash medium is big enough, you may even store media files within the ext4 filesystem.
For best compatibility I would prefer a second (FAT 32) partition on the same UFD for storage purposes which is seen by Windows.

But first you have to resize (shrink) the ext4 partition with Parted Magic (use 'Partition manager' = GParted or see Appendix below).

Disadvantage:
The whole space of the storage medium is used. The program uses about 500 MiB; the minimum space for settings, customization and downloaded add-ons should be another 500 MiB.
If you wish to thoroughly test and customize GeeXbox (with add-ons), I suggest that you use this installation for a longer period and then resize it with Parted Magic to a smaller or maybe bigger size.
See below, how to get it on a Grub4dos multi-booting flash drive (only one big file). Keep in mind, that FAT32 filesystem doesn't support files bigger than 4GB. But GeeXBoX is NTFS approved.

 

B. Using a 'casper-rw' ext2 file ( 4 files in total needed)

Advantage:
Its your decision how big this file needs to be ( Use RMPrepUSB to create one; GeeXBoX does  N O T  do it for you)

Disadvantage:
The casper file has to be on the same partition as file 'rootfs' (in any folder if path is given), because parameter 'root' is used for the location of both.
With the above used partnew method it's not achieveable ( ISO file fills whole partition; other locations are not scanned for the casper file)
 

menu.lst 2 (persistent with 'casper-rw' file)

# Create casper-rw ext2 file with RMPrepUSB (>= 500MB).
# Extract vmlinuz, initrd and rootfs from ISO with 7Zip GUI version.
# Create following structure on flash medium (paths for instructive purposes) and allocate the files accordingly.
# (You may of course put all 4 files in root folder instead and omit the paths.)
#
# (driveletter / root folder)
#  |
#  -- GEEXBOX
#     |  |
#     |  vmlinuz
#     |  initrd
#     |  rootfs
#     |
#     -- casper
#          |
#          casper-rw
#

#Initializing commands for Grub4dos menu
color yellow/light-blue
timeout 10
default 0

iftitle [find /GEEXBOX/initrd]   GEEXBOX 3.0 (Boot extracted files, persistent with casper file)
set gx=/GEEXBOX
set cp=%gx%/casper
uuid (hd0,0) | set uuid=
# UUID mounting solves the problem of changing device names on variably equipped systems.
# Unfortunately ISO9660 standard doesn't offer a UUID, so it's no solution for ISO images.
# (Volume) labels would be a way for both ISO and HDD/UFD partitions, and ISO label is easy to read with 'dd' from within Grub4Dos!
# e.g Trinity Rescue Kit uses labels that way.
set root=/dev/sdb1
# Default value if there is a fault in UUID detection; one built-in HDD (=/dev/sda1) should commonly fit ...
# ... or use 'geometry' method additionally (see menu.lst 1)
# The UUID format (length and grouping) depends on the filesystem. We extract UUID from the above commandline output.
# ext2/3/4
uuid %uuid:~-36,36% && set root=UUID=%uuid:~-36,36%
# fat32
uuid %uuid:~-9,9% && set root=UUID=%uuid:~-9,9%
# ntfs
uuid %uuid:~-16,16% && set root=UUID=%uuid:~-16,16%
# 'uuid UUID' with an accepted format switches root to the appropriate partition, which is always (hd0,0).
echo -e \r\n ... using root=%root% \r\n && pause --wait=5 > nul
# 'rootrw' is a synonym for 'rw' (read/write)
kernel %gx%/vmlinuz root=%root% rootfs=%gx%/rootfs rootrw vga=789 quiet splash loglevel=3 persistent=%cp%/casper-rw
initrd %gx%/initrd

3. Booting a GeeXboX created ext4 image file with Grub4dos (my favourite method!)

 - See Appendix on how to create an IMG file from the UFD content

 

menu.lst 3 (persistent within a read/write ext4 image file, booting with external Grub4dos)

#Initializing commands for Grub4dos menu
color yellow/light-blue
timeout 10
default 0

iftitle [find /_IMG/Linux/gxbox30.ext4]   GeeXBoX V3.0 (Boot ext4 ptn via ext. Grub4dos)
# Path names follow convention of steve6375's easy2boot system
# So you may easily add it in such a multiboot UFD
set MYFOLDER1=/_IMG
set IMG=%MYFOLDER1%/Linux/gxbox30.ext4
# Check for used 4th partition
parttype (hd0,3) | set check=
set check=%check:~-5,4%
# ext4 filesystem partition is not mountable with parttype 0x00 ! 
set pass=0
if %check%==0x83 set pass=1
if %check%==0x00 set pass=1
if %pass%==0 echo -e ERROR: Partion Table entry 4 already exists \n\r - so will not map %IMG% to ptn 4 \! && pause --wait=10 && configfile /menu.lst
#Hint: Exclamation mark must be "escaped" (with a backslash), otherwise all following commands in this line will be ignored !
ls (hd0,0)%IMG% > nul && partnew (hd0,3) 0x83 %IMG% > nul
set root=/dev/sdb1
Default value if there is a fault in UUID detection; one built-in HDD (=/dev/sda1) should commonly fit ...
# ... or use above 'geometry' method additionally (menu.lst 1)
uuid (hd0,3) | set uuid=
# ext4; we expect nothing else here.
uuid %uuid:~-36,36% && set root=UUID=%uuid:~-36,36%
echo -e \r\n ... using root=%root% \r\n && pause --wait=3 > nul  
root (hd0,3) > nul
kernel /boot/vmlinuz root=%root% rootfs=flat vga=789 quiet loglevel=3 rw
initrd /boot/initrd

menu.lst 4 (persistent, booting with internal Syslinux)

#Initializing commands for Grub4dos menu
color yellow/light-blue
timeout 10
default 0

iftitle [find /_IMG/Linux/gxbox30.ext4]   GeeXBoX V3.0 (Boot ext4 ptn via int. Syslinux)
# Path names follow convention of steve6375's easy2boot system
# So you may add it in such a multiboot UFD
set MYFOLDER1=/_IMG
set IMG=%MYFOLDER1%/Linux/gxbox30.ext4
# Check for used 4th partition
parttype (hd0,3) | set check=
set check=%check:~-5,4%
# ext4 filesystem partition is not mountable with parttype 0x00 ! 
set pass=0
if %check%==0x83 set pass=1
if %check%==0x00 set pass=1
if %pass%==0 echo -e ERROR: Partion Table entry 4 already exists \n\r - so will not map %IMG% to ptn 4 \! && pause --wait=5 && configfile /menu.lst
#Hint: Exclamation mark must be "escaped" (with a backslash), otherwise following command(s) in line will be ignored !
ls (hd0,0)%IMG% > nul && partnew (hd0,3) 0x83 %IMG% > nul  
root (hd0,3) > nul
# UUID is contained in syslinux.cfg !
chainloader (hd0,3)+1

 

A p p e n d i x

1. Menu item for Parted Magic Tool

iftitle [find /_ISO/Linux/pmagic_2013_01_29.iso]   Parted Magic 130129 (ISO direct)
set MYFOLDER=/_ISO
set ISO=%MYFOLDER%/Linux/pmagic_2013_01_29.iso
ls (hd0,0)/%ISO%  && partnew (hd0,3) 0x00 /%ISO% > nul
map /%ISO% (0xff)
map --hook
root (0xff) > nul
kernel /pmagic/bzImage iso_filename=/%ISO% edd=off load_ramdisk=1 prompt_ramdisk=0 rw vga=normal loglevel=9 max_loop=256 vmalloc=384MiB
initrd /pmagic/initrd.img

 

2. How to create an ext4 file from GeeXBoX installator version

You need a second (Grub4Dos) bootable UFD bigger than the one with the GeeXBox installator version or bigger than the resized partition.
You do  N O T  loose your customization.

Use PartedMagic for the image file creation

 - Boot Parted Magic and localize it (especially keyboard layout, if you use a non-US keyboard)
 - Look in filesystem manager which device names (/dev/sd..) are used by the source and target UFD
 - Open a Terminal window (click the monitor icon with the $ prompt)
 - I assume here: your built-in HDD is '/dev/sda1'; your source UFD is '/dev/sdb1' and the target is '/dev/sdc1'
 - Replace it with your possibly differing names.
 - Type at the prompt and confirm each line ('dd' needs some time; there is no progression indicator):

   mkdir -p /mnt/sdc1
   mount /dev/sdc1 /mnt/sdc1
   mkdir -p /mnt/sdc1/_IMG/Linux
   dd if=/dev/sdb1 of=/mnt/sdc1/_IMG/Linux/gxbox30.ext4 bs=100M
   umount /mnt/sdc1
   rmdir /mnt/sdc1


 - Copy the adequate menu.lst (3 or 4) file to the root of device sdc1 and test it.

 

3. How to resize a GeeXBox ext4 file
 - Boot Parted Magic and localize it (especially keyboard layout)
 - Find file gxbox30.ext4 (automatic drive mounting, when clicked in file manager) and write its path down.
 -Growing/shrinking gxbox30.ext4
   *Open a Terminal window
   *Type at the prompt  and confirm each line (omit comments/#) :

        # Your path to 'gxbox30.ext4' might vary !
      cd /media/sdc1/_IMG/Linux
        # Check the filesystem, you see the used space with the block (= 4096B ) ratio
      fsck.ext4 -p -v ./gxbox30.ext4
        # dd appends 0x00 Bytes to gxbox30.ext4
        # bs=blocksize (10MiB); count=loop counter (51 times) -> 510 MiB = 522.24 kiB
        # B E  S U R E  to write '>>', otherwise your file gets  O V E R W R I T T E N !
      dd if=/dev/zero bs=10M count=51 >> ./gxbox30.ext4
        # Growing the file system to fill the whole space ...
      resize2fs -p ./gxbox30.ext4
        # ... or shrinking the file system to a given size (490 MiB)
      resize2fs -p ./gxbox30.ext4 490M
        # Check filesystem again, it should still be 'clean'.
      fsck.ext4 -p -v ./gxbox30.ext4

   Perhaps you want to create a blank ext4 filesystem and copy all files from the source for safety reasons.
     - Type at the prompt  and confirm each line (omit comments/#) :

 

         # Your path to 'newfile.ext4'  and 'gxbox30.ext4' might vary !

         # path to 'newfile.ext4'

      cd /media/sdc1
         # Create a new zero file
       dd if=/dev/zero bs=10M count=125 > ./newfile.ext4
         # Format the created file ...
       echo y | mkfs.ext4 ./newfile.ext4
         # Check its integrity
       fsck.ext4 -p -v ./newfile.ext4
         # ... create mountpoints ...
       mkdir -p /mnt/source
       mkdir -p /mnt/target
         # ... and mount source and target.
       mount /media/sdb1/_IMG/Linux/gxbox30.ext4 /mnt/source
       mount ./newfile.ext4 /mnt/target

         # Copy all files from source to target with PartedMagic file manager ...
         # ... and unmount all at last.
       umount /mnt/source
       umount /mnt/target

         # Check target's integrity again.
       fsck.ext4 -p -v /media/sdc1/newfile.ext4
         # Copy newfile.ext4 to its final destination and rename it.

4. GeeXBox site : http://www.geexbox.org/
   For a documentation of the (kernel) commandline configuration parameters look at http://www.geexbox.o...d-boot-options/
   Parameter 'init(=)' which is not explained in the documentation points to the initializing binary file of 'rootfs'. The default value is '/sbin/init'.
   F1 (Help) within the ISO-/Syslinux menu indicates that there are localization parameters (lang=, keymap=), but the syntax of former GeeXBoX
   versions (e.g. lang=fr_BE, keymap=azerty) doesn't work any more. It would be useful to have an appropriate keymap if you drop to the shell or enter it from the GUI with
   [Ctrl] + [Alt] + [F1/F2] (back to GUI with [Alt] + [F4]). User name is 'root' and password, too.
   
   GeeXBox V3.0 has some issues with big (> 1TB) USB connected HDDs (incessantly mounting/unmounting). Internal big HDDs cause no problems.
   
5. If you want to analyze the initial script of 'initrd' (with commandline parameter processing) , unpack it (TAR/GZ style) with 7Zip
   and use Notepad2 to open 'init' (in / folder).
     
6. If you like to integrate GeeXBox into a collection of other bootable ISOs on one UFD, look for steve6375's Easy2Boot.
   http://docs.google.c...jkwNzMzODZkNGFh

 

 

Have fun with GeeXBox !
 


Edited by COD11, 11 February 2013 - 07:16 PM.


#2 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 11 February 2013 - 08:12 PM

Looks interesting!

 

You can get uuid like this

 

uuid (bd) && call set UUID=%^?%

 

note that you need the 'call' (or you can split the line into two and not use call)

 



#3 COD11

COD11

    Member

  • Members
  • 63 posts
  •  
    Germany

Posted 12 February 2013 - 02:30 PM

You can get uuid like this

 

uuid (bd) && call set UUID=%^?%

 

Doh , I reinvented the wheel although the source was so obvious !

 

http://www.rmprepusb...s-and-functions

 

Quotes from above URL :

 

Internal named variables

...

?_UUID  - set after uuid command

?  - result of last command ...

...

 

Variable Locations

...

 
# get the UUID of a boot volume (note: do NOT use && to join these lines!)
uuid (bd) > nul
set UUID=%?_UUID%
 
or you can use just one line:
uuid () && call set UUID=%^?%
 
Note that %^?% is used because %?% would be treated as a literal string and UUID would be set to %?% if ^? was not use!

 

So ^ is the "escape" sign ( like \ for the echo command) to differ the literal string "?"  from the variable '?' ( output of last command ).  But why is 'call' (ing a subroutine ?) needed ( a delay without a new output ?) ?


Edited by COD11, 12 February 2013 - 02:34 PM.


#4 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 12 February 2013 - 02:42 PM

It is to do with using && on a line - each command is executed independently not sequentially. If you use call then it is not (for some reason! - maybe uses current environment?)

 

IMPORTANT NOTE WHEN USING && or || : Changes may not take affect until the complete line has been executed - for instance:

 
set a=Hello && set b=%a%
set
will produce the result
a=Hello
the first time it is run. If you then run the same line again then it will produce
a=Hello
b=Hello
because the second time it is run a will already have been set by the first run.
 
You can use a single line if you use call and precede the variable with ^ - for example
set a=Hello && call set b=%^a% Steve!
set
will display
a=Hello
b=Hello Steve!

 

I must admit it threw me too! I think Windows shell  has a similar feature? try in cmd shell of Windows
set a=1 & set b=%a%

you get a=1 and b=%a%  (not b=1)

 
 


#5 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 12 February 2013 - 02:51 PM

P.S.   a ^ sign anywhere within a variable will mean 'literal'

 

e.g.

set a=%^bbb%  and set a=%bb^b%  are equivalent.  a will be the string  %bbb%

 

set a=%^%  will give a=%%



#6 COD11

COD11

    Member

  • Members
  • 63 posts
  •  
    Germany

Posted 12 February 2013 - 03:46 PM

I must admit it threw me too! I think Windows shell has a similar feature? try in cmd shell of Windows

set a=1 & set b=%a% you get a=1 and b=%a% (not b=1)

 

Eh, voilà !

 

test_set.cmd

@echo off
set a=Hello & call set b=%%a%%Steve
echo a=%a% 
echo b=%b%
set a=
set b=


#7 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 12 February 2013 - 03:48 PM

sehr gut!



#8 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 12 February 2013 - 06:30 PM

Just for the record:
 
 
 





@echo off
SETLOCAL
set _a=Hello & call set _b=%%_a%%Steve
set _a
set _b

set _a=
set _b=

SETLOCAL ENABLEDELAYEDEXPANSION
set _a=Hello & set _b=!_a!COD11
set _a
set _b

the call set is a sort of poorman's way DELAYEDEXPANSION.


@COD11
It wasn't that much "obvious" :w00t:, see:
http://reboot.pro/to...drive/?p=167163
and following posts until the solution was found (suggested by chenall himself :worship::
http://reboot.pro/to...drive/?p=167206

:cheers:
Wonko



#9 COD11

COD11

    Member

  • Members
  • 63 posts
  •  
    Germany

Posted 12 February 2013 - 08:39 PM

P.S. a ^ sign anywhere within a variable will mean 'literal'

e.g. set a=%^bbb% and set a=%bb^b% are equivalent. a will be the string %bbb% set a=%^% will give a=%%



So ^ is the "escape" sign ( like \ for the echo command) to differ the literal string "?" from the variable '?' ( output of last command ).

 

@steve6375

The above statements seem to be not mutually exclusive.

Example with Grub4dos :

echo -e Hello \Steve

Hello Steve

echo -e Hello \nice girl

Hello

ice girl

 

The behaviour depends on the defined variables for the ('echo') command .

 

@wonko

But why is 'call' (ing a subroutine ?) needed ( a delay without a new output ?) ?

 

Bingo !



#10 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 12 February 2013 - 09:04 PM

by variable I meant environment variable - e.g. %anything%, the ^ means don't translate this to the value of the variable.

 

When call interpreted, it launches a new shell and copies the current environment variables for use with the new shell.

Presumably when the shell exits, the new variable value is kept.



#11 COD11

COD11

    Member

  • Members
  • 63 posts
  •  
    Germany

Posted 13 February 2013 - 01:21 AM

by variable I meant environment variable - e.g. %anything%, the ^ means don't translate this to the value of the variable.

 

 

DOS example  (output in blue):

 

rem cmd / kernel  (or whatever uses this syntax the same way, even Grub4dos) ignores the 'escape' sign ^ in the variable name on creation (so it's a valid syntax) ...
set a^nything=something

 

rem ... compares 'a^nything' with the content of its environment variable repository (wherever it may be) and finds no match, because  on comparison the 'escape' sign ^ is not suppressed (a^nything != anything) ...

rem ... and finally removes ^ from the output string before writing it to the screen.

echo %a^nything%

%anything%

 

rem DOS finds a match, replaces %anything% by the string from its repository (stripping off the variable name and the equal sign) and writes 'something' to the screen.

echo %anything%

something


So I totally agree with you.



Now let's have a look at Grub4dos and its special feature:

set ^?=wonko

echo %^?%
%?%
echo %?%
wonko
 

 

# Logical concatenation: if first 'echo' gives a valid output (at least line feed if 'echo' stands alone) then proceed with the second 'echo' (and its special variable '^?'),
echo %?% && call echo %^?%
wonko
wonko

 

# The next line also works in DOS ( with  o n e  ampersand as concatenation of two commands, which are always processed both, one after the other from left to right).

# The special feature of Grub4dos works, but you don't notice it, since DOS would give the same output (with one ampersand, nota bene).

echo %^?% && call echo %^?%

%?%

%?%

 

So chenall ( I assume) decided to give this valid syntax (%^?%) its special task in  O N E  commandline of Grub4dos.

 


Edited by COD11, 13 February 2013 - 01:25 AM.


#12 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 13 February 2013 - 09:50 AM

Not quite sure I follow you. Basically in grub4dos shell, you need to use ^ to stop the shell interpreting %variable% as a value. These two lines are equivalent (except that && is conditional and & is not)

 

In Windows cmd shell:

set a=1 & echo %a% & echo %a% & call echo %a%

In grub4dos grldr shell

set a=1 & echo %a% & echo %a% & call echo %a^%

 

both produce the output

%a%

%a%

1

 

when run for the first time.

 
 
P.S. You need to be careful with ? (and I would avoid using it for testing)  as it is a special grub4dos internal variable which means 'the result of the last command'
 
e.g.
cat --locate=t --number=1 /menu.lst && set ?=1 && call echo %^?%
echo %?%
returns
21  (or wherever there is a 't' in your menu.lst file)
1
 
 
 


#13 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 13 February 2013 - 10:00 AM

So chenall ( I assume) decided to give this valid syntax (%^?%) its special task in  O N E  commandline of Grub4dos.

It seems to me like you made it more complex than needed.

Seemingly (as I see it) in grub4dos there is a rule like:

 

 

If a string representing a variable (i.e. any string that begins and ends with the percentage sign) contains the ^ character is to be treated literally as if the percentage signs were escaped.

 

Common batch language instead uses escaping the percentage signs, which is obtained by doubling them.

 

:cheers:

Wonko



#14 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 15 April 2013 - 02:47 PM

re. GeeBox

I am experimenting with it for Easy2Boot. I ended up with this menu which works well with persistence using this menu:

#Extract geexbox-3.0-i386.iso to \_ISO\MainMenu\Linux\geexbox  or \_ISO\Auto\Linux\geexbox  
#Make an ext2 filesytem at \_ISO\MainMenu\Linux\geexbox\geexbox-rw  or \_ISO\Auto\Linux\geexbox\geexbox-rw
#Only 4 files needed in geexbox folder: initrd rootfs vmlinuz geexbox-rw


iftitle [if exist %MFOLDER%/Linux/geexbox/initrd] GEEXBOX 3.0\n Boots extracted files\n Persistent with geexbox-rw ext2 file
set gx=%MFOLDER%/Linux/geexbox
uuid () > nul
set UUID=%?%
set root=live:UUID=%UUID% 
echo -e \r\n ... using root=%root% \r\n && pause --wait=1 > nul
kernel %gx%/vmlinuz root=%root% rootfs=%gx%/rootfs rootrw vga=789 quiet splash loglevel=3 persistent=%gx%/geexbox-rw
initrd %gx%/initrd
I used the x86 iso as the source which I downloaded using your link. However, I have found that this does not work if the USB drive is NTFS. I freshly formatted a USB flash drive as FAT32 and copied over the files and it works. But when I formatted the same USB drive as NTFS and copied over the same files, it does not boot ('cannot find valid root filesystem' error).
I have seen on forums that NTFS support seems to get dropped from different versions of GeeXbox on occasion...






Also tagged with one or more of these keywords: geexbox, grub4dos, multimedia, isofile boot

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users