I got a bit tired of constantly swapping SD cards in order to run either RuneAudio and OpenElec. Googling around I only came across solutions like Berryboot and similar which support OpenElec but fail to support RuneAudio. However the solution is simpler than I have ever thought!
I have been able to create a single SD card containing both RuneAudio and OpenElec using RPi2 based on existing installations of both systems. To do this I use one SD card (8 GB minimum) and create three partitions using gparted:
part1: 256 MB FAT16 (flags: boot, lba)
part2: appr. 3.5 GB ext4
part3: appr. 3.5 GB ext4
In this example I will be using an USB SD card reader which propagates itself as /dev/sdb on my system when connected (Note: could be /dev/sdc or /dev/sdd if you have more than one physical disk in your system! Use sudo fdisk -l to check). I also assume you started the terminal logged in into your own home directory. Do not change (cd) directories while in the process below. Also do not type in the "$" and "#" in the command lines.
1. Log in as root
- Code: Select all
$ sudo su
2. Create 4 directories for mounting the SD card partitions and 4 directories to retain the copied contents of these partitions
- Code: Select all
# mkdir oeboot runeboot oeroot runeroot
# mkdir oebootnew runebootnew oerootnew runerootnew
3. Insert the OpenElec SD card in the USB SD card reader and place it in one of your USB ports
4. Mount both partitions
- Code: Select all
# mount /dev/sdb1 oeboot
# mount /dev/sdb2 oeroot
5. Copy the contents of the OpenElec SD card partitions to your computer (dont forget the "." after the "/" !)
- Code: Select all
# cp -a oeboot/. oebootnew/
# cp -a oeroot/. oerootnew/
6. Unmount the OpenElec SD card
- Code: Select all
# umount oeroot oeboot
7. Remove the USB SD card reader, replace the OpenElec SD card with the RuneAudio SD card and put it back in the USB port of your computer
8. Mount both partitions
- Code: Select all
# mount /dev/sdb1 runeboot
# mount /dev/sdb2 runeroot
9. Copy the contents of the RuneAudio SD card partitions to your computer
- Code: Select all
# cp -a runeboot/. runebootnew/
# cp -a runeroot/. runerootnew/
10. Unmount the RuneAudio SD card
- Code: Select all
# umount runeboot runeroot
11. Remove the USB SD card reader, replace the RuneAudio SD card with the newly partitioned empty SD card and put it back in the USB port of your computer
12. Create 2 directories in the oeboot directory
- Code: Select all
# mkdir oebootnew/openelec oebootnew/runeaudio
13. Copy the contents of the runebootnew directory to the newly created runeaudio directory
- Code: Select all
# cp -a runebootnew/. oebootnew/runeaudio/
14. Edit the contents of the RuneAudio cmdline.txt file with the editor of your choice (nano or gedit)
- Code: Select all
# nano oebootnew/runeaudio/cmdline.txt
and replace root=/dev/mmcblk0p2 with root=/dev/mmcblk0p3 and leave the rest of the file as it is
15. Save the file
16. Mount the new SD card
- Code: Select all
# mount /dev/sdb1 oeboot
# mount /dev/sdb2 oeroot
# mount /dev/sdb3 runeroot
17. Copy the contents of three directories back to the SD card
- Code: Select all
# cp -a oebootnew/. oeboot/
# cp -a oerootnew/. oeroot/
# cp -a runerootnew/. runeroot/
18. Umount the new SD card
- Code: Select all
# umount oeboot oeroot runeroot
Now the new SD card is ready to be placed in the Raspberry Pi's SD slot. Put it there and reconnect power. If all is well the RPi should start in OpenElec's kodi. Please check if kodi works as it should.
Now we have to create two scripts to be able to switch between OpenElec and RuneAudio. In order to switch you should use SSH to log in into either system.
19. Log into OpenElec using SSH (e.g. ssh root@openelec.local or ssh root@<ip address of OpenElec system>)
20. Your current directory should be .storage as seen in the prompt
21. Create a script called "rune" using nano
- Code: Select all
# nano rune
22. Insert the following code (make sure to scroll down completely as the code window might not show all)
- Code: Select all
#!/bin/sh
mount -o remount,rw /flash #OpenElec mount its boot partition read-only
#so needs to be remounted
cd /flash
find . -path './*' -prune -type f -exec mv -f {} openelec \;
mv overlays openelec/
sync
mv runeaudio/* /flash/
sync
reboot
23. Save the script with Ctrl-X and make it executable
- Code: Select all
# chmod +x rune
Some explanation: the "find..." command moves all files except directories (to prevent the runeaudio directory to be moved as well), just in case I move overlays also as there might be different overlay versions...?. I also use "sync" a lot to prevent file corruption (maybe I could skip the first sync, paranoia?). I use move instead of copy to prevent SD card wear out
24. Run the "rune" script
- Code: Select all
# ./rune
The RPi should boot up with RuneAudio this time. Please check if everything works as it should.
Now we need to create the script to be able to switch back to OpenElec.
25. Log into RuneAudio using SSH (e.g. ssh root@runeaudio.local or ssh root@<ip address of RuneAudio system>)
26. Your current directory should be root as seen in the prompt
27. Create a script called "openelec" using nano. Insert the following code (make sure to scroll down completely as the code window might not show all)
- Code: Select all
#!/bin/sh
cd /boot
find . -path './*' -prune -type f -exec mv -f {} runeaudio \;
mv overlays runeaudio/
sync
mv openelec/* /boot/
sync
mpc stop
umount -f /mnt/MPD/NAS/Music #this is just an example, see below
reboot
28. Save the script with Ctrl-X and make it executable
- Code: Select all
# chmod +x openelec
To prevent "stop jobs" during reboot which take appr. 1 minute and 30 seconds I used the "umount" command in this script. This command may be omitted or changed to unmount any music directory configured in the Sources page of the RuneAudio web interface
29. Test the script by running it
- Code: Select all
# ./openelec
The Raspberry Pi should now reboot into OpenElec again.
Run ./rune to go back to RuneAudio etc. etc. etc.
I am not a noob regarding Linux but I am not an absolute expert as well. If there are any Linux experts among you please feel free to comment and make suggestions, additions or any other improvements.
Happy switching!
Greetz,
Hans.