Module 40 - Injecting Files¶
Historical miniclass
This lesson was recovered from the former Sandia minimega site. It is preserved for reference and may describe obsolete software, operating systems, commands, or external resources. Consult the current documentation before applying it.
Introduction¶
You can inject files into a HDD image without booting a virtual machine.
minimega¶
First let's take a snapshot of a disk:
If the destination name is omitted, a name will be randomly generated and the snapshot will be stored in the files/ directory. Snapshots are always created in the files/ directory.
To inject files into an image:
Each argument after the image should be a source and destination pair, separated by a colon (':'). If the file paths contain spaces, use double quotes. Optionally, you may specify a partition (partition 1 will be used by default):
You can optionally specify mount arguments to use with inject. Multiple options should be quoted. For example:
Disk image paths are always relative to the files/ directory. Users may also use absolute paths if desired.
Newer versions of minimega¶
In order to be namespace-aware, newer versions of minimega require that disk images be in the files/ directory (/data/mmfiles if booted using startMM.sh)
qemu-nbd¶
Manually you can inject files using QEMU Network Block Device mounts.
su -
modprobe nbd max_part=8
qemu-nbd --connect /dev/nbd0 linux.qcow2
mkdir -p /mnt/kvm
sudo mount /dev/nbd0p1 /mnt/kvm
echo "test" > /mnt/kvm/test.txt
sudo umount /mnt/kvm
sudo qemu-nbd --disconnect /dev/nbd0
Special Note¶
minimega is only able to inject files into images that do NOT use LVM.