[Raspberry Pi Development] sendust7:
I wrote a shell script to multi-boot my RPi from a terminal. Script can be executed remotely via SSH or VNC.

Features:

Automatically detect all ext4 partitions of all storage devices attached to RPi (ext4 is the default partition type for hosting an RPi-compatible OS)

Reconstruct boot device names (root=/dev/*) from partition editor output. No changes are made to storage devices

Generate table of boot options and prompt user for option

Include option to shutdown

Reboot to selected rootfs, e.g. /dev/sda2 according to user-selected boot option

Script uses partition editor (parted) to identify the storage device paths. I did have to install parted on Raspbmc:

sudo apt-get install parted

Presently I have triple boot:

Raspbian #1 on SD (/dev/mmcblk0p2)

Raspbian #2 on USB HD (/dev/sda2)

Raspbmc on USB HD (/dev/sda4)

Partition Info:

PNY 16GB SD

root@raspberrypi:/boot# parted /dev/mmcblk0 print

Model: SD SD16G (sd/mmc)

Disk /dev/mmcblk0: 16.0GB

Sector size (logical/physical): 512B/512B

Partition Table: msdos

Number Start End Size Type File system Flags

1 4194kB 62.9MB 58.7MB primary fat16 lba

2 62.9MB 16.0GB 15.9GB primary ext4

Western Digital 160GB HD 7200 RPM

root@raspberrypi:/boot# parted /dev/sda print

Model: WDC WD1600BJKT-75F4T (scsi)

Disk /dev/sda: 160GB

Sector size (logical/physical): 512B/512B

Partition Table: msdos

Number Start End Size Type File system Flags

1 4194kB 62.9MB 58.7MB primary fat16 lba

2 77.6MB 21.5GB 21.5GB primary ext4

3 21.5GB 25.8GB 4295MB primary linux-swap(v1)

4 25.8GB 160GB 134GB primary ext4

And here's the boot script (/boot/rpiboot.sh):

#!/bin/sh

echo
echo "Reboot RPi to rootfs... "

cd /boot
ftxt="cmdline.txt"
fbak="cmdline.bak"
fnew="cmdline.new"

if [ -f $fnew ]
then
rm $fnew
fi

echo
rootfs=$(awk '{for (i=1; i<NF; i++) if (match($i,"root=")) {sub("root=", "", $i); print $i} }' $ftxt)
echo "Current rootfs: $rootfs"

#Reconstructing device names from partition editor output
parted /dev/mmcblk0 print > parted.txt
mmcname=$(awk '/\/dev\// {printf "%s", substr($2,1,length($2)-1) }' parted.txt)
awk -v mmcname=$mmcname '/ext4/ {printf "%sp%d\n", mmcname, $1 > "ext4.txt" }' parted.txt

parted /dev/sda print > parted.txt
mmcname=$(awk '/\/dev\// {printf "%s", substr($2,1,length($2)-1) }' parted.txt)
awk -v mmcname=$mmcname '/ext4/ {printf "%s%d\n", mmcname, $1 >> "ext4.txt" }' parted.txt

echo
echo "Boot options for rootfs:"
cat -n ext4.txt > ext4_enum.txt
more ext4_enum.txt

echo
printf "Enter boot option (press ENTER to shutdown or CNTL-z to exit):"
read -r ext4_index
if test -z "$ext4_index"
then
echo
echo "Shutting down in 3 seconds..."
sleep 3
shutdown -h now
exit 0
fi

#Determine rootfs corresponding to boot option
rootfs=$(awk -v ext4_index=$ext4_index '{if (match($1,ext4_index)) print $2}' ext4_enum.txt)

if test -z "$rootfs"
then
echo
echo "Invalid boot option or other error. Exiting..."
exit 1
fi

awk -v rootfs=$rootfs -v fnew=$fnew '{
for (i=1; i<NF; i++) if (match($i,"root=")) {$i = "root=" rootfs; print $0 > fnew} }' $ftxt

if [ -f $fnew ]
then
printf "Press ENTER to reboot to $rootfs, or CNTL-z to exit."
read -r text
mv $ftxt $fbak
mv $fnew $ftxt
fi

echo
echo "/boot/cmdline.txt:"
more $ftxt

echo "Rebooting to $rootfs in 3 seconds..."
sleep 3
reboot

exit 0

Launching rpiboot.sh as root, here are my own results of a boot switch from /dev/sda2 (Raspbian) to /dev/sda4 (Raspbmc):

pi@raspberrypi ~ $ sudo sh /boot/rpiboot.sh

Reboot RPi to rootfs...

Current rootfs: /dev/sda2

Boot options for rootfs:
1	/dev/mmcblk0p2
2	/dev/sda2
3	/dev/sda4

Enter boot option (press ENTER to shutdown or CNTL-z to exit):3
Press ENTER to reboot to /dev/sda4, or CNTL-z to exit.

/boot/cmdline.txt:
dwc_otg.lpm_enable=0 root=/dev/sda4 rootfstype=ext4 noatime quiet rootwait loglevel=1 sdhci-bcm2708.enable_l
lm=1 dwc_otg.microframe_schedule=1 dwc_otg.fiq_fix_enable=0 dwc_otg.fiq_split_enable=0 dwc_otg.trans_backoff
=3000
Rebooting to /dev/sda4 in 3 seconds...

Broadcast message from root@raspberrypi (pts/0) (Thu Oct 31 15:28:20 2013):
The system is going down for reboot NOW!
pi@raspberrypi ~ $ Connection to 10.0.0.16 closed by remote host.
Connection to 10.0.0.16 closed.
root@ubuntu:~#

And voila, Raspbmc comes up. I now SSH in from my Ubuntu laptop:

root@ubuntu:~# ssh pi@10.0.0.16
pi@10.0.0.16's password:

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
pi@raspbmc:~$

Of course VNC renders the elegant desktop experience, and setting up VNC is fairly straightforward:

http://learn.adafruit.com/adafruit-...control-with-vnc/running-vncserver-at-startup

However VNC does not work on Raspbmc since VNC relies on the X11 window system, while Raspbmc’s XBMC implementation is rendered in the framebuffer only. Thus VNC cannot be used as there is no X-session available for connection. See:

http://www.raspbmc.com/wiki/user/frequently-asked-questions/

But SSH works well.

Blessings. Enjoy! :D