# CHDMan Linux Instructions

## Introduction

<div id="bkmrk-">  
</div>The file formats to adopt for CDs and other optical supports.

We have talked about a format, derived from researches we had on MAME, in order to be able to represent these supports in a compressed way, without losing the integrity of the data and that these can remain scrappable.

This format is the CHD (Compressed Hunks of Data), datas that could be useful for SEGA CD, PS1, PC Engine...

Unfortunately, the classic user will have difficulties to use the converter, which is a command line executable.

So here is a Zip file, with automated scripts, to convert from BIN+CUE (Redump format) to CHD, and vice versa.

It has been added also for the GDI format, which is for the Dreamcast.

For PS1 games protected by LibCrypt, normally you have SBI (Subchannel Information) files, you keep them and put them with the CHDs, otherwise your games will not pass.

If you ever lose them or make a bad manipulation, these files are available on the files of each corresponding disk at Redump, next to the re-downloadable CUE files.

<div id="bkmrk--1">  
</div>## Software

<div class="tabset elevation-2" id="bkmrk--2"><div class="tabset-content"><div class="tabset-panel is-active"></div></div></div>Some Linux distributions can give you chdman via `aptitude` with the `mame-tools` package. Some others don't have any `mame-tools` and you need to build it:

<div class="tabset elevation-2" id="bkmrk-go-to%C2%A0https%3A%2F%2Fgithub"><div class="tabset-content"><div class="tabset-panel is-active">- Go to [https://github.com/libretro/mame](https://github.com/libretro/mame)
- Download the content by clicking on the `Code` green button then, in the visible menu, click on `Download ZIP`

</div></div></div>![](https://wiki.recalbox.com/tutorials/utilities/rom-conversion/chdman/mamedownload.png)

<div class="tabset elevation-2" id="bkmrk-uncompress-the-downl"><div class="tabset-content"><div class="tabset-panel is-active">- Uncompress the downloaded archive and go inside the extracted directory. You should retrieve the same content than into the given link in the first step.
- From your, use this command:

<div class="code-toolbar"></div></div></div></div>```ssh
make tools
```

<div class="tabset elevation-2" id="bkmrk-at-the-end%2C-you-shou"><div class="tabset-content"><div class="tabset-panel is-active"><div class="code-toolbar"></div>- At the end, you should be able to find chdman into the `build` directory.

</div></div></div>Here is a link to download files to automate format conversions:

![](https://wiki.recalbox.com/tutorials/utilities/rom-conversion/chdman/archive.svg) [ChdScripts.zip](https://wiki.recalbox.com/tutorials/utilities/rom-conversion/chdman/chdscripts.zip)

In this zip you will find 6 files:

<div class="tabset elevation-2" id="bkmrk-file-name-descriptio"><div class="tabset-content"><div class="tabset-panel is-active"><table><thead><tr><th>File name</th><th>Description</th></tr></thead><tbody><tr><td>**ConvertFromChdToCue.sh**</td><td>A .sh file that allows you to convert your `CHD` roms to `BIN`/`CUE` format.</td></tr><tr><td>**convertFromChdToGdi.sh**</td><td>A .sh file that allows you to convert your `CHD` roms to `GDI` format.</td></tr><tr><td>**convertFromChdToIso.sh**</td><td>A .sh file that allows you to convert your `CHD` roms to `ISO` format.</td></tr><tr><td>**convertFromCueToChd.sh**</td><td>A .sh file that allows you to convert your `BIN`/`CUE` roms to `CHD`.</td></tr><tr><td>**convertFromGdiToChd.sh**</td><td>A .sh file that allows you to convert your `GDI` roms to `CUE`.</td></tr><tr><td>**convertFromIsoToChd.sh**</td><td>A .sh file that allows you to convert your `ISO` roms to `CUE`.</td></tr><tr><td>**README\_EN.txt**</td><td> </td></tr><tr><td>**README\_FR.txt**</td><td> </td></tr></tbody></table>

</div></div></div>#### Contents of the readme file

<div class="tabset elevation-2" id="bkmrk-convertfromchdtocue."><div class="tabset-content"><div class="tabset-panel is-active">- **convertFromChdToCue.sh**
    
    Decompresses a CHD (V5) file into a BIN+CUE file.  
    The CUE format is used by games on CD. CHD is supported by 3DO, Amiga CD32, Amiga CDTV, Dreamcast, Mega CD, Neo-Geo CD, PC Engine CD, PlayStation and Saturn.
- **convertFromChdToGdi.sh**  
    Decompresses a CHD (V5) file into a GDI file.  
    The GDI format is used by disk-based games for Dreamcast.
- **convertFromChdToIso.sh**  
    Decompresses a CHD (V5) file into an ISO file.  
    The ISO format is used by disk-based games for PlayStation 2.
- **convertFromCueToChd.sh**
    
    Compresses any type of BIN disk files with a CUE header to the CHD (v5) format. Searches all subfolders and creates CHD (v5) files in the folder where the files are placed with CHDMAN.
- **convertFromGdiToChd.sh**
    
    Compresses any type of BIN disk files with a GDI header to the CHD (v5) format. The GDI format is used by disk-based games for Dreamcast.
- **convertFromIsoToChd.sh**
    
    Compresses any type of BIN disk files with a ISO header to the CHD (v5) format. The ISO format is used by disk-based games for PlayStation 2.

</div></div></div>## Automated use

#### Convert your game from `BIN`/`CUE` to `CHD`

<div class="tabset elevation-2" id="bkmrk-put-%22convertfromcuet"><div class="tabset-content"><div class="tabset-panel is-active">- Put "**convertFromCueToChd.sh**" in the folder containing your game as below.  
    Example for the game "Grandia (France)" :
- In your Terminal, execute the file with the command `./convertCueToChd.sh` to start the conversion.
- Once your Terminal window has finished, your conversion is complete.
- You can delete "**convertFromCueToChd.sh**", your rom is ready.

</div></div></div>#### Convert your game from `GDI` to `CHD`

<div class="tabset elevation-2" id="bkmrk-put-%22convertfromgdit"><div class="tabset-content"><div class="tabset-panel is-active">- Put "**convertFromGdiToChd.sh**" in the folder containing your game as below.  
    Example for the game "Resident Evil - Code - Veronica (France)" :
- In your Terminal, execute the file with the command `./convertFromGdiToChd.sh` to start the conversion.
- Once your Terminal window has finished, your conversion is complete.
- You can delete "**convertFromGdiToChd.sh**", your rom is ready.

</div></div></div>#### Convert your game from `ISO` to `CHD`

<div class="tabset elevation-2" id="bkmrk-put-%22convertfromisot"><div class="tabset-content"><div class="tabset-panel is-active">- Put "**convertFromIsoToChd.sh**" in the folder containing your game as below.  
    Example for the game "Shadow of the Colossus (Europe, Australia) (En,Fr,De,Es,It)" :
- In your Terminal, execute the file with the command `./convertFromIsoToChd.sh` to start the conversion.
- Once your Terminal window has finished, your conversion is complete.
- You can delete "**convertFromIsoToChd.sh**", your rom is ready.

</div></div></div>#### Convert your game from `CHD` to `BIN`/`CUE`

<div class="tabset elevation-2" id="bkmrk-put-%22convertfromchdt"><div class="tabset-content"><div class="tabset-panel is-active">- Put "**convertFromChdToCue.sh**" in the folder containing your game as below.  
    Example for the game "Grandia (France)" :
- In your Terminal, execute the file with the command `./convertFromChdToCue.sh` to start the conversion.
- Once your Terminal window has finished, your conversion is complete.
- You can delete "**convertFromChdToCue.sh**", your rom is ready.

</div></div></div>#### Convert your game from `CHD` to `GDI`

<div class="tabset elevation-2" id="bkmrk-put-%22convertfromchdt-1"><div class="tabset-content"><div class="tabset-panel is-active">- Put "**convertFromChdToGdi.sh**" in the folder containing your game as below.  
    Example for the game "Resident Evil - Code - Veronica (France)" :
- In your Terminal, execute the file with the command `./convertFromChdToGdi.sh` to start the conversion.
- Once your Terminal window has finished, your conversion is complete.
- You can delete "**convertFromChdToGdi.sh**", your rom is ready.

</div></div></div>#### Convert your game from `CHD` to `ISO`

<div class="tabset elevation-2" id="bkmrk-put-%22convertfromchdt-2"><div class="tabset-content"><div class="tabset-panel is-active">- Put "**convertFromChdToIso.sh**" in the folder containing your game as below.  
    Example for the game "Shadow of the Colossus (Europe, Australia) (En,Fr,De,Es,It)" :
- In your Terminal, execute the file with the command `./convertFromChdToIso.sh` to start the conversion.
- Once your Terminal window has finished, your conversion is complete.
- You can delete "**convertFromChdToIso.sh**", your rom is ready.

</div></div></div>## Create the `.M3U` file

<div id="bkmrk--4">  
</div>In CHD conversion for multi-disk games, you have to make a **M3U** file to declare all the disks.

The `.M3U` file is a list of the different CDs for a game that allows you to switch from one CD to another in a simple way by using the disc change combination (`Hotkey` + `L. STICK` to the *LEFT* or to the *RIGHT*).

Example for the game "Grandia (France)":

<div id="bkmrk--5">  
</div>- Create a `M3U` file via Notepad++ named "Grandia (France).m3u".
- In the file, fill in the `CHD` files of the game:

<div id="bkmrk--6">  
</div>```text
Grandia (France) (Disc 1).chd
Grandia (France) (Disc 2).chd
```

<div id="bkmrk--7">  
</div>- On Windows, you must have the extension view enabled to create this file: 
    - Go to `View` at the top of the Windows Explorer window.
    - Check "File name extensions" at the top right.

<div id="bkmrk--8">  
</div>![](https://wiki.recalbox.com/tutorials/utilities/rom-conversion/chdman/chdman-m3u1.png)

<div id="bkmrk--10">  
</div>- Confirm the extension change

<div id="bkmrk--11">  
</div>![](https://wiki.recalbox.com/tutorials/utilities/rom-conversion/chdman/chdman-m3u2.png)