Skip to content

Instantly share code, notes, and snippets.

@maatthc
Last active November 16, 2025 15:05
Show Gist options
  • Select an option

  • Save maatthc/792471812150010c935aedd34c93aedf to your computer and use it in GitHub Desktop.

Select an option

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
@shienok
Copy link

shienok commented Jan 15, 2024

Are the roms zipped? It must be uncompressed to retroarch to find it.
no, all roms are unzipped of course

@maatthc
Copy link
Author

maatthc commented Jan 16, 2024

On RetroArch, if you go to "Load content" and select "/media/internal", what do you see?

@maatthc
Copy link
Author

maatthc commented Jan 16, 2024

Also, please send the output of following command with the usb drive attached:

ls -la /var/palm/jail/com.retroarch/media/internal/

And

cat /var/lib/webosbrew/init.d/add_usb_drive_to_retroarch_media_folder

And

ls -la /var/lib/webosbrew/init.d/add_usb_drive_to_retroarch_media_folder

@shienok
Copy link

shienok commented Jan 18, 2024

1
2
screen 1 with donkey kong sfc rom - this rom i uploded on tv memory with the help of webOS Dev Manager.
screen 2 with above 3 commands on terminal

@maatthc
Copy link
Author

maatthc commented Jan 19, 2024

Everything looks okay.. could you please add all your roms to the usb drive and repeat all steps, adding the following?

ls -la /tmp/usb/sda/sda1/

@Simon34545
Copy link

I'm having an issue as well.
image
Here is output of script:
image

@Simon34545
Copy link

Fixed after reformatting usb using NTFS (overlayfs: filesystem on '/tmp/usb/sda/sda1' not supported)

@bejamartins
Copy link

bejamartins commented Aug 21, 2024

@maatthc I have the same problem. run the script, TV rebooted, no new files or folders in /media/internal/ seen in retroarch.

root@LGwebOSTV:~# ls -la /var/palm/jail/com.retroarch/media/internal/
total 40
drwxrwxrwx 10 root root 4096 Aug 20 03:07 .
dr-xr-xr-x 5 6103 5000 4096 Aug 18 2023 ..
-rw-r--r-- 1 root root 0 Jan 1 2022 .VolumeIcon.icns
drwxr-xr-x 2 root root 4096 Jan 1 2022 .sysservice
drwxr-xr-x 2 root root 4096 Jan 1 2022 .temp
drwxr-xr-x 3 root root 4096 Jan 1 2022 .wallpapers
drwxr-xr-x 6 root root 4096 Aug 19 04:25 ROMs
drwxr-xr-x 2 6799 5000 4096 Aug 20 2023 avs
drwxr-xr-x 2 root root 4096 Feb 26 2023 downloads
drwxr-xr-x 2 root root 4096 Jan 1 2022 ringtones
drwxr-xr-x 2 6799 5000 4096 Aug 18 2023 vsk
root@LGwebOSTV:~# cat /var/lib/webosbrew/init.d/add_usb_drive_to_retroarch_media_folder
#!/bin/bash
mount -t overlay -olowerdir=/var/palm/jail/com.retroarch/media/internal:/tmp/usb/sda/sda1/,nofail overlay /var/palm/jail/com.retroarch/media/internal
root@LGwebOSTV:~# ls -la /var/lib/webosbrew/init.d/add_usb_drive_to_retroarch_media_folder
-rwxr-xr-x 1 root root 163 Aug 21 00:56 /var/lib/webosbrew/init.d/add_usb_drive_to_retroarch_media_folder
root@LGwebOSTV:~# ls -la /tmp/usb/sda/sda1/
total 640
drwxr-xr-x 5 root root 131072 Jan 1 2022 .
drwxr-xr-x 3 root root 60 Jan 1 2022 ..
drwxr-xr-x 2 root root 131072 Aug 21 00:21 Smart TV
drwxr-xr-x 2 root root 131072 Aug 21 00:10 System Volume Information
-rwxr-xr-x 1 root root 1318 Aug 21 00:56 add_usb_drive_to_retroarch_media_folder_install.sh
drwxr-xr-x 3 root root 131072 Aug 21 00:10 roms

