7

How is possible to create virtual USB drive?

I found some examples, that they included some *.iso file into mount directory.

But i would like to create empty virtual USB drive with about 4 GB volume.

I am using Ubuntu GNOME 16.04 LTS.

Thank you

tomsk
  • 349
  • You can create empty FAT images and mount them in the same way as ISO images. You can't create "virtual USB drives", though: the image will be access through a loop device, not through an USB device. But of course you can copy a FAT image to and from an USB stick. – dirkt Dec 05 '16 at 15:12
  • @tomsk You may boot your linux with qemu on a rescue disk, and give it the img as a virtual usb device. But probably there are also better solutions. Next time write into your question that you want to trick some installers (because you've lost the original key for your legally bought software), so you question will be more clear. – peterh Sep 27 '17 at 16:18

1 Answers1

8

To create a virtual USB volume use the following steps:

Use fallocate to create a new file:

fallocate -l 4000M Virtual_usb.img

Format it:

mkfs -t ext4 Virtual_usb.img

Create a mount point:

mkdir /media/usb_mount_point

mount it:

mount -t auto -o loop Virtual_usb.img /media/usb_mount_point
GAD3R
  • 66,769