code_exec
Posts: 263
Joined: Sun Sep 30, 2018 12:25 pm

How to "root" OSMC and install a desktop environment alongside Kodi

Sat Dec 08, 2018 2:05 pm

Recently, I've been playing around with OSMC on my Pi 3. I recently found out that it is based on Debian Stretch, so surely it must have the Bash shell, right? Well, yes it does, but OSMC is restricted to Kodi by default, preventing you from accessing the shell. With Bash, you can install a desktop environment and run commands. Since OSMC is essentially a barebones Debian install configured to boot into a modified and optimised Kodi, you can indeed access Bash from OSMC, but it requires a few hacks.

First of all, you'll need to change the password of the root user. Since you'll need to have access to the bash prompt to do this (which you don't currently have), you'll need to chroot into OSMC from another computer. Chances are you have a x64 PC, so you'll need to install QEMU User Emulation packages so that you can chroot into your OSMC filesystem. And no, I don't mean the QEMU where you emulate an OS for a different architecture by running it on an emulated CPU, but QEMU User Emulation packages that allow you to chroot into a filesystem where bash and other core packages are compiled for a different architecture. To install QEMU User Emulation packages, run:

Code: Select all

sudo apt install qemu-user-static binfmt-support 
Now, insert your microSD into your PC and chroot into your OSMC filesystem:

Code: Select all

sudo systemd-nspawn -D /media/your_username/root-rbp2
Change the root account password by running:

Code: Select all

passwd root
Enter a secure password for the root account. Then create your own personal user account and give it sudo privileges by running:

Code: Select all

adduser [username]
usermod -aG sudo [username]
Then exit the chroot with the 'exit' command. Remove the microSD from your PC and insert it into the Pi. Once OSMC has booted up, exit it through the Power menu and when it is exiting, press CTRL+ALT+F1 to get to the command prompt. Log in with the root user account and the password you chose for the account earlier.

From there, you can install a desktop environment and display manager. I've had issues with using LightDM on OSMC, so I recommend SLIM. Install it by running:

Code: Select all

apt update
apt install slim
Then install Xorg:

Code: Select all

apt install xorg
Now, you can install either LXDE, LXQT, XFCE, KDE Plasma, or MATE for a desktop environment.

Code: Select all

apt install lxde
apt install lxqt
apt install xfce4
apt install kde-plasma-desktop 
apt install mate-desktop-environment
You can add '--no-install-recommends' to the end of the end of one of those commands to only install the base of that desktop environment and not the recommended software.

Start SLIM with the following command:

Code: Select all

service slim start
Enter in the username of the personal account you created earlier, followed by the password you set. The desktop environment you installed should load.

To get to the desktop environment in the future, just boot OSMC, leave it for about a minute, exit Kodi by clicking Exit in the power menu, and then press CTRL+ALT+F1 when you see the OSMC splash screen. Login using the root username and password, and then start SLIM:

Code: Select all

service slim start
Then enter in the username of your personal account, followed by your password. The desktop should load.

You will still be able to access the OSMC user interface either by simply not exiting OSMC, or by selecting the 'Kodi' application from the menu of the desktop environment you're using.

Enjoy!
Last edited by code_exec on Sat Dec 08, 2018 9:18 pm, edited 1 time in total.
Ubuntu 18.04 LTS desktop images for the Raspberry Pi 3.

https://github.com/CodeExecution/Ubuntu-ARM64-RPi

User avatar
Paul Webster
Posts: 776
Joined: Sat Jul 30, 2011 4:49 am
Location: London, UK
Contact: Twitter

Re: How to root OSMC and install a desktop environment alongside Kodi

Sat Dec 08, 2018 8:09 pm

The OSMC team don't hide access to the underlying OS.
https://osmc.tv/wiki/general/accessing- ... mand-line/
or that it Debian based
https://osmc.tv/wiki/general/working-wi ... mand-line/

FYI ... here is the approach taken by someone else
https://discourse.osmc.tv/t/testing-x11 ... etch/16846

code_exec
Posts: 263
Joined: Sun Sep 30, 2018 12:25 pm

Re: How to root OSMC and install a desktop environment alongside Kodi

Sat Dec 08, 2018 9:33 pm

Paul Webster wrote:
Sat Dec 08, 2018 8:09 pm
The OSMC team don't hide access to the underlying OS.
https://osmc.tv/wiki/general/accessing- ... mand-line/
or that it Debian based
https://osmc.tv/wiki/general/working-wi ... mand-line/

FYI ... here is the approach taken by someone else
https://discourse.osmc.tv/t/testing-x11 ... etch/16846
However, they do not state that a desktop environment can be installed and that you can use OSMC as a desktop OS. All that needs to be done now is a way to run desktop apps on top of the Kodi interface instead of having to exit Kodi and load the desktop environment.
Ubuntu 18.04 LTS desktop images for the Raspberry Pi 3.

https://github.com/CodeExecution/Ubuntu-ARM64-RPi

Rascas
Posts: 507
Joined: Tue Mar 11, 2014 6:18 pm
Location: Porto, Portugal
Contact: Website

Re: How to root OSMC and install a desktop environment alongside Kodi

Sat Dec 08, 2018 9:48 pm

code_exec wrote:
Sat Dec 08, 2018 9:33 pm

However, they do not state that a desktop environment can be installed and that you can use OSMC as a desktop OS. All that needs to be done now is a way to run desktop apps on top of the Kodi interface instead of having to exit Kodi and load the desktop environment.
You can't do that, unless you compile Kodi against OpenGL and X11 support, like on a "normal" Linux desktop, instead of OpenGLES like it is done on the Raspberry Pi. But the performance will be much worse, you will loose hardware video decoding and other Pi optimizations. This is known/talked since the beginning of the RPi.

code_exec
Posts: 263
Joined: Sun Sep 30, 2018 12:25 pm

Re: How to root OSMC and install a desktop environment alongside Kodi

Sun Dec 09, 2018 6:02 am

Rascas wrote:
Sat Dec 08, 2018 9:48 pm
code_exec wrote:
Sat Dec 08, 2018 9:33 pm

However, they do not state that a desktop environment can be installed and that you can use OSMC as a desktop OS. All that needs to be done now is a way to run desktop apps on top of the Kodi interface instead of having to exit Kodi and load the desktop environment.
You can't do that, unless you compile Kodi against OpenGL and X11 support, like on a "normal" Linux desktop, instead of OpenGLES like it is done on the Raspberry Pi. But the performance will be much worse, you will loose hardware video decoding and other Pi optimizations. This is known/talked since the beginning of the RPi.
So you're saying that the version of Kodi used in OSMC uses OpenGLES for rendering so that it runs smoothly on the Pi, yet a desktop environment will perform poorly just because Kodi is optimised for the Pi?
Ubuntu 18.04 LTS desktop images for the Raspberry Pi 3.

https://github.com/CodeExecution/Ubuntu-ARM64-RPi

Rascas
Posts: 507
Joined: Tue Mar 11, 2014 6:18 pm
Location: Porto, Portugal
Contact: Website

Re: How to root OSMC and install a desktop environment alongside Kodi

Sun Dec 09, 2018 6:08 am

No, I said nothing like that...

Return to “Other”