LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-14-2009, 04:26 AM   #1
Al_
Member
 
Registered: Jun 2009
Location: Switzerland
Distribution: Ubuntu
Posts: 35

Rep: Reputation: 15
GRUB reading BIOS date / time for conditional boot preferences


Hi

Is it possible to instruct GRUB boot loader to read the system (BIOS) date and time and to behave differently depending on the date? E.g. (on a dual boot system), until 30-Sep-09 default is to boot Windows, after 1-Oct default is to boot Ubuntu?

The grub manual did not list such option, but possibly somebody knows a hack to accomplish it.

Thanks for any suggestions.

A_
 
Old 09-14-2009, 05:33 AM   #2
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 101Reputation: 101
Quote:
Originally Posted by Al_ View Post
Hi

Is it possible to instruct GRUB boot loader to read the system (BIOS) date and time and to behave differently depending on the date? E.g. (on a dual boot system), until 30-Sep-09 default is to boot Windows, after 1-Oct default is to boot Ubuntu?

The grub manual did not list such option, but possibly somebody knows a hack to accomplish it.

Thanks for any suggestions.

A_
In order for the grub boot loader to test the date and change its behavior on that basis, it would need a Linux resource like the Bash shell. But Bash can't be run until the Linux kernel is loaded and running. But the Linux kernel can't load until Grub has decided what to do.

So .. no. It can't be done. There's a reason Grub is severely limited in what it can do.
 
Old 09-14-2009, 06:30 AM   #3
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,052

Rep: Reputation: 379Reputation: 379Reputation: 379Reputation: 379
Bash has nothing to do with this. There are lots of programs that access the BIOS and do not need bash for anything, in both Linux and Windows.

It's just that grub simply has not this feature. The code to accomplish it shouldn't really be too much of a deal and anyway, GRUB is a multi stage boot loader, which means that the space constrains are really not a serious limitation for it.

So, to answer, no, grub can't do it as far as I know. Under linux, dmidecode can be used to get some info from the BIOS, taking a look into it might help to port such functionality into grub, once grub has the date it's a matter of writing the feature you want and a way to interface it from the configuration file. In any case, I'd start by asking on the grub mailing lists. Grub2 is under development so they might consider adding the feature, who knows... I know that it supports (or aims to support, don't tried it myself) scripting of some kind, so that's a very good start and there's a big chance that you can achieve what you need with very little extra work.

Last edited by i92guboj; 09-14-2009 at 06:32 AM.
 
Old 09-14-2009, 08:56 AM   #4
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
I also don't think Grub1 or legacy Grub can do this. As for Grub2 there is no full manual yet so I wouldn't know.

However Grub is just a small boot loader with very limited functionalities. It may be able to do a few exceptional freaks. Grub's task is just to boot up an operating system. It doesn't even carries a driver to read a USB device but it can read/boot it if the Bios presents it as the first booting device. Equally Grub can't read a NTFS partition but it can boot any or all of the Win2k, Xp, Vista and Win7. May be Grub is so superior to other boot loaders that make us think it is more than a boot loader.

Remember when legacy Grub is loaded there isn't a kernel available for it to use!
 
Old 09-14-2009, 09:26 AM   #5
fpmurphy
Member
 
Registered: Jan 2009
Location: /dev/ph
Distribution: Fedora, Ubuntu, Redhat, Centos
Posts: 296

Rep: Reputation: 62
The only way that I can see you being about to do what you want to do is to write a Powershell script which checks the date and when Sept 30th rolls around, mounts the Linux partition which has grub.conf on it, changes default to point to the Ubuntu stanza, and reboots the system.
 
Old 09-17-2009, 09:40 AM   #6
Al_
Member
 
Registered: Jun 2009
Location: Switzerland
Distribution: Ubuntu
Posts: 35

Original Poster
Rep: Reputation: 15
Thanks to all for explanations and suggestions. @fpmurphy: scripts would be an option fot the simplified example I presented. However, I like to decide on linux or windows :-( boot based on datre repeatedly; a logon script would still be possible, but the necessary re-boot makes this solution very unpleasant on the long run.

Regards, A_
 
Old 12-02-2010, 12:17 PM   #7
sokol_44
LQ Newbie
 
Registered: Dec 2010
Posts: 2

Rep: Reputation: 0
Actually there is possibility to instruct GRUB to read date and react according to it.
First you need to load datehook.mod, it will provide new environmental variables.
Second you can add LUA support with grub-extras to have better scripting language.
At the end of this page is example: http://grub.enbug.org/LUASupport
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BIOS Date and Time: Why does Ubuntu alter it? concoran Linux - Hardware 2 08-03-2009 03:31 AM
Setting system date and time affecting the clock and date on BIOS satimis Ubuntu 7 09-21-2007 08:02 AM
Start Date + Time Duration = End Date/Time calculator? ToBe Linux - General 3 09-26-2005 10:17 AM
Trying to dual-boot XP and RH9 with GRUB...GRUB stops right after BIOS EvilYoda Linux - Newbie 5 06-20-2003 03:38 PM


All times are GMT -5. The time now is 09:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration