Jump to content

[Tutorial] Optimizing Emby (Native): Transcode and Cache in RAM (Tmpfs) via Entware WD PR4100


Recommended Posts

WDPR4100
Posted (edited)

This tutorial explains how to move Emby's transcoding and cache directories to a virtual disk in memory (RAM using tmpfs). This provides maximum performance and, most importantly, protects your mechanical hard drives (HDDs) from the heavy and constant write operations generated by video transcoding and thumbnail generation.

Prerequisites:

  • A NAS running Entware (tested on WD My Cloud PR4100).

  • Sufficient RAM (Recommended: at least 16GB of RAM so you can comfortably allocate 6GB to the system).

  • Root SSH access.

Step 1: Create the Automatic RAM Mounting Script

Entware automatically executes scripts located in /opt/etc/init.d/ when the NAS boots up. We will create a script that sets up a 6GB tmpfs RAM space and prepares the necessary directories.

  • Connect to your NAS via SSH as root.

  • Create or overwrite your startup script by running this command block:

  • cat << 'EOF' > /opt/etc/init.d/S99embyram
    #!/bin/sh
    RAM_DIR="/mnt/HD/HD_a2/Nas_Prog/embyserver/transcode_ram"
    CACHE_DIR="$RAM_DIR/cache"
    
    case "$1" in
        start)
            if [ ! -d "$RAM_DIR" ]; then
                mkdir -p "$RAM_DIR"
            fi
            
            # Mount RAM with a 6GB allocation
            mount -t tmpfs -o size=6G tmpfs "$RAM_DIR"
            
            if [ ! -d "$CACHE_DIR" ]; then
                mkdir -p "$CACHE_DIR"
            fi
            
            # Broad permissions to allow native writing without errors
            chmod -R 777 "$RAM_DIR"
            
            echo "Emby RAM (6GB) transcode and cache mounted successfully at $RAM_DIR"
            ;;
        stop)
            umount "$RAM_DIR"
            echo "Emby RAM transcode unmounted."
            ;;
        *)
            echo "Usage: $0 {start|stop}"
            exit 1
            ;;
    es:
    exit 0
    EOF

    (Adjust the path /mnt/HD/HD_a2/Nas_Prog/embyserver/transcode_ram to match your own NAS directory structure if necessary).

    Step 2: Test and Run the Script Immediately

    To apply the script right away without rebooting your NAS:

  • Unmount the old point if it already existed:

  • umount /mnt/HD/HD_a2/Nas_Prog/embyserver/transcode_ram

    Run the startup script:

  • sh /opt/etc/init.d/S99embyram start

    Verify that the 6GB are active:

  • df -h | grep transcode_ram

    Step 3: Configure Emby from the Web Interface

    Now that your RAM space is ready, you need to tell Emby to use it.

  • Log into your Emby admin dashboard as an administrator.

  • For Transcoding:

    Go to Server > Transcoding (or Paths).

    In the Transcode path field, enter:

  • /mnt/HD/HD_a2/Nas_Prog/embyserver/transcode_ram

     

  • Click Save.

  • For Cache:

    Go to Server > General (under the Advanced section).

    In the Cache path field, enter:

  • /mnt/HD/HD_a2/Nas_Prog/embyserver/transcode_ram/cache

     

  • Click Save.

  • Step 4: Restart Emby

    Restart your Emby service so it applies the new paths.

    That's it! The setup is fully persistent: every time the NAS reboots, the Entware script will automatically recreate the 6GB RAM space with the correct permissions, and Emby will seamlessly store its cache and transcodes there.

     

entware_20.11.17_PR4100.bin

Emby_old version.png

Emby Transcodage_Cache.png

Edited by WDPR4100
Posted

Thanks for sharing.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...