Skip to content

Instantly share code, notes, and snippets.

@Rudo2204
Created July 4, 2021 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rudo2204/c61d8bb739a12922f9d1ea57d849f589 to your computer and use it in GitHub Desktop.
Save Rudo2204/c61d8bb739a12922f9d1ea57d849f589 to your computer and use it in GitHub Desktop.
cdemu mx linux

NOTE

The cdemu packages from deb multimedia repo is broken, so we will have to use ubuntu PPA for this.

Add ubuntu PPA Ref link

sudo nano /etc/apt/sources.list.d/cdemu.list with content:

# cdemu source
deb http://ppa.launchpad.net/cdemu/ppa/ubuntu/ bionic main  
deb-src http://ppa.launchpad.net/cdemu/ppa/ubuntu/ bionic main

Add key: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AFDF4CC6A4F32AA9395FAE8F423A2125D782A00F

Add deb multimedia for libmirage-plugin relevant issue

You can do it using synaptic or sudo vim /etc/apt/sources.list and add deb http://www.deb-multimedia.org/ buster main non-free

Update and grab the packages

sudo apt install cdemu-client cdemu-daemon gcdemu libmirage-plugin

IMPORTANT STEP: disable deb multimedia after you are done, it usually causes problems!

Start cdemu

NOTE

Sometime you will run into some trouble running the daemon:

posix_spawn avoided (fd close requested) cdemu0: Kernel I/O: failed to open control device /dev/vhba_ctl: No such file or directory!
cdemu: Daemon: failed to start device #0!
cdemu: Daemon: failed to create device!
Daemon initialization and start failed!

Solution to this is to: sudo modprobe vhba to start up vhba device, then start the daemon.

Start daemon

cdemu-daemon

Now you can start gcdemu

gcdemu

Hope that helps.

@0x6A7232
Copy link

0x6A7232 commented Mar 3, 2024

I'm having issues, seen here.

Error given at system start is

Daemon autostart faled. Error:
g-io-error-quark: Error calling StartServiceByName for
net.sf.cdemu.CDEmuDaemon: Timeout was reached (24)

Trying to figure out a way to convert the systemd init script to a sysv init script and sysv init scripts look arcane. I mean,

Systemd:

[Unit]
Description=CDEmu daemon

[Service]
Type=dbus
BusName=net.sf.cdemu.CDEmuDaemon
ExecStart=/usr/bin/cdemu-daemon --config-file "%h/.config/cdemu-daemon"
Restart=no

vs

SysV Init:

#!/bin/sh
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
    set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi
### BEGIN INIT INFO
# Provides:          iscsid
# Required-Start:    $network $local_fs
# Required-Stop:     $network $local_fs sendsigs
# Default-Start:     S
# Default-Stop:      0 1 6
# Short-Description: iSCSI initiator daemon (iscsid)
# Description:       The iSCSI initiator daemon takes care of
#                    monitoring iSCSI connections to targets. It is
#                    also the daemon providing the interface for the
#                    iscisadm tool to talk to when administering iSCSI
#                    connections.
### END INIT INFO

# Author: Christian Seiler <christian@iwakd.de>

DESC="iSCSI initiator daemon"
DAEMON=/sbin/iscsid
PIDFILE=/run/iscsid.pid
OMITDIR=/run/sendsigs.omit.d

do_start_prepare() {
	if ! /lib/open-iscsi/startup-checks.sh ; then
		exit 1
	fi
}

do_start_cleanup() {
	ln -sf $PIDFILE $OMITDIR
}

do_stop_override() {
	# Don't stop iscsid if we're on initramfs or we had some
	# excluded sessions. We could actually stop it, it's not
	# required for the kernel to continue working with active
	# sessions, but it also doesn't hurt to leave it running.
	if [ -f /etc/iscsi/iscsi.initramfs ] ||
		( [ -f /run/open-iscsi/shutdown-keep-sessions ] && [ -n "$(cat /run/open-iscsi/shutdown-keep-sessions)" ] )
	then
		return
	fi
	do_stop "$@"
}

There's no way of guessing the correct syntax for an init script, I'd basically have to know how to program them from scratch.

Tried starting the cdemu daemon manually and:

$ cdemu-daemon
Starting CDEmu daemon with following parameters:
 - config file: (null) (exists: 0)
 - num devices: 1
 - control device: /dev/vhba_ctl
 - audio driver: null
 - bus type: session
 - default CDEmu debug mask: 0x0
 - default libMirage debug mask: 0x0

Using cross-namespace EXTERNAL authentication (this will deadlock if server is GDBus < 2.73.3)Using cross-namespace EXTERNAL authentication (this will deadlock if server is GDBus < 2.73.3)

Looks like a deadlock. Can't find GDBus package, guess that's my next rabbit hole to jump down, since MX uses a systemd shim for compatibility, it should be working, right? So maybe it's GDBus?

Looks like we're using DBus instead? Found these:

https://docs.gtk.org/gio/

https://docs.gtk.org/gio/migrating-gdbus.html

In hopes that the daemon was running successfully despite not returning control to the terminal window, I tried running gCDemu, it won't open. cdemu status locks up then displays:

$ cdemu status
ERROR: Failed to connect to CDEmu daemon: g-io-error-quark: Error calling StartServiceByName for net.sf.cdemu.CDEmuDaemon: Timeout was reached (24)

Poked around and here's the net.sf.cdemu.CDEmuDaemon.service file

[D-BUS Service]
Name=net.sf.cdemu.CDEmuDaemon
SystemdService=cdemu-daemon.service
Exec=/bin/true

/bin/true "does nothing and exits successfully" so...??

EDIT: Looks like I found the culprit for some of this. Missing the libmirage-plugin, which I had thought I saw get installed, but it was libmirage11 -- so I had to:
sudo add-apt-repository deb https://www.deb-multimedia.org bookworm main non-free
then sudo apt update & sudo apt install libmirage-plugin
then edit the /etc/apt/sources.list.d/archive_uri-https_www_deb-multimedia_org-bookworm.list and comment out all lines then sudo apt update again

Service still has the same error as before but now I can manually start it with cdemu-daemon --config-file ~/".config/cdemu-daemon"
It will still lock up that terminal window, but you can then seem to use cdemu. (If you Ctrl+C the terminal window it will close the daemon as well.)
I have not tested mounting anything, just the program can view device status.
For gCDEmu, you need to right-click the tray icon & quit, then start it back up from your menu and then it will see the devices properly.

There's a thread on the MX Linux forums about cdemu and I mentioned the above on it. You can find it here.

@0x6A7232
Copy link

0x6A7232 commented Mar 3, 2024

Ok, loading .cue files is a success and I've successfully played the audio tracks on the mixed mode CD (.bin) it referenced (data / audio combined). VLC can play back successfully, Asunder can view / rip the tracks, but Audacious and DeadBeef can't see the drive (hard coded CD device location?). Hope this helps someone out there.

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