syslinux arguments in config file available?
#1
Posted 02 February 2012 - 05:21 PM
I'm trying to find a way to make syslinux load windows, after windows loads it'll write to an inifile it suceeded to load.
if it didn't load the inifile will show it didn't succeed to load and syslinux will default to load linux.
Someone can help me where to start? I'm very weak with linux and coding but I gave and example what I mean if it helps:
Data.ini:
-----------
[BOOT]
BOOTWINDOWS=0
BOOTLINUX=1
[SUCCESS]
BOOTWINDOWS=1
BOOTLINUX=1
Syslinux/isolinux/pxelinux/whatever arguments examples so you'll get the idea what i'm looking for:
------------------------------------------------------------------------------------------------------------------------------------
parse DATA.INI
if section(BOOT)key(BOOTWINDOWS)value(=1) thenif
___section(SUCCESS)key(BOOTWINDOWS)value(=1) write in syslinux.cfg default=boot windows
_____elseif section(SUCCESS)key(BOOTWINDOWS)value(=0) write in syslinux.cfg default=boot linux
___endif
elseif section(BOOT)key(BOOLINUX)value(=1) write in syslinux.cfg default=boot linux
Thanks!!
-Noam
#2
Posted 02 February 2012 - 10:29 PM
Go search around on the syslinux WIKI ( It's BACK http://www.syslinux....ex.php/SYSLINUX ).
There is a lot of good information there. You could (with a lot of custom programming) build a COM32 module for syslinux that reads an INI file to read values or even operate on them. But there is nothing like what you are proposing in the "pseudo" code above. Als, the logic is "bad", since you would have to reset the "sucess" flag before trying to boot windows, and also build in logic to cope with the fact that you are trying to pass "state" information in an INI file.
So, instead of telling us HOW you are trying to do something, tell us more about WHAT you want to have happen.
Scott
#3
Posted 03 February 2012 - 03:45 AM
Actually I just went to dig on the subject for a few hours and didn't find an answer but you are right I need to supply more information.
I'm trying to make an automatic failsafe loading of winpe os.
An OpenWRT router will have a tftp server on it for netbooting via BOOTP.
The images for tftp will be on a UFD connected to USB input of the router. It will contain a few images including winpe/livexp and hardware diagnostic tools.
I want pe environment to boot and if it won't boot the bootloader will automatically boot hardware diagnostic tools.
What I was planning to do is making a text ini file (so I'll can access it by win32, dos and linux).
My current problem is that I don't know how to implement a script in syslinux to change the default boot or write new value to the cfg file.
Like you say, windows will have to reset the succeed value, this is done by a vb script.
So by default the inifile will look like this:
[SECTION DEFAULT BOOT]
LOAD_BOOTPE=1 ;;syslinux will read the line and make pe load by default
LOAD_BOOTUBCD=0
LOAD_BOOTOPTION3=0
LOAD_BOOTOPTION4=0
[SECTION SUCCESS]
BOOTPE_SUCCESS=0
BOOTOPTION3_SUCCESS=0
BOOTOPTION4_SUCCESS=0
Before loading PE, syslinux will change the value of SUCCESS-> BOOTPE_SUCCESS to =NO.
When PE loads it'll change the same key to =YES.
IF PE didn't load: Next time syslinux starts and it reads the inifile and reads LOAD_BOOTPE=1 but [BOOTPE_SUCCESS)=NO,
It'll load UBCD.
All this should be also work booting by a USB (syslinux and isolinux without pxelinux).
I read that syslinux has an option to use a moudle for LUA language, I wonder how to use it and if it can be programmed to read text files by scripting (it includes the functions to do so), I must say that I don't know LUA language.
If there is a way to do what I want, I'll just need to find out if it's possible to upload and overwrite the pxelinux config file on the tftp server and it will also work with PXELINUX.
Another thing I'm not sure yet is where to place the ini file. I thought of placing it in a samba share together with the other images on the UFD so windows can access it but syslinux doesn't have support for samba so I'm not sure how it can read/write to it.
Any help will be kindly appreciated:)
-Noam
#4
Posted 03 February 2012 - 10:48 AM
Let's say that -simplifying - the only lines in the .ini are:
where values:LastGoodBoot=1
1 means PE (good boot)
0 or anything else means "I don't know" or "unspecified error" or "first run" or "failed PE boot"
and
where values:NextBoot=1
1 means PE
0 or anything else means "try UBCD"
- You start first time with LastGoodBoot=0 and NextBoot=1
- You boot (successfully) to PE (and it sets LastGoodBoot=1)
- Next boot you have LastGoodBoot=1, you reset it *somehow* to LastGoodBoot=0 in syslinux and you are then in situation #1 above
- You boot (fail to) to PE (and the value remains LastGoodBoot=0)
- Next boot you have LastGoodBoot=0 and NextBoot=1 and you are back to square #1
Can you try and explain to me your approach with a similar detail?
Wonko
#5
Posted 03 February 2012 - 12:59 PM
If the problem is that the contents of the USB drive may vary, would something like this do..
if exist (winpe file) then load it and boot it
if exist (some other file) then load it and boot it
if exist (ubcd file) then load it and boot it
if exist etc. etc. etc.
if so the latest grub4dos version will do this easily and you can call grub4dos from syslinux like this
default vesamenu.c32 LABEL grud4dos MENU LABEL Grub4dos KERNEL /grub.exe
And your menu.lst file would be
if exist /somepath/somefile default x && timeout 1 if exist /somepath/somefile default y && timeout 1 etc
x or y would be the number of the menu entry you wanted to run
Then add your grub4dos menu entries for each boot option (winpe, ubcd, etc.)
#6
Posted 03 February 2012 - 06:30 PM
You have to have some means of keeping track of the "state" of things. So you need a way to "reset" the system back to a known initial configuration and also keep track of what has been tried...
So, the bootloader has to drop a marker (in an ini file OR on disk) that says "try the first OS" (and I'll just say OS to mean any operating environment).
So, the logic would need to be
If Try Nth OS then Set Flag for N+1 Go try the Nth OS endifOr something like this...
If ERROR flag set then STOP endif If flag for Third one exists then set flag for ERROR //because if this fails we are done! go try Third OS endif If flag for Second one exists then Set Flag for Third go try Second OS endif Set flag for Second go try First OS
Then on any success of an OS, you reset all the flags... So, Steve's approach would be fine using grub4dos. BUT, my guess is that your using PXE, since you talked about a router having the images, etc. So, you would have to build in some sort of flags, and means to read them, etc.
As for LUA, you should be able to do something with it, but I haven't played with it either, so "HAVE FUN"...But it seems it should be usable in a PXE environment (from the 30 seconds I browsed the LUA modulae docs).
Scott
#7
Posted 03 February 2012 - 06:44 PM
Actually I want syslinux/isolinux to be able to auto decide which ever iso to run by default based on an ini file or (rewrite it's config file based on the ini).
Wonko - Almost, i'll make an example based on yours:
Ini file default:
NextBoot=1
where values:
1 means PE
2 means try UBCD
3,4,5,6,7,8.... means anything else (other ISOs)
LastGoodBoot=0
where values:
0 or anything else means "I don't know" or "first run"
1 means PE (Good Boot)
2 means "unspecified error" or "failed PE boot"
- You start first time with LastGoodBoot=0 and NextBoot=1
- Before Booting to PE - syslinux will change the ini file "somehow" to LastGoodBoot=2 (fail) and NextBoot=2 (UBCD)
- You boot (successfully) to PE (and PE sets LastGoodBoot=1)
- You boot (fail to) to PE (and the value remains LastGoodBoot=2)
- Next boot you have LastGoodBoot=2 and NextBoot=2 and UBCD will Load
#8
Posted 03 February 2012 - 06:54 PM
Actually I need this approach for Netbooting and also from booting by USB.
I'll try to play a bit with Lua hope I'll find something to work with:)
I already found an ini parser writed in Lua called IniLazy for the lazy coder haha:)
Another option may be using GRUB2 I understand it's scriptable and contain a lot of support for filesystems (like ext4, ntfs) and other options similar to syslinux.
It's still in develop so I may boot to syslinux and chainload to grub2.
I'll update how I progress.
-Noam
Edited by protools23, 03 February 2012 - 07:18 PM.
#9
Posted 03 February 2012 - 07:36 PM
Call me tough (mainly because I am ) but:
- You start first time with LastGoodBoot=1 and NextBoot=1
- Before Booting to PE - syslinux will change the ini file "somehow" to LastGoodBoot=2 (fail) and NextBoot=2 (UBCD)
- You boot (successfully) to PE (and PE sets LastGoodBoot=1) AND PE sets NextBoot=1 (this way you can loop to #1)
- You boot (fail to) to PE (and the value remains LastGoodBoot=2) AND the value remains NextBoot=2
- Next boot you have LastGoodBoot=2 and NextBoot=2 and UBCD will Load
Now consider to have ONLY Nextboot :
- You start first time with NextBoot=1
- Before Booting to PE - syslinux will change the ini file "somehow" to NextBoot=2 (UBCD)
- You boot (successfully) to PE and PE sets NextBoot=1 (this way you can loop to #2)
- You boot (fail to) to PE and the value remains NextBoot=2
- Next boot you have and NextBoot=2 and UBCD will Load
If you can do with a single variable, you don't need a .ini at all, the above is just a switch (on/off) or binary 0/1.
As an example, you can change the value of a single byte *somewhere* in the MBR, in the bootsector or in *any* sector or file.
This would bypass filesystem issues (NTFS support for syslinux is still experimental).
BTW, since a single byte can hold values from 0 to 255, you have 256 possible values to set.
And, JFYI, grub4dos has already the "default" file that can be used in this manner.
Wonko
#10
Posted 03 February 2012 - 10:31 PM
The reason for the more keys and variables is because the PE script will have more options to autoload other ISO's and boot without user intervention, For example, If the specific PC wasn't able to boot PE, I don't want it to boot PE at all, the hardware diagnosis will be a script to check hardware and report to a php on a webserver the log, than php will be used to autoprint a PDF file for the PC user. If PE environment didn't load I don't want the PC to continue the script (for example imaging the HD) using PE environment but only linux/dos console-like environments.
When I'll get the basics it will be easier to implement other options ofcourse.
But actually I can borrow your idea to combine the options binarically like:
NextBoot=4
LastBootSuccess=1
Binary is 4+1
== 0101
Do you have any Idea how to implement it?
And should it be safe to write the boot sector a lot of times It sounds a bit frightning solution, let's say I had a user PC connected and it's HD is almost dying, the bootsector rewrites may make some damage (most of the time HD with physical errors that -can- be read with software will have bad sectors in the start of the HD and usually less in the end.
What you mean in grub4dos is the fallback command?
Can it be used to rebooot with default after windows hangs with an error? how does the fallback mechanism works I can't understand it.
-Noam
Edited by protools23, 03 February 2012 - 10:40 PM.
#11
Posted 04 February 2012 - 12:05 AM
The default file in grub4dos is a file that contains a parameter.
Example menu.lst snippet (simplified):
color black/cyan yellow/cyan timeout 30 default /default title My nice PE entry 0 fallback 1 root (hd0,0) chainloader /bootmgr savedefault 1 title My nice UBCD entry 1 fallback 2 root (hd0,0) chainloader /IO.SYS savedefault 1 title My nice floppy entry 2 find --set-root /dosfloppy.ima map /dosfloppy.ima (fd0) map --hook root (fd0) chainloader +1 savedefault 1Explanation:
when this menu.lst is loaded, the default entry (that will be booted after timeout ) is READ from file /default (which in this example must be in same root as menu.lst)
Whatever is the default value READ from file /default, ALLentries in the example set it to 1.
Let's assume that you start with value 0 in /default.
When you boot, the PE entry will be booted after timeout (if selection is not changed via keyboard) AND it will set the value in /default to 1.
If the PE boots successfully, you simply change from the PE the value in /default from 1 to 0 and next time you will boot the PE again.
If the PE fails booting, the value will remain 1 and next time you will boot (after timeout) entry 1, i.e. the UBCD.
If the error is within grub4dos (and does not hang it completely ) the fallback provisions will attempt booting "next" entry, no matter what the settings in default are (of course if default is 0, if it fails then 1 will be attempted and if this also fails 2 will be attempted, if default is 1, if it fails 2 will be attempted and 0 will never be attempted)
Besides direct writing capabilities to *any* sector or file on *any* filesystem which is there since quite a bit of time, newish grub4dos versions have also sophisticated batch like language, so there are no real limits to the complexity you can add, though the KISS principle or Occam's Razor should be always applied to simplify things as much as possible. (review now previous post by steve6375, then have a quick look around in the grub4dos section, there are quite a few examples of using conditions, checking values in files or disk sectors and write and dd)
Wonko
#12
Posted 04 February 2012 - 08:23 AM
I wonder if syslinux has better compatibility with i368 PC's because I see for example than Hiren's uses syslinux as primary bootloader but asks user to chainload grub legacy if it won't load the os correctly.
Also I can see Grub4DOS wasn't updated a few years, I can make also something similar to use grub, syslinux and grub4dos so I'll have a way to boot the machine either way (the problem is that I'll use all these scripts in a KVM over IP remote control environment so I have to be able to access the PC somehow if the automating procedure will fail).
#13
Posted 04 February 2012 - 10:12 AM
On the contrary, grub4dos is updated almost daily these days by that very good fellow chenall. The latest versions can be found at http://code.google.c.../downloads/list. You may find my grub4dos page useful too at http://www.rmprepusb...orials/grub4dosAlso I can see Grub4DOS wasn't updated a few years...
#14
Posted 04 February 2012 - 10:23 AM
Maybe you mean that the grub/grub4dos developers are.You're a Genious!
I would not consider that a good source.I wonder if syslinux has better compatibility with i368 PC's because I see for example than Hiren's uses syslinux as primary bootloader but asks user to chainload grub legacy if it won't load the os correctly.
The dark side is still strong with that one.
WHERE?Also I can see Grub4DOS wasn't updated a few years,
Latest latest is in this moment is dated February 1st 2012..... then have a quick look around in the grub4dos section ....
http://reboot.pro/forum/66/
http://reboot.pro/14/
http://reboot.pro/14/page__st__30
http://code.google.c.../downloads/list
If you are interested, start by reading the guide:
http://reboot.pro/5187/
http://diddy.boot-la...os/Grub4dos.htm
then assume that besides the basic functions you have in the guide there are tens of new ones in newer versions of the tool (actually it is like that, so your assumption would be right ) and start learning about the latter ones browsing the forum...
There is no actual law that prohibits you from using multiple tools, they are mostly chainloadable from one to the other, you could well use grub4dos as the simple manager for theI can make also something similar to use grub, syslinux and grub4dos so I'll have a way to boot the machine either way (the problem is that I'll use all these scripts in a KVM over IP remote control environment so I have to be able to access the PC somehow if the automating procedure will fail).
Wonko
#15
Posted 04 February 2012 - 06:12 PM
I like to donate for projects that help my work but when I decide to do my own projects and make my weekends free for it, people like you saves me from spending precious time.
It really makes me want to be more shareful in the internet community and also in real life ofcourse.
Soon ill open a new subject in the grub4dos forum I guess:)
By the way, from your experience, which bootloader is the most compatiable with all kinds of pc hardware (old and new)?
if anyone is intetested chatting my facebook: pnl.prod at gmail.com
-Noam
#16
Posted 04 February 2012 - 09:51 PM
Be very careful about wording .By the way, from your experience, which bootloader is the most compatiable with all kinds of pc hardware (old and new)?
grub4dos (and syslinux etc.) are generically bootmanagers and bootloaders ONLY for Linux and for some flavours of DOS (still remembering that DOS normally uses NOT a bootloader as IO.SYS - MS-DOS and kernel.sys - FreeDOS are both system files and bootloaders).
On NT systems the bootloader is actually NTLDR or BOOTMGR (and these also double as - very limited - bootmanagers).
grub4dos is more "flexible" in the sense that it can be loaded from *everywhere*, like MBR, PBR, NTLDR, BOOTMGR and DOS (besides from Linux as grub.exe is also a Linux kernel).
Syslinux is a Linux kernel and normally it is booted by it's own installed bootsector/PBR.
For obvious reasons (numbers of machines on which it has been installed and practically every producer has been "forced" to test his hardware against), the most compatible "booting chains" MBR + PBR + bootloader are -strangely enough - MS owns ones.
i.e. it is very rare that this:
2k/XP MBR->2K/XP PBR->NTLDR->BOOT.INI
or this:
Vista :ph34r:/7 MBR->Vista :ph34r:/7 PBR -> BOOTMGR -> \boot\BCD
actually fail, whilst we have quite a few reports - and also some hints that this may be intentional - of BIOSes that don't "like" the grub4dos grldr.mbr.
Moreover, if you install grub4dos to the MBR it actually uses a few of the hidden sectors, something that is not entirely standard and may create a conflict with a few very old programs (or with a handful or modern IMHO badly programmed ones).
In other words, YMMV, and when you choose a "booting chain" several factors may come into play, so it's hard to give advice.
If one has to boot at least one of the NT OSes, I would normally suggest the use the correspondent bootloader/bootmanager (NTLDR or BOTMGR and the matching MBR and PBR) and grub4dos as secondary bootmanager.
On Linux only systems I am more oriented towards using the Syslinux "generic" MBR and corresponding PBR as primary bootmanager and if needed grub4dos as secondary bootmanager.
Wonko
#17
Posted 05 February 2012 - 04:06 AM
So actually as based of what you say which sounds reasonable to me, best practice will be- start by booting NTLDR and than chainload to grub4dos (GRLDR?) for the best compability?
#18
Posted 05 February 2012 - 08:52 AM
Yes, at least initially. (this has also the advantage that you don't do any modification to a 2K/XP system if not adding a few files and a line in boot.ini, so that it is very easy to "go back").So actually as based of what you say which sounds reasonable to me, best practice will be- start by booting NTLDR and than chainload to grub4dos (GRLDR?) for the best compability?
Wonko
#19
Posted 06 February 2012 - 11:45 PM
I think this is going to be the hardest part of all, since how do you detect if an error happened? the machine may just "hang", and unless you are there sitting at the machine, and can reset it, you may never get back to a boot loader. On the other hand, if you are sitting there at the console, you could just use a menu to select which environment to "boot".if there was just a way to implement it (like exiting from windows boot process back to syslinux when an error occurs it would be very easy)
Best of luck!
Scott
#20
Posted 08 February 2012 - 03:46 AM
i got this idea from a priduct that does that but i can't find it again :s
there are also pdu units which power cycle servers by an internal webserver but it won't be any use to.a normal desktop configured to be always off after recovering from a power surge because it can just turn it off.
i intentionally didnt think about connecting the relay to short the motherboard's power pins because i want it to be very easy to connect new desktopds
#21
Posted 08 February 2012 - 07:42 AM
#22
Posted 09 February 2012 - 01:25 AM
Actually I find a simpler product but can't find it again, it's a pad that you put around the pc and you can remotely mechanically switch the power on button, made compatible for many PCs.
30$ donating Grub4Dos project if someone will find it on the net:) If I remember correct, It is meant for people that can't press the button (accessibility item).
-Noam
#23
Posted 09 February 2012 - 11:08 AM
#24
Posted 09 February 2012 - 01:11 PM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users