Use a device over SSH?

Posted on

Problem :

I have 2 PCs with Ubuntu at home and a network link between them.

If I do

 $ sshfs pc2root@ /media/pc2

can I use a remote device as a local one? (in this case: /media/pc2/dev/sr0 as a local DVD-RW). In the end, everything in Unixes is a file, right?

I did

 culebrón@culebrón:/dev$ sudo ln -s /media/pc2/dev/sr0 dvdrw

but without a success: Brasero and K3b don’t see any DVD device.

I know, for most tasks, SSH and sshfs are more than enough, but would like to know if there’s a general solution.

Solution :

SSHFS does not work that way — it handles files, but not devices. Everything is a file, but there are many types of files, including: regular files, directories, symbolic links, sockets, character devices, and block devices.

% ls -l /dev/sda
brw-r----- 1 root disk 8, 0 Oct  9 20:59 /dev/sda

The letter b indicates this is a block device. These types of files support ioctl in addition to the normal read and write functions. The purpose of ioctl is to allow a way to do “extra” operations to the device. These operations are different for each type of device: a DVD device can open/close its door, but an ethernet device cannot.

This is why the SSHFS software cannot make device files available over the network.

You will need a different system that is made for this purpose, something like webCDwriter.

If you want to remotely access a block device, there is such a tool called ‘nbd‘ (Network Block Device). I have used this in the past to clone a harddrive using dd if=/dev/nbd0 of=/dev/hda with reasonable success.

However, I doubt this will work for optical drives.

I think you’d be better off running the burning software locally on the remote machine (say with X or VNC), and have it pull files using regular file sharing mechanisms like samba or NFS.

Linux/UNIX are not Plan 9. “Everything is a file” doesn’t mean that they’re all the same sort of files. FIFOs and device nodes being prime examples.

No, you cannot do it this way. My recommendation would be to use a virtual writer (celebron writes to an image, .iso or other) and pipe that to cdrecord over ssh.

Brasero and K3b don’t see a DVD device because your local computer’s OS kernel doesn’t see a DVD device.

Mounting filesystems remotely is easy; there are network protocols like CIFS, NFS, AFS, and even SSHFS to handle all the details of file access. But low-level device access is a different animal — note that none of these protocols would allow, for example, repartitioning or reformatting the filesystem being accessed.

You would need a low-level protocol like iSCSI, FCoE (Fibre Channel over Ethernet), or ATAoE (ATA over Ethernet) to do what you want to do. This would involve driver-level software on the remote device to export the device, and driver-level software on the local device to attach to it. There’s Windows software called Starport that claims this capability, and a Linux-iSCSI site that may give you more information about what’s currently possible.

But generally, these technologies are used in corporate data centers with expensive hardware. For general home use, you really want to run Brasero on your remote computer and just display the GUI window on your local system (via X, VNC, or some other remote desktop technology).

Leave a Reply

Your email address will not be published. Required fields are marked *