We're trying to build a customized installation stick for putting linux on our embedded product. We're wanting to build it from scratch every time -- that is, pull RPMs out of a (local) repository.

All of the mechanisms we've used to date require us to have a physical USB stick in the build system at build time. For a variety of reasons, this is painful.

What we'd really like to do is build an image (i.e., a file) that can later be copied to a physical device (e.g., a la dd to a USB stick).

We've toyed with using a virtual machine (Virtual Box) to spoof things, but haven't been able to figure out how to make a virtual USB stick appear there.

What's a good way to create an image of the stick without the stick? It's acceptable that as a "finishing touch", some magic sectors have to be tickled -- that's something that can be quickly done at stick-population time. But waiting for a complete system generation is way too long for our scenario.

[If it matters, we're using FC 7 as our base -- it's stable and, more importantly, our drivers all work with that kernel]

1 Answer 1


These easiest way is with a loopback device. Make a file the size of your USB stick, then use losetup to map it to a loop device. Then the loop device is a block device, so it acts exactly like a USB stick would.

The only exception is partitioning. But you can fix that by a few more losetup calls to map your partitions to other loop devices with the offset (-o) parameter. Things work pretty much as everything expects if you map the full device to loop0, the first partition to loop1, second to loop2, etc. You can always symlink loop0 to loop, then the names are exactly like a partitionable block device would be (There are patches floating around for partionable loopback devices, so you may not even need to do this).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .