LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (http://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Access remote USB as local USB (http://www.linuxquestions.org/questions/linux-hardware-18/access-remote-usb-as-local-usb-4175438812/)

Felipe 11-26-2012 03:29 PM

Access remote USB as local USB
 
Hello:

I've an Avermedia DVB-T, which connect to a remote computer using USB.
The computer where is connected is very slow, so I try to access the remote usb as if it where a local usb.
I've found different solutions as:
- usbredirectserver: But I've not found a usbredirect client. I see it can be used by virtual machines like QEMU, but don't know if there is a program which access the remote usb and offers it to applications as if it were local.
- USB network gateway. But it's no free.
Can any tell an easy way to access remote USB devices as if they were local?

Thanks

jschiwal 11-27-2012 08:38 AM

You could use NBD (network block device). It won't speed up the USB drive, but you may see faster access with nbd over NFS.

jefro 11-27-2012 03:05 PM

I agree that the base system is still the weakest point. How can one overcome that by further using remote access which will consume more resources?

Felipe 11-27-2012 05:54 PM

Thanks for the answer.

I've installed nbd-server and nbd-client and configured server with:
Quote:

/etc/nbd-server# cat config
[generic]
# If you want to run everything as root rather than the nbd user, you
# may either say "root" in the two following lines, or remove them
# altogether. Do not remove the [generic] section, however.
# user = nbd
# group = nbd
allowlist = true
user = root
group = root
includedir = /etc/nbd-server/conf.d

# What follows are export definitions. You may create as much of them as
# you want, but the section header has to be unique.
[dvr0]
exportname = /dev/dvb/adapter0/dvr0

[demux0]
exportname = /dev/dvb/adapter0/demux0

[frontend0]
exportname = /dev/dvb/adapter0/frontend0

[net0]
exportname = /dev/dvb/adapter0/net0
Accessing from client, now I can see:
Quote:

linux-b2rk:/dev/dvb/adapter0 # nbd-client -l raspberrypi
Negotiation: ..
dvr0
demux0
frontend0
net0
I've created manually on /dev directories dvb/adapter0.
But if try to connect, I receive a message and nothing happens:
Quote:

nbd-client raspberrypi /dev/dvb/adapter0/dvr0 -name dvr0
Negotiation: ..
dvr0
demux0
frontend0
net0
File is not created. If I create a regular file, then I receive:
Quote:

touch dvr0
linux-b2rk:/dev/dvb/adapter0 # nbd-client raspberrypi /dev/dvb/adapter0/dvr0 -name dvr0
Negotiation: ..size = 16384MB
Error: Ioctl/1.1a failed: Inappropriate ioctl for device

Exiting.
So, what can I do?

jschiwal 11-27-2012 06:44 PM

Share the block device for the USB file system instead e.g. /dev/sdb1 instead. Using the /dev/disk/by-uuid/ device symlink might be better. You might want to use udev rules to create and destroy the nbd device on the server side if it is removable.

Look at the simple example at the bottom of the "man 5 nbd-server" man page.
http://manpages.ubuntu.com/manpages/...-server.5.html

jefro 11-28-2012 03:14 PM

Let us know how well this works. I assume you are trying to use a low power system some place where you can get tv and then moving the use to a different location. I have considered such a plan but never attempted your way.

Felipe 11-28-2012 05:43 PM

Hello:

I'd like to come back and put the solution, but go on with questions (I use to put solutions to my questions when I find them).

I've never used nbd-sever or nbd-client so I've installed both packages on the same computer and tried with something simple. Ex: A file containing a disk image. Serve it with nbd-server, access it with nbd-client. I mount it on "/root/dirdisco/mnt" for nbd-server and "/root/dirdisco/mnt2" for nbd-client.

What I've done:
-Created a file for the disk:
Quote:

mkdir /root/dirdisco/disco.img
mkfs -t ext3 /roo/dirdisco/disco.img
- Configured nbd-server to server it. This is the configuration file:
Quote:

[generic]
# If you want to run everything as root rather than the nbd user, you
# may either say "root" in the two following lines, or remove them
# altogether. Do not remove the [generic] section, however.
# user = nbd
# group = nbd
allowlist = true
oldstyle = true
user = root
group = root
includedir = /etc/nbd-server/conf.d

# What follows are export definitions. You may create as much of them as
# you want, but the section header has to be unique.
[AverTv]
exportname = /dev/bus/usb/001/006
port = 1234

[Disco]
exportname = /root/dirdisco/disco.img
port = 1235

- Started nbd-server
Quote:

/etc/init.d/nbd-server start
- In the same computer (to be sure there is no problem with nbd-server and nbd-client releases), I've configured nbd-client:
Quote:

NBD_DEVICE[0]=/dev/nbd0
NBD_TYPE[0]="f"
NBD_HOST[0]="raspberrypi"
NBD_PORT[0]="1235"

- Started nbd-client
Quote:

/etc/nbd-client start
- I can see devices
Quote:

nbd-client -l raspberrypi
Negotiation: ..
AverTv
Disco
- Now, I mount the disco.img on directory /root/dirdisco/mnt and /dev/nbd0 on mnt2 as you can see:
Quote:

#mount
...
root/dirdisco/disco.img on /root/dirdisco/mnt type ext2 (rw,relatime,sync,dirsync,user_xattr,barrier=1)
/dev/nbd0 on /root/dirdisco/mnt2 type ext2 (rw,relatime,user_xattr,barrier=1)
- If I write something on mnt, I doesn't appear on mnt2. I've to umount /root/dirdisco/mnt2 and mount it again and files created/deleted are reflected in mnt2. But I've to umount/mount mnt2 to update directory (mount -o remount doesn't update files).

So something is wrong or I don't understand nbd. I've also tried with "sync" command, but files modified on mnt are not reflected on mnt2.

Whats wrong?

Thanks

Felipe 11-29-2012 04:23 PM

nbd-server and nbd-client don't work
 
Hello again:

I've repeated the same process, but instead of using raspberrypi with Raspbian, I've used my laptop with OpenSuse 12.2.

I mount the disk image with nbd-server and just from the same computer, I can list it with
Quote:

nbd-client -l mylaptop
Something strange is that Disco1 is listed twice:
Quote:

nbd-client -l mylaptop
Negotiation: ..
Disco1
Disco1
Now, I try to connect nbd-server and nbd-client:
Quote:

nbd-client -N Disco1 mylaptop /dev/nbd0
But then I can see this error in messages:
Quote:

Nov 29 23:09:59 mylaptop kernel: block nbd0: Receive control failed (result -32)
Nov 29 23:09:59 mylaptop kernel: block nbd0: shutting down socket
Nov 29 23:09:59 mylaptop kernel: block nbd0: queue cleared
And unable to mount /dev/nbd0
Quote:

mount /dev/nbd0 mnt2
mount: /dev/nbd0: can't read superblock
Please, can any give me an example of nbd on OpenSuse 12.2 (or raspbian) than works.

Thanks


All times are GMT -5. The time now is 05:50 AM.