Skip to content

Instantly share code, notes, and snippets.

@andreafortuna
Last active May 19, 2019 03:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreafortuna/69a075440037db9d0dcbb4c6f751d378 to your computer and use it in GitHub Desktop.
Save andreafortuna/69a075440037db9d0dcbb4c6f751d378 to your computer and use it in GitHub Desktop.
#!/bin/bash
#Simple script for VirtuaBox filesystem bodyfile creation
# Usage: vbfilesystembodyfile.sh <VM name>
disk=`echo $( sudo VBoxManage showvminfo $1|grep "vdi\|vmdk"|head -n 1|cut -d ":" -f 2|cut -d "(" -f 1)|xargs`
VBoxManage clonemedium $disk ./$1.raw --format=raw
offset=$(mmls $1.raw -a | grep `mmls $1.raw -a | grep "000:" | cut -d " " -f 9 | sort -r | head -1` | cut -d " " -f 6 | bc)
fls -o $offset -r -m / $1.raw > $1.bodyfile
rm $1.raw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment