I need a way, in Ubuntu 10.04, to simulate a USB flash drive insertion, such that the udev subsystem is notified of the insertion and can invoke rules to mount the filesystem and execute external scripts.

I've read a detailed tutorial on how to write Linux device drivers, which delves into writing a RAMdisk, but that virtual device doesn't have any parent device listings from udevadm, and so doesn't look like a USB device. A post over here suggests that I'd have to write a virtual USB root hub.

Note that I'm not married to having a virtual USB drive tied to a RAMdisk; I'd be just as happy redirecting the virtual drive to an on-disk folder. This will be used to Squish test the USB-centric features (insertion/removal/read/write) of an embedded application. The application monitors the udev subsystem to figure out where it should read/write data to the removable media, and some custom rules are configured to look specifically for USB removable media, so it's important for the simulated device to look like a real USB device to udev.

Questions: If I need to write a virtual USB root hub, could anyone point me to a tutorial to do that?
If that's not necessary, what are the next steps to extend the above-linked RAMdisk tutorial to appear as a USB mass storage device?

Thanks in advance for you responses.

  • Which architecture? Is this for an embedded project? – eepp Sep 12 '13 at 20:35
  • Yes, this is for an embedded project - we're using WindRiver linux on-target. However, we use Ubuntu in a VMPlayer VM to simulate the target and host the application, and that is the environment in which we Squish test, so the solution space would actually be in 32-bit Ubuntu. – dpmott Sep 16 '13 at 20:27

Your Answer


Browse other questions tagged or ask your own question.