Nu, szeretném megosztani veletek pár a VirtualBox VirtualDiskImage formátumához kapcsolódó scripteimet:
load_nbd:#!/bin/sh
if [ `lsmod | grep nbd | wc -l` != 0 ];
then
echo 'Already loaded.'
else
modprobe nbd max_part=$1
fi map_vdi:#!/bin/sh
if [ ! -f "$2" ];
then
echo "File does not exists."
exit
fi
qemu-nbd -c "/dev/nbd""$1" "$2"
partprobe "/dev/nbd""$1" copy_nbd_to_disk:#!/bin/sh
dd if="/dev/nbd""$1" of="/dev/sd""$2" bs=16MiB status=progress unmap_vdi:#!/bin/sh
qemu-nbd -d "/dev/nbd""$1" unload_nbd:#!/bin/sh
if [ `lsmod | grep nbd | wc -l` != 0 ];
then
while [ `lsblk | grep nbd | wc -l` != 0 ];
do
qemu-nbd -d "/dev/""$(lsblk | grep nbd | head -n 1 | cut -f 1 -d " ")"
done
rmmod nbd
else
echo 'Not loaded.'
fi |