Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
GRUB 2 has outsourced many functions into modules. This makes it possible to load only the required functions and thus smaller core images are possible. You can also use these modules to extend GRUB, e.g. to implement scheduling in GRUB. This makes it possible to start an particular operating system at a certain time.
You get a list of all available modules with
$ ls /boot/grub/i386-pc/
Configuring Scheduling in GRUB
For the scheduling in GRUB you need the module datehook. This allows access to the following variables in GRUB:
- DAY
- HOUR
- MINUTE
- SECOND
- MONTH
- WEEKDAY
- YEAR
All these values are based on the time and date set in the BIOS (usually the mainboard hardware clock). You have to keep that in mind when setting up the scheduling in GRUB.
With the following command you get a list with all menu items of the GRUBÂ menu:
$ grep -E â^menuentry|^submenuâ /boot/grub/grub.cfg | cut -d âââ -f2 | cut -d âââ -f2
The first entry has the number 0, the second the number 1 and so on.
Next open the file /boot/grub/grub.cfg and add the following lines relative to the beginning of the file:
insmod datehook
# Add an extra zero for minute 0â9, so MINUTE is always double-digitif[ $MINUTE -lt 10 ]; then PADDING="0"; else PADDING=""; fiTIME=$HOUR$PADDING$MINUTE
# Start Ubuntu by defaultset default=0
# Start Windows 10 from 5:00 p.m. to 11:00 p.m.if[ $TIME -ge 1700 -a $TIME -lt 2300 ]; then set default=3fi
At the beginning, an extra zero is inserted for minutes smaller than 10, so that the number of minutes is always two digits. Then we construct a new variable TIME, which has the current time in the format HHMM. These can now be used to implement scheduling in GRUB.
Ubuntu should be started by default, but in the evening Windows 10 takes precedence. It may be necessary to adjust the times, since the time zone UTC is often set up in the BIOS.
Conclusion
The changes above are only valid until the next time update-grub is executed. To keep the changes in GRUB permanently, you should create a template with this code in /etc/grub.d/.
We use this option to better manage our computers at school. Ubuntu is started by default during the day, but during the night we let Linbo boot so that the computers can be updated or provided with a new image, for example.
Originally published at openschoolsolutions.org on April 2, 2018. Sign up to our newsletter to get access to a FREE PDF with great open source apps for your classroom or follow @OpenSchoolZ on Twitter.
How To Set Up Scheduling In GRUB was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.