Hi. I have some projects going in which I compile minimalistic Linux system components, copy them into disk image (.img) files, and then run the assembled system in qemu.
System assembly has been kind of like so:
1. Use dd to create empty image file
2. Use losetup to map image file to loop device
3. partition loop device with fdisk
4. use kpartx to map all partitions in loop device to /dev/mapper
5. copy in appropriate files to appropriate partitions
6. install grub or lilo on image through original loop device
The lame part of this whole setup, however, is that it requires root privileges. It is inconvenient to be working as root, and it is especially scary when running commands like fdisk.
On the Internet I found a program called
mountlo which supposedly can create loop devices from disk images without root privileges. (Through fuse). However, I have yet to find a userspace version of kpartx.
Anyone have any ideas that could help me out here?