I think you're looking for a boot-once solution. The examples below are shown with Grub v1; they should be easily translatable to a Grub v2-style configuration.
You need to add a basic boot config for your temporary partition. Your grub
config might look like the below. You'd activate a reboot into the temporary partition by executing grub-set-default 1
followed by reboot
.
On Debian with Grub v1, the boot config is /boot/grub/menu.lst
and the saved default boot is written to /boot/grub/default
. The grub-set-default
command changes the value in this file to the boot entry to be auto-booted on reboot. On reboot, grub
boots that entry, and the savedefault 0
resets /boot/grub/default
back to the regular boot entry for subsequent boots.
With this solution you don't need to edit the config and reset it every time you want to boot the temporary partition. However, you do need to have the entry in the grub config to begin with. You could possibly make it work with a chainloader if you don't know the kernel
and/or initrd
lines ahead of time. (I've never tried to use Grub to chainload Grub, so I don't know how well that would work.)
default saved
# boot entry 0
title Default boot
root hd(0,0)
kernel /boot/vmlinuz-2.6.xx UUID=xxxxxxx ro
savedefault
# boot entry 1
title Temp boot
root hd(0,1)
kernel /boot/vmlinuz UUID=yyyyyyyy ro
savedefault 0
# boot entry 2, chainloader version of boot entry 1
title Temp boot
root hd(0,1)
savedefault 0
makeactive
chainloader +1