Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
User Journal

Journal eno2001's Journal: TOPIC: Pop 3 (Pop it in the drive...) 2

Have you ever been frustrated that you've got a nice DVD drive in one Linux box and not the other and wished there was a way to have another box access it as if it were in the box itself? Me too. Our wishes have been granted. (We're not talking file sharing here or NFS. We're talking direct, low level access to a remote drive over the network as if it were in the box) Read on...

As many of my one or two readers know, I'm a HUGE fan of virtualization. I started out with VMWare pretty much from when they first went into business and moved to Xen within the past two years. One of the things I've been wanting to delve into is centralized storage at home for my Xen VMs. Much nicer to have everything in one place on a hardware RAIDed system that does automated nightly disk-to-disk backups and has automated off-site backups via rsync. Keep in mind that I'm just talking plain old home PCs here. Not enterprise level stuff at all. Anyone who knows their way around Linux really well can make this a reality at home and experience the multiple benefits (hardware cost savings, more efficient use of your computing resources, space savings,etc...) of virtualization. But this JE is NOT about virtualization. It's about something else entirely that I discovered and played with last night quite successfully and simply. I'll get to that in a bit.

While reading through the Xen documentation a few years ago, I saw that they mentioned that your VMs could have their storage backed by a variety of methods. One of the methods intrigued me. They mentioned something called NBD. I had no idea at that point, what that was. It stands for "Network Block Devices" and is part of Linux kernel. You can either build it into the kernel or as a module as is the norm. I use the 2.6 series kernels and the NBD support can be found here:

DEVICE DRIVERS-->BLOCK DEVICES-->Network Block Device Support

You also need the nbd-server and nbd-client software which can be found here: http://sourceforge.net/project/showfiles.php?group_id=13229. The main project page is here: http://nbd.sourceforge.net/. Most of what you need to know is in the README file included with the source code and in the man pages for nbd-server and nbd-client.

I was experimenting with NBD last night in order to begin moving ahead with my virtualization schemes for home using Xen and my new AMD64 with hardware virtualization support. And when I was reading the README file, I noted that they mentioned remote access to ANY kind of block device including CD-ROMs. Not just /dev/hdX or LVM logical volumes, which is all I was planning on doing. Then a crazy idea hit me. I thought, "Hmmm... can I actually use NBD to export my laptop's DVD drive to my Linux media center PC via wireless"? Turns out the answer is an emphatic YES! (Note I'm using 802.11g on the notebook) So here's kind of what I did:

1. Compiled in the NBD support on my media center and my notebook in module form
2. Did the usual ./configure --prefix=/usr/local && make && make install jig with the ndb source code from the NBD project page
3. Modprobed the nbd kernel module so that the kernel would recognize the NDB devices
4. Created the device nodes in /dev using the MAKEDEV nb0...nb10 commmands. That is to say that I typed: 'cd /dev ; MAKEDEV nb0 ; MAKEDEV nb1 ; MAKEDEV nb2 ; MAKEDEV nb3 ; MAKEDEV nb4 ; MAKEDEV nb5 ; MAKEDEV nb6 ; MAKEDEV nb7 ; MAKEDEV nb8 ; MAKEDEV nb9 ; MAKEDEV nb10' I don't know what the limit is but I'm sure there is one and it's probably in the source.
5. Then on the laptop I popped in a DVD and typed: 'nbd-server -r 2000 /dev/hdc' and did a ps to check and see if it was running. The syntax is: 'nbd-server [-r for read only filesystems like a commercial DVD] [port to run the export of this device on] [path to the device file of the device you want to export]'
6. On the media center PC I typed: 'nbc-client nc6220.mydomain.private 2000 /dev/nb0'. The syntax of the nbd-client command is: 'nbd-client [hostname or IP of the nbd server] [port that the remote device is being shared on] [local nbd device file to map to]'
7. I manually set the perms/owner/group on /dev/nb0 (I imagine that udev should take care of this once I get the proper rules in /etc/udev/rules.d in) jsut for this test.
8. I then ran Xine and configured it's DVD device to be /dev/nb0 instead of /dev/hdc (it does have an internal DVD drive, but since I moved the media center into the basement and the monitor/KB/mouse are all in the living room, it's awkward to use) and hit the DVD button to play back the DVD on it. It worked! It's ALIVE! ALIIIIIVE!!!!

My original plan with my media center was to get a USB DVD drive and plug it into the extension hub I have in the living room. But, we also keep a laptop next to the sofa all the time and it's wireless with a DVD drive in it. This solution is not only free and super cool (a wireless DVD player!) but on a pracitcal level it would look better than having a USB cable coming down from behind the wide-screen monitor to a DVD drive. If you've got questions, I'll try and answer them. For the security nuts out there, yeah, this is all totally insecure at the moment. But there is a way to limit the hosts that can access the NBD exported devices. I'll likely explore those features. My first order of business is to write up some scripting that will allow me to just pop a DVD into the laptop and have it automatically export the DVD drive and then automatically run Xine on the media center so it's as seamless as possible. Another script will unexport and then eject the DVD and I might actually put that on the media center PC so that the only thing the latop really seems like in this one respect is just a wireless DVD drive that you pop the DVD into.

When I got my crazy idea last night, I didn't think it would really work well if at all since I find wireless to be very slow compared to my gigabit network. I also expected that the data flow from the DVD drive would be somewhere areound 100 to 250 Mb/s. I guess I was wrong. I'm sure it wouldn't work on an 802.11b system. But I'll be damned if it doesn't work on 802.11g! The only glitch I had was at the very beginning of the movie after hitting the "Play" link from the DVD navigation menu. For about a second or two there was a slight pause and then the movie played smoothly for the next 30 minutes that I spent watching it. I honestly didn't expect it to work. Of course it totally sidetracked me from my virtualization project, but this was just TOO cool. My house is really starting to work out the way I want it to with the way I'm borgifying it. ;)

This discussion has been archived. No new comments can be posted.

TOPIC: Pop 3 (Pop it in the drive...)

Comments Filter:
  • That's a cool setup you have there. :) I'll keep that in mind as I'm bound to either find a use for that in the future, or try it out just for the heck of it.

    I really want to get into Xen VMs as well. I just recently made a major upgrade to my desktop though, and so I'm not ready to replace it or add another PC that has a processor with hardware virtualization. (Current desktop has an Athlon64 3700 clawhammer core proc in it - its still plenty fast enough for me).

    • by eno2001 ( 527078 )
      One thing I can say about it is that it's a lot easier to set up than I originally imagined. I pictured spending a couple of days trying to get it working right since I've had some things take a while to fully sink in. This is just TOO easy. :) So I've say "for the heck of it" is actually a good idea. The user space apps that do the exporting and importing are pretty small and only take a few minutes to compile and install. (I did it on a P4 ~2GHz system and a P4 Mobile laptop as well as a P3 800 all u

The opossum is a very sophisticated animal. It doesn't even get up until 5 or 6 PM.

Working...