]> git.donarmstrong.com Git - don.git/blob - posts/grub2_halt_and_set_default.mdwn
fix ethnic region code segment
[don.git] / posts / grub2_halt_and_set_default.mdwn
1 [[!meta title="Changing Grub2's default boot entry and halting"]] 
2
3 I have a mythtv box which (when working) records television shows for
4 me. As I'm not interested in the vast majority of shows shown on US
5 television, it spends most of it's time off, waiting for a show that I
6 want to record. This requires using `nvram-wakeup`, and one of the
7 oddities of my machine's bios is that it wants to be rebooted after
8 setting the nvram.
9 [This is likely due to Debian writing to the RTC after the nvram being updated, but not setting the RTC seems stupid.]
10 After the reboot, the machine should halt, and grub should be
11 configured to start the machine normally once the bios starts.
12
13 As grub2 now supports named default entries, this is fairly
14 straightforward. We create a menu entry like the following in
15 `/etc/grub.d/40_custom`:
16
17      menuentry 'halt' {
18              set saved_entry=0;
19              save_env saved_entry;
20              load_env;
21              halt;
22      }
23
24 make sure that `GRUB_DEFAULT="saved"` in `/etc/default/grub`; and set MythShutdownNvramRestartCmd to `/usr/sbin/grub-set-default halt`:
25
26      mysql mythdb -e "UPDATE settings SET data='/usr/sbin/grub-set-default halt' WHERE value='MythShutdownNvramRestartCmd'";
27
28 and viola, the machine now behaves properly with grub2.
29
30 [[!tag debian mythtv tech]]
31