Skip to content

Instantly share code, notes, and snippets.

@harish2704
Created August 7, 2016 14:58
Show Gist options
  • Save harish2704/32c84105e0a117fb572bb85a8882b5f4 to your computer and use it in GitHub Desktop.
Save harish2704/32c84105e0a117fb572bb85a8882b5f4 to your computer and use it in GitHub Desktop.
Mount / Unmount a Virtualbox vdi image in linux
# Mount command
sleep 1; modprobe nbd
sleep 1; qemu-nbd -c /dev/nbd0 /path/to/image.vdi
sleep 1; mount /dev/nbd0p1 ~/u
# Below command to compress the entire mounted dir tree into a squafs filesystem
# mksquashfs u/ /path/to/image.squashfs -no-recovery -wildcards -e 'var/cache/apt/archives/*.deb' -e "home/user/Downloads/*" -e home/user/.cache -e home/user/.config/chromium
# Unmount command
# sleep 1; umount ~/u
# sleep 1; qemu-nbd -d /dev/nbd0
# sleep 1; modprobe -r nbd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment