Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

The reason I ask the question is because I would like to emulate a device or create a device (specifically a usb-device) on disk without connecting the physical device.

What I would like is to create a device such that it shows up in the lsusb output.

What I have tried so far is creating a file with dd and using losetup to connect the created file with a loop device (/dev/loop*). That however doesn't create a message in dmesg.

Edit:

As requested here's more info on my dilemma. I bought a USB-stick quite a while back with a language trainer that has limited it's execution (.exe)to the USB-stick. Since wine doesn't transfer the USB device data to the exe I was forced to use it in a VM. Since I use the stick on a VM, I thought I could emulate it on my host and go completely virtual - no need for the physical usb-stick.

share|improve this question
    
Have a look at the udevadm manpage, it may be of some help. –  aquaherd Oct 5 '11 at 22:21
    
@aquaherd That indeed was somewhat helpful. If I understood the manual right I think I can create kernel events. I'll get some more information on the sysfs so that I know what attributes to set when creating an event. If hope one of those attributes is a reference to a file that will represent the device's storage. –  UncleJack Oct 6 '11 at 13:37
    
Yes. you can't fake a non-existing device but you can persuade the system to re-detect plugged devices or fake/trigger their arrival and departure events. –  aquaherd Oct 6 '11 at 17:45

1 Answer 1

What you're looking for would be called a virtual USB device. I don't think the standard kernel contains anything like that.

Some virtual machines can emulate USB devices for the guest (as opposed to relaying data to a hardware USB device connected to the host). For example, KVM can emulate USB storage and human interface devices.

The gadget framework is a way for Linux devices to function as USB peripherals (USB is highly asymmetrical: devices and hosts do different things). There is also a usbnet driver to relay USB connections over Ethernet; you could use this and write a program that talks the Ethernet protocol.

Using these indirect methods will not necessarily be easier than implementing your own USB driver. If you choose to go that route, Linux Device Drivers (3rd ed.) is the book to read.

What you're asking is not likely to be easy. If you explain what your underlying problem is, someone may be able to suggest a better solution.

share|improve this answer
    
Hey thanks for the information. It delves deeper than I thought I'd have to go and I hope I won't have to do any coding. I'll edit my question's description to be more specific about my goals. –  UncleJack Oct 6 '11 at 13:42
    
@UncleJack Assuming the USB stick is an ordinary one and not a dual device with a built-in cryptographic module (these exist but tend to be used to protect $10,000-per-user software, not language trainers), what you need is specifically to emulate a USB storage device. KVM can do this out of the box (see my link). I don't think VirtualBox can do it, and I don't know about VMWare. –  Gilles Oct 6 '11 at 19:08
    
I'll fiddle around and see if I can get expected results. Ty –  UncleJack Oct 7 '11 at 8:14

Your Answer

 
discard

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.