Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Dec 2014 22:04:38 -0800
From:      Alfred Perlstein <alfred@freebsd.org>
To:        Glen Barber <gjb@FreeBSD.org>
Cc:        Ryan Kois <ryan.kois@gmail.com>, hackers@freebsd.org, re@freebsd.org, Claudia Yadathi <yadathi@gmail.com>
Subject:   Re: How to make a FreeBSD vm in virtualbox.
Message-ID:  <24520431-8E2A-4D70-BD2D-D8D76A98C762@freebsd.org>
In-Reply-To: <20141231042455.GB53230@hub.FreeBSD.org>
References:  <13C55A7B-4010-40FA-901B-DF8ED6BADD87@freebsd.org> <20141231042455.GB53230@hub.FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--Apple-Mail=_19201FB0-3C19-4126-99BC-0191B1F7AE9C
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii


On Dec 30, 2014, at 8:24 PM, Glen Barber wrote:

> On Tue, Dec 30, 2014 at 07:42:36PM -0800, Alfred Perlstein wrote:
>> After he linked it to me, I decided that it would make sense if
>> this was scripted and would really make sense as part of the release
>> process.
>>=20
>=20
> We already provide VMDK images.  There is nothing, that I can see, =
that
> is different from how I've been testing the various images.  Creating
> a new VM and attaching the VMDK to the disk controller is the intended
> workflow.

The difference is that with a vmdk you must get the exact combinations =
of items correct or you will wind up with a FreeBSD instance that will =
not boot.  With the ova, you just run a single command "VBoxManage =
FreeBSD.ova" and stuff "just works", or you can even just double click =
on the downloaded file from within your OS X / Windows/ whatever host =
and it "just works".


>=20
>> I've written a script that will make a .ova that you can one-click
>> import into Virtualbox (and I think Fusion as well) here:
>>=20
>>  https://gist.github.com/splbio/84bd4d2122782e99fc5c
>>=20
>=20
> Can you send the script as an attachment?

Uh sure.  It's attached.

For updates you can check here:
=
https://github.com/splbio/freebsd-vmtools/blob/master/vbox/freebsd-vbox.sh=


or here via subversion:

svn co https://github.com/splbio/freebsd-vmtools/trunk

I moved it to its own repo now, for updates/pull requests.=20


>=20
>> What is the best way to get this made into part of the release
>> process so that we can get .ovas shipped as well.
>>=20
>=20
> I'm inclined to think this is an overkill solution, to be honest.

Here is why I strongly disagree.

Creating a proper .ova is fraught with small errors that easily turn =
users away.

The most simple thing, accidentally picking 32bit BSD, has bitten many a =
newcomer and just makes things unpleasant.

Please read through the blog post by Ryan on the EXACT config needed for =
FreeBSD to work correctly:
=
http://blog.kidicarus.cool/blog/2014/12/24/freebsd-guest-on-mac-osx-host-v=
ia-virtualbox/

It's tiring, long and easy to get wrong.=20

By reducing steps we make it easier for people to use FreeBSD in a =
virtual environment.

>=20
>> One final question, is there a possibility we could add some
>> changes to the image so that it auto-dhcp's an address?  Most people
>> who just download the image won't know to "dhclient em0" or even
>> what an "em0" is.
>>=20
>=20
> I think 'ifconfig_DEFAULT=3D"DHCP"' in rc.conf(5) is what you want.

Do we want this by default in all images?  (I would vote yes).

-Alfred


--Apple-Mail=_19201FB0-3C19-4126-99BC-0191B1F7AE9C
Content-Disposition: attachment;
	filename=freebsd-vbox.sh
Content-Type: application/octet-stream;
	x-unix-mode=0755;
	name="freebsd-vbox.sh"
Content-Transfer-Encoding: 7bit

#!/bin/sh

# Make freebsd vm

# fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/VM-IMAGES/10.1-RELEASE/amd64/Latest/FreeBSD-10.1-RELEASE-amd64.raw.xz

VM="FreeBSD10"
RAW_IMG="$1"

set -e
if VBoxManage list vms | sed -e 's/^"//' -e 's/".*//g' | grep "^${VM}\$" ; then
    echo "VM '$VM' already exists.  delete? (y/N)"
    read resp
    if [ "$resp" = "y" -o "$resp" = "Y" ] ; then
	VBoxManage unregistervm "$VM" --delete
    fi
fi

if echo "$RAW_IMG" | grep -q '.vmdk' ; then
    # remove .vmdk -> .2.vmdk
    VMDK_IMG="${RAW_IMG%.vmdk}.2.vmdk"
    echo copying "$RAW_IMG" to "$VMDK_IMG"
    set -x
    cp  "$RAW_IMG" "$VMDK_IMG"
    import_vmdk="false"
else
    set -x
    BASE_IMG="${RAW_IMG%.raw}"
    VMDK_IMG="${BASE_IMG}.vmdk"
    import_vmdk="true"
fi

OSTYPE="FreeBSD_64"
OVA_IMG="${VM}.ova"
set -x

rm -f "${OVA_IMG}"

# storage controller
STORAGE_CONTROLLER_NAME="IDE Controller"
if $import_vmdk ; then
    rm -f "${VMDK_IMG}"
    VBoxManage convertfromraw "${RAW_IMG}" "${VMDK_IMG}" --format VMDK
fi
VBoxManage createvm --name "$VM" --ostype "${OSTYPE}" --register
#VBoxManage storagectl "$VM" --name "SATA Controller" --add sata --controller IntelAHCI
VBoxManage storagectl "$VM" --name "${STORAGE_CONTROLLER_NAME}" --add ide --controller PIIX4

VBoxManage storageattach "$VM" --storagectl "${STORAGE_CONTROLLER_NAME}" \
    --port 0 --device 0 --type hdd --medium "${VMDK_IMG}"

VBoxManage modifyvm "$VM" --ioapic on --boot1 disk --memory 768 --vram 12
# XXX: NAT instead?  
VBoxManage modifyvm "$VM" --nic1 nat
VBoxManage modifyvm "$VM" --macaddress1 auto
# seems to be most stable NIC under virtualbox, might want to try virtio later?
VBoxManage modifyvm "$VM" --nictype1 82540EM

# Turn off PAE
VBoxManage modifyvm "$VM" --pae off

# Usb is nice too.  Makes it easier for user to later add pass-through.
VBoxManage modifyvm "$VM" --usb on

# sound is nice to have
case `uname` in
    Darwin) AUDIO="coreaudio" ;;
    FreeBSD) AUDIO="oss" ;;
    *) AUDIO="null" ;;
esac
# Might want to disable this line if we get errors loading the VM
# on hosts, problem is that there doesn't seem to be a way to just
# say "use the default driver that plays audio" instead you can only
# say "none" or "null" in a platform independent way.
VBoxManage modifyvm "$VM" --audio "$AUDIO"


VBoxManage modifyvm "$VM" --audiocontroller ac97

VBoxManage export "$VM" -o "${VM}.ova"

# Clean up the generated vm?
# VBoxManage unregistervm "$VM" --delete


--Apple-Mail=_19201FB0-3C19-4126-99BC-0191B1F7AE9C--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?24520431-8E2A-4D70-BD2D-D8D76A98C762>