Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save maatthc/792471812150010c935aedd34c93aedf to your computer and use it in GitHub Desktop.
Save maatthc/792471812150010c935aedd34c93aedf to your computer and use it in GitHub Desktop.
LG WebOStv - Play games on RetroArch from USB drive
#!/bin/bash
# === For rooted LG TVs with WebOsBrew installed only ===
#
# On LG WebOStv, RetroArch only have access to a few jailed folders so to run games on a usb drive,
# we need to 'merge' the USB mounting point with one of those jailed folders using OverlayFS.
# The scripts on folder '/var/lib/webosbrew/init.d/' will run after every tv boot.
# Remove the $STARTUP_FOLDER/$SCRIPT_TO_RUN_AFTER_BOOT and reboot to revert the change.
#
# Tested on 7.3.0-03.30.72
#
# Steps:
# - Copy this script to a pen drive and insert it to the TV
# - Check if the folder '/tmp/usb/sda/sda1/' exists and have the content of your pen drive.
# - Run the script
#
# The folder structure might be different depending of your TV version
set -euo pipefail
JAILED_FOLDER=/var/palm/jail/com.retroarch/media/internal
USB_MOUTING_POINT1=/tmp/usb/sda/sda1/
USB_MOUTING_POINT2=/tmp/usb/sdb/sdb1/
USB_MOUTING_POINT3=/tmp/usb/sdc/sdc1/
SCRIPT_TO_RUN_AFTER_BOOT=add_usb_drive_to_retroarch_media_folder
STARTUP_FOLDER=/var/lib/webosbrew/init.d
echo -e "#!/bin/bash \nmount -t overlay -olowerdir=${JAILED_FOLDER}:${USB_MOUTING_POINT1},nofail overlay ${JAILED_FOLDER}" > $STARTUP_FOLDER/$SCRIPT_TO_RUN_AFTER_BOOT
echo -e "\nmount -t overlay -olowerdir=${JAILED_FOLDER}:${USB_MOUTING_POINT2},nofail overlay ${JAILED_FOLDER}" > $STARTUP_FOLDER/$SCRIPT_TO_RUN_AFTER_BOOT
echo -e "\nmount -t overlay -olowerdir=${JAILED_FOLDER}:${USB_MOUTING_POINT3},nofail overlay ${JAILED_FOLDER}" > $STARTUP_FOLDER/$SCRIPT_TO_RUN_AFTER_BOOT
chmod +x $STARTUP_FOLDER/$SCRIPT_TO_RUN_AFTER_BOOT
echo "Script ${STARTUP_FOLDER}/${SCRIPT_TO_RUN_AFTER_BOOT} created."
echo "Press any key to reboot and activate changes or CRTL+C to quit."
read -n 1
reboot
@maatthc
Copy link
Author

maatthc commented Jan 16, 2025

Hi @shienok ,
Perhaps your TV is mounting the usb drive in another location, like @Nalle65 described above.
Also, try another ROM - mine are all .zip files (no idea that is inside) or .smc ..

@shienok
Copy link

shienok commented Jan 16, 2025

Hi @shienok , Perhaps your TV is mounting the usb drive in another location, like @Nalle65 described above. Also, try another ROM - mine are all .zip files (no idea that is inside) or .smc ..

Thanx for reply, pls can you write full Nalle65's code here so i can replace your original code with Nalle65's version?
I am not a programmer) i realy dont understand where to put his text code.
Thanx!

@maatthc
Copy link
Author

maatthc commented Jan 17, 2025

Hi @shienok ,
Updated.. try and let me know if it works..

@tricky67
Copy link

On my rooted LG TV, com.retroarch is actually com.retroarch.webos. So needed this in the script
JAILED_FOLDER=/var/palm/jail/com.retroarch.webos/media/internal
Also needed to comment out the sdb and sdc lines to make it use mu USB on sda

@maatthc
Copy link
Author

maatthc commented Feb 27, 2025

Hi @tricky67 , thanks!
I might add a test for that in the script.
What version of WeOs is your tv at?

@2gammer21
Copy link

so i rooted my lg tv, firgured out a path to ftp into the tv, i can ftp into my 2tb drive, but kodi and retro arch cant see my flash drive, and when i terminal in web os manager its un seeable, but the native apps can still use my drive

@HenryKun55
Copy link

Alguém conseguiria fazer um vídeo de como eu consigo rodar esse script sem ter feito root na tv ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment