11

The CD/DVD drive of my notebook is broken. However, the drive from my desktop computer is working perfectly.

How can I access the CD/DVD drive from my desktop computer over the network? I want to put a DVD disc there and access it from my notebook.

Both computers have Gentoo/Linux. (but the solution ought to work on any Linux distribution)

3 Answers 3

9

I feel like a Samba / NFS setup is kind of a big hammer for this little nail. I found a blog post on this topic which shows the use of a tool called nbd -- network block device. To use it, setup the server and client.

(The tutorial is written for Ubuntu with a CD device at /dev/cdrom, so you may need to adjust for your setup.)

On the server side (with the CDROM):

sudo apt-get install nbd-server
sudo adduser nbd cdrom

(You may get a warning about no configured exports - ignore it, we'll set one up below.)

Edit the /etc/nbd-server/config file:

[generic]
  group     = cdrom
  allowlist = true
[cdrom]
  exportname = /dev/cdrom
  readonly   = true

Then: sudo /etc/init.d/nbd-server restart

On the client side (access the server's CDROM):

sudo apt-get install nbd-client

Now map the block device (where 192.168.1.100 is the ip address of the server):

sudo nbd-client 192.168.1.100 -name cdrom /dev/nbd0

Now you can mount /dev/nbd0 as if it was a CDROM on the client:

sudo mkdir /mnt/cdrom   # if it doesn't already exist
sudo mount -t iso9660 /dev/nbd0 /mnt/cdrom

Or grab an ISO:

sudo dd if=/dev/nbd0 of=~/disc.iso
2
  • 1
    This is a better write up than the chatty original, thanks! Mar 15, 2016 at 13:48
  • 1
    I was able to follow these instructions with zero hiccups on two archlinux machines (archlinux bundles server and client as nbd). It's not perfect, though: my software can tell that it's not a real drive. I'm trying to play a bluray somewhere else. Mar 21, 2016 at 14:29
3

Try sharing it over samba:

sudo nano /etc/samba/smb.conf

and

[cdrom]
comment = CD Drive
path = /mnt/cdrom
public = no
writable = no
4
  • +1 from me. I already did this using samba oce and it works perfectly.
    – Diogo
    Jul 29, 2011 at 17:40
  • Sorry, this is not working. The log inside /var/log/ says: '/dev/sr0' is not a directory, when connecting to [cdrom] (I've renamed [public] to [cdrom]) Jul 29, 2011 at 19:01
  • Changing /dev/cdrom into /mnt/cdrom (or whatever the mountpoint is) solves the issue. Aug 1, 2011 at 21:12
  • How do you unmount the cdrom though once smb grabs it? like to replace it with another disc Aug 23, 2023 at 16:10
2

At first I thought about sharing the /dev/cdrom (actually, /dev/sr0) using either NFS or sshfs.

Then I tried that, and it does not work. Raw devices can't be shared using these technologies.

However, I can mount the cdrom somewhere (/mnt/cdrom and /media/cdrom are common places) and then share the mount point.

Using sshfs is easy to setup, as it doesn't require root permissions nor any configuration file. It's also "safe", as the file access permissions will be basically the same as the logged in ssh user. However, using NFS will lead to better performance (because it has less overhead, as it doesn't encrypt any data).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .