Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
disk_image_compression [2023/10/21 17:46] – [SquashFS] Add explanation for how to use run.sh with ports ssokolowdisk_image_compression [2026/03/27 10:24] (current) – ↷ Links adapted because of a move operation 40.77.167.44
Line 30: Line 30:
   * [[systems:3do]]   * [[systems:3do]]
   * [[systems:dreamcast]]   * [[systems:dreamcast]]
-  * [[systems:segacd]]+  * [[systems:megacd]]
   * [[systems:neogeocd]]   * [[systems:neogeocd]]
   * [[systems:pcenginecd]]   * [[systems:pcenginecd]]
Line 95: Line 95:
 chdman extractcd -i <game.chd> -o <game.cue> chdman extractcd -i <game.chd> -o <game.cue>
 </code> </code>
 +
 +For DVD-based systems, you can use the ''createdvd'' command rather than ''createcd'' in the examples above. It is usually a little more efficient in term of compression (7-10% gain on the resulting ''.chd'' file) but it also provides better performance in-game. 
  
 === CHD batch converting === === CHD batch converting ===
Line 102: Line 104:
 **Linux/macOS:** **Linux/macOS:**
  
-Navigate to the folder that has all your game ROMs and run the following ''for'' loop to convert all the files in one go:+Place the script into your folder that holds your ROMs and execute the script. This will take it's time. So relax....
  
-<file bash cue-to-chd.sh> +<file bash allimg-to-chd.sh> 
-#!/bin/bash +#!/usr/bin/env -S bash #PROTECTED 
-for i in *.cue; +grep -rlq $'\r' "$0" && { dos2unix -k -q "$0"; echo "Script repaired ... please try again"; exit 0; } # Selfrepair for called script 
-do chdman createcd -i "${i}" -o "${i%.*}.chd";+pushd "$(dirname "$0")" 
 +readarray -t array < <(find -maxdepth 1 -type f \( -iname "*.cue" -o -iname "*.iso" -o -iname "*.toc" -o -iname "*.gdi" -o -iname "*.nrg" \) -printf "%p\n"
 +[ -z "${array[@]}" ] && { echo "No disc images found.... Exit now"exit; } 
 +[ -f "/usr/bin/mame/chdman" ] || { echo "chdman not found! ... Exit now"; exit; } 
 +for i in "${array[@]}"; do 
 +    /usr/bin/mame/chdman createcd -i "${i}" -o "${i%.*}.chd"; 
 +    echo; echo "You can remove file: $i and additionals if you want!"
 done done
 +popd
 </file> </file>
  
-replacing ''*.cue'' as needed. If you're converting a lot of files, practice some yoga poses. This may take a while.+replacing ''*.cue'' and other images as needed. If you're converting a lot of files, practice some yoga poses. This may take a while.
  
 Here's a command to convert all the games in the current folder and recursive folders to CHD:  Here's a command to convert all the games in the current folder and recursive folders to CHD: 
Line 290: Line 299:
  
 **Linux/MacOS:** **Linux/MacOS:**
 +
 +Create a file with these contents...
  
 <file bash iso-to-ciso.sh> <file bash iso-to-ciso.sh>
 #!/bin/bash #!/bin/bash
-for i in *.iso; +for i in "$@"; do  
-do ciso 9 "${i}" "${i}".ciso;+    ciso 9 "${i}" "${i%*.iso}".cso;
 done done
 </file> </file>
 +
 +...mark it executable with this...
 +
 +<code>chmod +x iso-to-ciso.sh</code>
 +
 +...and then run it like this:
 +
 +<code>./iso-to-ciso.sh *.iso</code>
  
 **Windows:** **Windows:**
Line 532: Line 551:
   cd /userdata/roms/dos   cd /userdata/roms/dos
   mksquashfs skweek.pc skweek.pc.squashfs   mksquashfs skweek.pc skweek.pc.squashfs
 +  
 +  cd /userdata/roms/scummvm
 +  mksquashfs "astro chicken" "astro chicken.squashfs" -comp xz
  
 Or to compress a single file : Or to compress a single file :
Line 557: Line 579:
  
 If you use the btrfs filesystem, you can enable compression, and you'll get the same compression result without any action. If you use the btrfs filesystem, you can enable compression, and you'll get the same compression result without any action.
- 
-=== The run.sh file === 
- 
-When using squashfs for [[systems:ports]] games, you must include a ''run.sh'' file at the root of the compressed filesystem which will run the game. 
- 
-This file will be executed with the working directory set to ''/userdata'', so the first operation you need to do is ''cd'' into the script's parent directory. 
- 
-If your game is a 64-bit GOG.com game which requires no special tweaks or additional libraries, you should just be able to use this example script as-is: 
- 
-<file sh run.sh> 
-#!/bin/sh 
-cd "$(dirname "$(readlink -f "$0")")" 
- 
-unclutter-remote -h 
-exec ./start.sh 
-</file> 
- 
-If your game is a 32-bit GOG.com game which requires no special tweaks or additional libraries, this example script should do: 
- 
-<file sh run.sh> 
-#!/bin/sh 
-cd "$(dirname "$(readlink -f "$0")")" 
- 
-unclutter-remote -h 
-export LD_LIBRARY_PATH=/lib32 
-export LIBGL_DRIVERS_PATH=/lib32/dri 
-export SPA_PLUGIN_DIR="/lib32/spa-0.2:/usr/lib/spa-0.2" 
-export PIPEWIRE_MODULE_DIR="/lib32/pipewire-0.3:/usr/lib/pipewire-0.3" 
-exec ./start.sh 
-</file> 
- 
-To explain the ''cd'' line: 
- 
-* In any shell script, ''$0'' contains the command used to run the script 
-* ''readlink -f'' resolves any symlinks and makes it absolute, ensuring the path will always contain a parent directory 
-* ''dirname'' strips off the last component to get the parent directory 
-* ...and then we ''cd'' into that. 
  
 === Uncompress a SquashFS file === === Uncompress a SquashFS file ===
  • disk_image_compression.1697910391.txt.gz
  • Last modified: 3 years ago
  • by ssokolow