Sandbird
Posts: 29
Joined: Tue Feb 10, 2015 12:45 pm

[HowTo]Control your multiboot remotely with SSH(no mon/keyb) [obsolete]

Sun Apr 05, 2015 9:19 pm

I wanted to use my old pi1 as a mini server for various things that require a GUI using raspbian and also be able to take it next door and watch something while i was running on my treadmill using raspbmc. Without a keyboard and mouse though to select which OS i want to boot into, i had to think of an easy to do that. So i did some research and figured out a shell script that i can use to manually switch the boot record to boot on Raspbian or Kodi using the console from my PC. This way i can just type : bootin kodi and the next time the pi boots it will boot on the Kodi partition, and bootin raspbian to go back to Raspbian.
Here is the script and instructions how to use it.
Just log in with root privileges or do : sudo nano /bin/bootin, then copy paste my script, press Ctrl+X to save and exit and then do : sudo chmod +x /bin/bootin to make it executable. You will have to do this in both partitions (raspbian and kodi).
Then type bootin to see the commands.
Instructions how to adapt it to your likings are in the script. Make sure you get your partition numbers right !!

Code: Select all

#!/bin/bash
# Provides: bootin
# Short-Description: Boot in whichever multiboot system you got
# Description: If you dont have a keybard and monitor hooked up on your pi and you want to 
# boot for example from Rasbmc to Rasbian or vice versa using SSH from a remote computer.
# First you need to get the partition numbers for all your systems and put them in the values bellow.
# Do these steps to get them:
# mkdir /tmp/noobs
# sudo mount  /dev/mmcblk0p3 /tmp/noobs
# cat /tmp/noobs/installed_os.json
# Example: 
#  "name" : "Raspbian",
#  "partitions" : [
#"/dev/mmcblk0p5",  <---- 5
#"/dev/mmcblk0p6"
#.....
#  "name" : "RaspBMC",
#  "partitions" : [
#"/dev/mmcblk0p7",  <----- 7
#"/dev/mmcblk0p8"
#...
# the mmcblk0p 5 is important.. Note the 1st number for every /dev pair...these are the numbers you want. These numbers represent your OS systems.
# So in the above example i want 5 and 7. If you have more than 2 systems, just copy paste a new section like the kodi) section i have bellow...
# and change the sed value \1'x' where is x is the value of the other partition. Also put the name you want for that OS, ex pico) and add that extra OS 
# at the bottom with the helper command: "Usage: bootin {kodi|raspbian}"
### END INIT INFO

case "$1" in
 kodi)
   mkdir /tmp/noobs
   sudo mount  /dev/mmcblk0p3 /tmp/noobs

   sudo sed -i 's,^\(default_partition_to_boot=\).*,\1'7',' /tmp/noobs/noobs.conf
   echo "Boot value changed to partition with RaspBMC"
   ;;
 raspbian)
   mkdir /tmp/noobs
   sudo mount  /dev/mmcblk0p3 /tmp/noobs

   sudo sed -i 's,^\(default_partition_to_boot=\).*,\1'5',' /tmp/noobs/noobs.conf
   echo "Boot value changed to partition with Raspbian"
   ;;
 *)
   echo "Usage: bootin {kodi|raspbian}"
   exit 1
   ;;
esac
exit 0

Return to “Advanced users”