Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save temap/6e4702a38a47e6a025e2ff3daea195f0 to your computer and use it in GitHub Desktop.
Save temap/6e4702a38a47e6a025e2ff3daea195f0 to your computer and use it in GitHub Desktop.
How to emulate USB flash drive in Linux

Emulating mass storage USB flash devices in Linux

Create a new disk image with space pre-allocation (4000 MBytes):

fallocate -l 4000M virtual_usb.img

Create Ext4 file system:

mkfs -t ext4 virtual_usb.img

Load the necessary modules:

sudo modprobe dummy_hcd
sudo modprobe g_mass_storage file=virtual_usb.img idVendor=0x8564 idProduct=0x1000 iSerialNumber=C71FFD58CDF9 iManufacturer="JetFlash" iProduct="Mass Storage Device" removable=true cdrom=false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment