Control Your Multiboot OS Remotely Using Only SSH (no Keyb/monitor Connected to the Pi)

Introduction: Control Your Multiboot OS Remotely Using Only SSH (no Keyb/monitor Connected to the Pi)

Description: If you have 2 (or more) operating systems on your pi's SSD card, you can remotely select which partition you want your pi to boot up into on the next reboot.

Instructions: 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 (putty).
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 on the next boot.

Here is the script and instructions on how to use it.

  1. Just log in with root privileges or do : sudo nano /bin/bootin,
  2. Copy paste my script, press Ctrl+X to save and exit.
  3. The do: sudo chmod +x /bin/bootin to make it executable.
  4. You will have to do this in both partitions (raspbian and kodi). One partition is in plain / path, and the other should be inside /media/root0/bin. So basically in the end you will have 2 bootin files...One in /bin and one in /media/root0/bin
  5. Then type bootin to see the commands.
  6. Instructions how to adapt the script with your partition numbers are in the script. Make sure you get your partition numbers right !!

Be the First to Share


    • Science Fair Challenge

      Science Fair Challenge
    • Chocolate Challenge

      Chocolate Challenge
    • Go Big Challenge

      Go Big Challenge



    2 years ago on Introduction

    hi, i followed all of the steps but when in LibreELEC (because that's what gets installed in NOOBS/PINN) the /bin/ folder is read-only so i cant get the bootin script in that folder. what to do?


    Reply 2 years ago

    You can also place it in /usr/local/bin
    That should be writable, and it's the same thing as well :)
    Edit: If there isnt any /usr/local/bin (cause i am not sure with LibreELEC), i've seen people use /storage/bin/ instead. Just make a /bin folder inside /storage and then add that path to the PATH value. Check out this thread here on how to do it:
    In the end (in both partitions) you should be able to just type 'bootin' from any folder and you should see the helpline pop up.


    Reply 2 years ago

    Hi, Thanks for your reply!
    When i cd to /usr/local then it says no such file or directory exists. (Usr does, no local)
    When I cd to /storage/bin there is my one bootin file.
    I followed the link in your comment and I think you’re referring to this comment:

    mkdir /storage/bin/
    cp /etc/profile /storage/.profile
    echo "export PATH=/storage/bin/:$PATH" >> /storage/.profile

    But you see I’m not really sure how and why because step one doesn’t work because there already is a bin folder.
    I have the bootin file in the /storage/bootin1 and /storage/bin folders now


    Reply 2 years ago

    What that thread explains, is how to make a bin folder (located in storage/) and add it to the PATH variable so that whatever is inside it can be executed from any folder/location inside that partition.
    I am not that familiar with LibreELEC to suggest how you append the PATH could just leave your bootin file in /storage/bin (bin name doesnt really matter....could be anything) and instead of blindly do 'bootin' command when you log in your Pi, you could just do: "/storage/bin/bootin raspbian' for example. (ofc you chmod +x the file file first to make it executable)
    Placing bootin in the bin folder is just a convenience thing so you dont have to actually write the full path of where the file is located, whenever you want to do the partition switch.