Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Here's the situation. I have a video device /dev/video0 on a VMware Server and I want to access this device from within a virtual machine. However for whatever reason I can't connect the device directly to the VM, it must be connected to the host.

Since under unix philosophy everything really is just a file, can I share a device under /dev using NFS, Samba, sshfs or some other protocol between two hosts, so that a linux on one server can access devices on a different server?

share|improve this question
One of the few cases where my first thought is: "This would be easier if you were using Plan 9" –  Steven D Dec 18 '10 at 20:16
@Steven D: That was essentially my first thought as well :-) –  SamB Dec 19 '10 at 6:25
add comment

2 Answers

up vote 6 down vote accepted


You can export a device file through NFS or some other network filesystems. But the meaning of the device file is dependent on the machine where you open it. If you export /dev/video0 over NFS from a server machine to a client machine, the client machine just sees “character device 81:0”, and interprets it as its own video capture device. The client machine doesn't even need to have the same device number assignment as the server; for example an OpenBSD client would see the same file as the pseudo-terminal driver, because that's what char 81:0 is under OpenBSD.

What you're asking for would be very nice, but also very hard. Every request on the client would have to be forwarded to the server and vice versa. There would have to be specific support in individual drivers. For example some drivers rely on shared memory between the process and the kernel, and supporting transparently across the network would be hard and prohibitively expensive in many cases. I don't know if the video capture driver does use shared memory, but given that it's likely to transfer large amounts of data asynchronously, I expect it to.

Linux has some specific support for network block devices. They do not rely on a network filesystem; the device file exists only on the client, and a daemon on the server emulates a physical block device (it might relay the operations to and from a real physical device, but often it reads and writes to an image file).

You should look for a solution that's specific to video capture. Try to run as much of the data-intensive part on the machine to which the physical device is attached. Or find a virtual machine solution that supports direct access to the physical device from inside the virtual machine (I don't know if any host/guest solution does; hypervisor-based solutions are more likely to).

share|improve this answer
Network block device. Thanks for that tip! Exactly what I was searching for. It's a great way to kinda dd a disk to another machine without using a screwdriver. –  Christian Mar 8 at 14:18
@Christian ssh root@othermachine cat /dev/sdb >/dev/sdc –  Gilles Mar 8 at 14:25
I know it's stupid but somehow I don't trust cat with important binary data. Must be some deeply buried trauma that I don't consciously remember. And no, I'm not a dog person; that's not it. –  Christian Mar 8 at 14:55
@Christian Some older Unix systems had text processing tools that didn't treat binary data correctly, but I doubt that ever applied to cat, and in any case cat will work on all current systems. GNU utilities (the ones on Linux) have always treated binary data correctly, it was a design goal from the start. The use of dd for binary data is a habit inherited from the days of magnetic tapes; on contemporary Linux systems, not only is it a needless complication, it even tends to be slower. –  Gilles Mar 8 at 15:11
Ok, maybe I will actively work against my irrational objections then ;) –  Christian Mar 8 at 15:17
add comment

In addition to Gilles answer - as long as you do not intend to do ioctls on file it is simply a stream. So if you ran from guest

# mkfifo /dev/fakevideo0
# ssh host cat /dev/video0 > /dev/fakevideo0

/dev/fakevideo0 will behave as a buffor so if you read from it you will get stream from camera.

share|improve this answer
Would this procedure work for dual way communications? For instance I would like to do this with a serial port. –  portforwardpodcast Feb 5 at 1:10
@portforwardpodcast I don't think it will work straightforwardly - you would probably need to wrap it in unix pipe so you might need to write a program/script on both sides. –  Maciej Piechotka Feb 5 at 1:24
Thanks for the feedback. I just found this page which works great for dual direction serial over tcp/ip dest-unreach.org/socat/doc/socat-ttyovertcp.txt –  portforwardpodcast Feb 5 at 2:27
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.