Skip to content

Instantly share code, notes, and snippets.

@lemartinet
Created February 16, 2017 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lemartinet/48737ab847cc772e137fac2b88497b32 to your computer and use it in GitHub Desktop.
Save lemartinet/48737ab847cc772e137fac2b88497b32 to your computer and use it in GitHub Desktop.
Creating a virtualbox image over network
# Set up source machine
0. Optional, ssh support and lzo
sudo bash
add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe"
apt-get update
apt-get install ssh lzop
1. Boot Ubuntu USB stick
2. Run fdisk -l to figure out which drive to clone and how many bytes it has
Example:
Disk /dev/sda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders, total 78165360 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x1744b9d1
Device Boot Start End Blocks Id System
/dev/sda1 * 16065 78156224 39070080 7 HPFS/NTFS/exFAT
# Send the dd over network
On target:
nc -l 7777 | gzip -d | VBoxManage convertfromraw stdin remote.vdi 40020664320
nc -l 7777 | bunzip2 -vvv | VBoxManage convertfromraw stdin remote.vdi 40020664320
nc -l 7777 | lzop -d | VBoxManage convertfromraw stdin remote.vdi 40020664320
alt if you just want dd. nc -l 7777 | bunzip2 -vvv > remote.dd
On source:
dd bs=16M if=/dev/sda | gzip | nc 192.168.7.188 7777
dd bs=16M if=/dev/sda | bzip2 -vv9 | nc 192.168.7.188 7777
dd bs=1M if=/dev/sda | lzop | nc 192.168.7.188 7777
# Monitoring omn source
pgrep -l '^dd$'
watch -n 10 kill -USR1 PID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment