creating a virtual clone

Mike Tancsa mike at sentex.net
Mon Apr 6 19:00:37 UTC 2015


On 4/6/2015 1:43 PM, David Newman wrote:
> To test some new software, I'd like to replicate a 9.3-RELEASE machine
> and run it as a virtual machine (in this case inside VMware vSphere, but
> I'm open to using other hypervisors if this isn't possible with VMware).
>
> The 9.3 host is itself virtual, running as a VPS instance in a colo.
>
> What's the best way to do this?

Not sure the best way to convert directly to VMWare, but if you have a 
spare machine with VirtualBox on it, you can use its tools to create a 
.ovf file which you can then import. (there might be a similar tool on 
VMWare).

I just did one from dump files not too long ago. You could use dd, but 
the nice thing about dump is, you can size the disk to what you want.

truncate -s10G importfile.dd

mdconfig -t vnode -f importfile.dd


  gpart create -s mbr md0
  gpart add -t freebsd md0
  gpart set -a active -i 1 md0
  gpart bootcode -b /boot/mbr md0
  gpart create -s bsd md0s1
  gpart bootcode -b /boot/boot md0s1
  gpart add -t freebsd-ufs -s 1G md0s1
  gpart add -t freebsd-swap -s 1G md0s1
  gpart add -t freebsd-ufs -s 2G md0s1
  gpart add -t freebsd-ufs md0s1
  newfs -U -O1 /dev/md0s1a    #O2 for RELENG7 and above
  newfs -U -O2 /dev/md0s1d
  newfs -U -O2 /dev/md0s1e
  mkdir /mnt/root
  mkdir /mnt/usr
  mkdir /mnt/var
  mount /dev/md0s1a /mnt/root/
  mount /dev/md0s1d /mnt/var
  mount /dev/md0s1e /mnt/usr
  cd /mnt/root
  gzcat /backups/dump-root0.gz | restore -rf -
  cd /mnt/usr
  gzcat /backups/dump-usr0.gz | restore -rf -
  cd /mnt/var
  gzcat /backups/dump-var0.gz | restore -rf -

# You might need to adjust /mnt/root/etc/fstab to reflect the new locations

umount /mnt/root
umount /mnt/var
umount /mnt/usr
mdconfig -d -u -0

Then lets convert the file

VBoxManage convertfromraw importfile.dd target.vdi --format VDI

Now we create the VM and attach the disk. Easiest is through the web/gui 
interface
new VM
BSD
32bit BSD (or 64 if its a 64bit image)
Use existing HD, and point it to target.vdi
You can then export, or try importing the .vdi directly into vmware as a 
disk


	---Mike






-- 
-------------------
Mike Tancsa, tel +1 519 651 3400
Sentex Communications, mike at sentex.net
Providing Internet services since 1994 www.sentex.net
Cambridge, Ontario Canada   http://www.tancsa.com/


More information about the freebsd-questions mailing list