Skip to content

Instantly share code, notes, and snippets.

@mafredri
Last active November 11, 2024 05:10
Show Gist options
  • Save mafredri/e88401c91489232e92e493d0e02912ef to your computer and use it in GitHub Desktop.
Save mafredri/e88401c91489232e92e493d0e02912ef to your computer and use it in GitHub Desktop.
Samba config for Open PS2 Loader (PlayStation 2)
# This setup works pretty well for OPL with a network link that travels through
# two UniFi switches and connects to a Samba server running inside Docker. The
# host OS is Debian with a ZFS filesystem and the container OS is also Debian.
# Latest Samba (4.11+).
[global]
# ======================
# General Samba settings
# ======================
log level = 1
workgroup = WORKGROUP
server string = PS2 Samba Server
server role = standalone server
log file = /dev/stdout
max log size = 0
# Disable printers.
load printers = no
printing = bsd
printcap name = /etc/printcap
printcap cache time = 0
disable spoolss = yes
pam password change = yes
map to guest = bad user
usershare allow guests = yes
create mask = 0664
force create mode = 0664
directory mask = 0775
force directory mode = 0775
force user =
force group = users
# ===========================
# PlayStations 2 OPL settings
# ===========================
# Lower the minimum protocol to NT1 (a SMB1 dialect), this is required since
# Samba 4.11 changed the default and deprecated SMB1.
# See https://github.com/ifcaro/Open-PS2-Loader/issues/86 and
# https://github.com/ps2dev/ps2sdk/issues/72 for future SMB2 support.
server min protocol = NT1
server signing = disabled
smb encrypt = disabled
# Tweak socket options for lower delay. We also set TCP_KEEPIDLE to 20s which is
# about what it takes to reset the console and launch OPL, this avoids keeping
# file locks around for too long. We could try to optimize socket buffer sizes
# but Linux should do this automatically.
# TODO(mafredri): Do more testing with TCP_QUICKACK.
socket options = TCP_NODELAY TCP_KEEPIDLE=20 IPTOS_LOWDELAY SO_KEEPALIVE
# Disable keepalive to avoid hanging onto locks. Should not be needed
# due to SO_KEEPALIVE and helps with FMV audio stutter.
keepalive = 0
# ------------------------------------
# Attempt to speed up reads and writes
# ------------------------------------
# This setting only works for oplocked files but OPL doesn't oplock.
write cache size = 0
# Speed up directory listings.
getwd cache = yes
# Remove audio stutter in FMVs.
large readwrite = yes
# Disable asynchronous reads and writes.
aio read size = 0
aio write size = 0
# This might help with performance as the system doesn't need to check locks.
# OPL is the only client so we don't care about locks anyway.
strict locking = no
# ----------
# ZFS tuning
# ----------
# Don't listen to client requests for sync.
strict sync = no
# ZFS does not support preallocation (copy-on-write FS).
strict allocate = no
# Disable low-latency file operations for better performance.
read raw = no
write raw = no
# ----
# Misc
# ----
# Allow symlinks, useful for symlinking saves for multi-disk games.
follow symlinks = yes
[PS2]
comment = PlayStation 2
path = /mnt/ps2
browsable = yes
guest ok = yes
public = yes
available = yes
read only = no
veto files = /._*/.apdisk/.AppleDouble/.DS_Store/.TemporaryItems/.Trashes/desktop.ini/ehthumbs.db/Network Trash Folder/Temporary Items/Thumbs.db/
delete veto files = yes
@gdfsv
Copy link

gdfsv commented Nov 27, 2021

this hangs for me on Fatal Frame 3. I'm using BTRFS.

@mafredri
Copy link
Author

mafredri commented Nov 27, 2021

@gdfsv have you tried using different versions of Open PS2 Loader? Or changing game settings/hacks inside OPL? A hang sounds like a game specific OPL issue but I'm definitely no expert.

I'd start testing from the latest stable OPL release (v1.1.0), then try a newer beta, or some of the older v0 releases.

The only Samba change for btrfs I can think of is changing these from no to yes (it may or may not improve btrfs performance):

read raw = yes
write raw = yes

Btw, on what OS are you, and what version of Samba?

@gdfsv
Copy link

gdfsv commented Nov 30, 2021

i tried opl 1.0, 1.1.0, and latest beta. also done enable read/write write. issue persists.

i use NixOS. samba 4.15.0

@mafredri
Copy link
Author

mafredri commented Dec 1, 2021

@gdfsv ok, sounds like you have the bases covered in that department. Did you try changing the game modes (and experimenting with different combinations) in game settings (inside OPL)? That's the only thing I can think of that could help assuming the game is playable over Samba. That's about all the help I can provide in this instance.

@jamez2128
Copy link

jamez2128 commented Jan 14, 2022

add this line for passwords to work in OPL:
ntlm auth = yes

@GabubuAvailable
Copy link

If it still doesn't work, make sure to create a samba user:
sudo smbpasswd -a samba_user, where samba_user can be the username you want.

Restart the smb and nmb services with systemctl then open OPL and use the USER and PASSWORD used for creating the samba user previously.

@NetMan134
Copy link

write cache size is not present in samba 4+ afaik

@tomeq82
Copy link

tomeq82 commented Jun 6, 2024

Sorry for necroposting, but using this config and modifying it line by line - I got result of simply hanging samba docker container after few packets exchanged. Probably not connected with this config itself, but i'm wondering what effectively "kills" the process running on the container (Alpine and vanilla samba there - nothing else)

@SpazCode153
Copy link

@tomeq82 are there any logs for the container? you can run the following command to see the logs for the container: sudo docker container logs CONTAINER_NAME

just replace CONTAINER_NAME with your container name or the container id

@tomeq82
Copy link

tomeq82 commented Jun 7, 2024

@SpazCode153 in fact, I have a lot of the debugs - I enabled level 5, then reduced do level 3.
Each time it says "waiting for connections" is my restart of the container as it simply exits/dies.
Also, any meaningful error is something like that when tried to read the file:

https://pastebin.com/RSLTcRhv

and here are the other logs:
https://pastebin.com/0sm1hcrp

What is surprising it is not repatable situation eg. sometimes I got into listing of the particular game inside the share, but most of the time it simple drops error 300 or 301.

@SpazCode153
Copy link

@tomeq82 Just to confirm, your PS2 is directly connected to the samba device via LAN cable? What device are you using to share your games via samba?

@tomeq82
Copy link

tomeq82 commented Jun 7, 2024

@SpazCode153 no, PS2 is connected to the same lan as NAS hosting the container with samba. Docker container, vanilla alpine linux + just samba packages.

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