(Note that the ROMs folder in /media/internal was already there)

Edit: nevermind, it was the file format as well. Apparently only NTFS works, which is odd for a Linux system,

@Nalle65
Copy link

Nalle65 commented Sep 25, 2024

My LG TV (Firmware 03.30.73 webOS 7.3.0) randomly switches the USB storage path between /tmp/usb/sda/sda1/ to /tmp/usb/sdb/sdb1/ and /tmp/usb/sdc/sdc1/. Is it ok to put each path in a file init.d? like:

#!/bin/bash
mount -t overlay -olowerdir=/var/palm/jail/com.retroarch/media/internal:/tmp/usb/sda/sda1/,nofail overlay /var/palm/jail/com.retroarch/media/internal
mount -t overlay -olowerdir=/var/palm/jail/com.retroarch/media/internal:/tmp/usb/sdb/sdb1/,nofail overlay /var/palm/jail/com.retroarch/media/internal
mount -t overlay -olowerdir=/var/palm/jail/com.retroarch/media/internal:/tmp/usb/sdc/sdc1/,nofail overlay /var/palm/jail/com.retroarch/media/internal

@maatthc
Copy link
Author

maatthc commented Sep 25, 2024

Yeah.. give it a try.. let me know if it works..

@Nalle65
Copy link

Nalle65 commented Sep 26, 2024

My file...
/var/lib/webosbrew/init.d/add_usb_drive_to_retroarch_media_folder
...now looks like this:

#!/bin/bash
mount -t overlay -olowerdir=/var/palm/jail/com.retroarch/media/internal:/tmp/usb/sda/sda1/,nofail overlay /var/palm/jail/com.retroarch/media/internal
mount -t overlay -olowerdir=/var/palm/jail/com.retroarch/media/internal:/tmp/usb/sdb/sdb1/,nofail overlay /var/palm/jail/com.retroarch/media/internal
mount -t overlay -olowerdir=/var/palm/jail/com.retroarch/media/internal:/tmp/usb/sdc/sdc1/,nofail overlay /var/palm/jail/com.retroarch/media/internal

This kind of works, it doesn't matter what letter between A-C LG has decided to use for mounting. But it requires a reboot from the homebre channel if the path has changed since the last normal TV startup.

@maatthc
Copy link
Author

maatthc commented Sep 30, 2024

Legend! Thanks!

@shienok
Copy link

shienok commented Jan 11, 2025

Hi. Almost a year has passed, but my problem is still not solved.
LG C3, rooted, webos 8.2.0-710 (number1-nambung), software version 03.20.17.
Retroarch version 1.19.1 (from Homebrew Channel)
I tried 2 different flash drives with 8 and 16 gb. I tried ntfs, fat32, exfat.
My steaps:

  1. I formated flash drive. On empty flash drive i put only 2 files - add_usb_drive_to_retroarch_media_folder_install.sh and Donkey Kong Country 2 - Diddy's Kong Quest (USA) (En,Fr).sfc. I set flash drive on TV.
  2. On my pc i opened Dev Manager, successfuly conncted to my TV, opened Terminal
  3. I entered: cd /tmp/usb/sda/sda1/
  4. I checked success: ls (i see only those 2 files)
  5. I entered: sh add_usb_drive_to_retroarch_media_folder_install.sh. Pressed random buttom, TV reloaded succesfully.
  6. On TV i open Retroarch, i load snes core, i go to Load Content, i see:
    /media/internal
    /tmp/usb/sda/sda1/
    /
  7. I go to /tmp/usb/sda/sda1/ - and see nothing.

I plug off usb flash drive, set it into my PC and see only this:
-Smart TV (empty folder)
-add_usb_drive_to_retroarch_media_folder_install.sh (file)
-Donkey Kong Country 2 - Diddy's Kong Quest (USA) (En,Fr).sfc (file)

