2

I have a dual boot setup: Manjaro KDE and Elementary OS.

Let's say I'd like to prevent Manjaro KDE from booting at a certain time (for example between 8:00 AM - 1:00 PM) so that only Elementary OS can be used in that particular time.

Since I think I can't act at GRUB level, Manjaro must certainly be able to boot but then some piece of software should prevent the user from logging in or making the distro unusable at that particular time.

Is this possible? What could I do?

RaiN
  • 23

2 Answers2

2

If you can put a solytion in place for this, you can bypass it. If its to frustrate attempts by someone less knowledgeable, you can simply add a line to crontab to reboot every minute between those hours. Possibly along the lines of editing /etc/crontab and adding

       * 8-12 * * * root shutdown -h now
davidgo
  • 73,366
0

What it seems today it can not seem tomorrow :-).

You should have been allowed to use date and time related commands on /boot/grub/grub.cfg editing /etc/grub.d even if they should rely on the internal PC clock, that has to be protected from users under both OSes and BIOS, as well as the possibility to boot from sources different from those two. Moreover remember that a failure of the motherboard battery may lead to a corrupt time shown by the internal clock.

Give it a look on this ubuntu thread for some more practical hints or to this post for a simple panorama. Hint relays on the datehook module and the config file (/boot/grub/grub.cfg)

insmod datehook
if [ "$HOUR" -ge "8" -a "$HOUR" -lt "13" ]; then set default="0" #Manjaro KDE
else set default="1"                                             #Elementary OS 
fi

By hands

If you cannot use the grub features above, you can apply a strategy

  1. to preempt the logging in the wrong time forcing a reboot with a specific selection as described in these other answers. You should put a time check in a script that has to be executed on boot. If the check is not passed you should force a reboot with a different grub option.
    Main steps are:

    • in the /etc/default/grub write/check GRUB_DEFAULT=saved
    • Use grub-set-default(if you want) for the willed boot option
    • sudo update-grub to save it

    In the script to be run

    • grub-reboot <entry> with that points to the other OS.
  2. kicking out the people still logged in when it will arrive a black time window, e.g. following the suggestion of davidgo adding a check in the crontab (but again I think it is better to write a little script that reboots with the willed grub option or if it works directly grub-reboot <entry>).

Have a nice reading and trying time...

Hastur
  • 19,483
  • 9
  • 55
  • 99