Pls what am i doing wrong?(

@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 ?

@Yovskii
Copy link

Yovskii commented Mar 23, 2025

@maatthc Eu tenho accesso ao Root na TV, antes quando Instaletei RetroArch primeira vez ele faz a leitura do pendrive, porem de tanto eu fazer unistall e install por que estava tentando confirgurar, emulador parou de ler os pendrive. Eu coloquei alguns jogos na memoria da TV porem é apenas 1GB. Poderia explicar melhor o passo a passo de como fazer isso. Eu tenho acesso ao root e o terminal tambem.

@Yovskii
Copy link

Yovskii commented Mar 23, 2025

@mirogster
Copy link

mirogster commented Aug 31, 2025

Bump. May confirm, everything is working now after those changes https://gist.github.com/maatthc/792471812150010c935aedd34c93aedf?permalink_comment_id=5457777#gistcomment-5457777 mentioned.

Had similar problems with recognition of SDA1 (none), then ran that changed script. All gucci :P

Thank you!!

PS. Rooted OLED 48B4
webOS 24 / 9.2.4-44
SDD with NTFS

@vinelt76
Copy link

In mine it detecst now the archives but doesnt let me use a core to play the games just says no cores available even i have the cores and BIOS , anyone got this issue?

@ElYaiko
Copy link

ElYaiko commented Oct 5, 2025

I get "webosbrew/ not exists" (I haven't rooted my TV)
Any help how to root my LG WebOS 9+?

@maatthc
Copy link
Author

maatthc commented Oct 5, 2025

I get "webosbrew/ not exists" (I haven't rooted my TV) Any help how to root my LG WebOS 9+?

Try this..

@ElYaiko
Copy link

ElYaiko commented Oct 5, 2025

I get "webosbrew/ not exists" (I haven't rooted my TV) Any help how to root my LG WebOS 9+?

Try this..

I tried but I get error (It seems to be patched for 9+ 😞 )

@wes1993
Copy link

wes1993 commented Nov 15, 2025

Hi all,
Thanks a lot for this guide, there are some options for network drive?

@maatthc
Copy link
Author

maatthc commented Nov 16, 2025

Very good question.. but I'm pretty sure it is possible.. would be nice to have..

@wes1993
Copy link

wes1993 commented Nov 16, 2025

Hi @maatthc
I’ve checked, but unfortunately the TV doesn’t have the components needed to mount the share. They might need to be compiled, but I’d rather not risk bricking the TV :-(

root@LGwebOSTV:# which mount
/bin/mount
root@LGwebOSTV:
# which mount.nfs
root@LGwebOSTV:# ls /sbin /bin /usr/sbin /usr/bin | grep nfs
root@LGwebOSTV:
# lsmod | grep nfs
root@LGwebOSTV:~# lsmod
Module Size Used by
dm_eswap_ad 16384 0
dm_eswap 61440 3 dm_eswap_ad
wlan_mt7663_usb 1875968 0
btmtk_usb 106496 2
tfat 311296 0
tntfs 458752 0
a8303 16384 0
dvb_a8303_chip 16384 1 a8303
dvb_a8303_adapter 16384 1 dvb_a8303_chip
rda5815m 16384 0
dvb_rda5815m_chip 24576 1 rda5815m
dvb_rda_adapter 16384 1 dvb_rda5815m_chip
si2178b 16384 0
si2178b_atv 16384 0
dvb_si2178b_chip 188416 2 si2178b,si2178b_atv
dvb_silab_adapter 16384 1 dvb_si2178b_chip
dvb_dtv_soc 16384 0
dvb_dtv_soc_chip 49152 1 dvb_dtv_soc
dvb_common_adapter 16384 2 dvb_dtv_soc_chip,dvb_si2178b_chip
demod_khal 1167360 1 dvb_dtv_soc_chip
webos_tv 57344 10 dvb_a8303_chip,a8303,si2178b,dvb_dtv_soc_chip,dvb_dtv_soc,si2178b_atv,rda5815m,dvb_si2178b_chip,dvb_rda5815m_chip
mali_kbase 471040 8
mali_fb 20480 6
dma_buf_test_exporter 20480 28 mali_kbase

Best regards
Stefano

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