# VirtualBox



## balanga (Dec 9, 2017)

I'm thinking of installing VirtualBox and wondered if anyone could offer opinions/advice on how easy it is to set up and use, what are the hardware requirements and how well would a guest OS such as Windows 7 perform?


----------



## Sensucht94 (Dec 9, 2017)

Aside from the lack of 3D acceleration for guests, in my experience VirtualBox in FreeBSD as host performs exactly as it does on Linux and OS X. Whether or not installing a Desktop Workstation as VM can be a good idea, largely depends on your hardware. For something like Win7 I'd suggest at least 6Gb ddr3/4 (to share half). OpenSuSE Leap as host on my desktop (i5 7700+8gb RAM ddr4 + Nvidia 1060 6Gb) is incredibly fast, I couldn't even tell it were a VM if I hadn't known it first. Os opposite on my cheap 2009 laptop, with a 2 Core Pentium, and 3 Gb RAM ddr2, the only things I can run well are FreeDOS and 9front, but this wouldn't change if I were in Linux.


----------



## PacketMan (Dec 10, 2017)

I didn't find VirtualBox too hard at all but performance on my older server hardware was poor.  After some researching, and I'm a virtual machine amateur, I came to understand your CPU needs some 'vm hardware extensions/features'.  In Intel CPUs it would be:

Intel® Virtualization Technology (VT-x) ‡ Yes
Intel® Virtualization Technology for Directed I/O (VT-d) ‡ Yes
Intel® VT-x with Extended Page Tables (EPT) ‡ Yes

I've yet to research but I'm guessing in some applications with virtual machine this feature can be beneficial:
 Intel® Hyper-Threading Technology ‡ Yes

You can use the Interl ARK web site to find this sort of information on a per CPU bases. They really do a good job providing CPU specs.


----------



## balanga (Dec 10, 2017)

I was thinking of installing it on the 256GB mSata card in my i7 ThinkPad x220 which 8GB of RAM.

I'll see if there is anything in its BIOS regarding Intel® Virtualization Technology...


----------



## balanga (Dec 10, 2017)

Sensucht94 said:


> OpenSuSE Leap as host on my desktop (i5 7700+8gb RAM ddr4 + Nvidia 1060 6Gb) is incredibly fast, I couldn't even tell it were a VM if I hadn't known it first.



What's so special about OpenSuSE?


----------



## scottro (Dec 10, 2017)

Without presuming to speak for Sensucht94, my impression is that they meant that OpenSUse in their machine, as a VirtualBox guest, runs so well that if they didn't know it was a VBox guest, they would think it's bare metal.


----------



## miker (Dec 11, 2017)

For the lazy https://ark.intel.com/

The only issue is finding the right hardware, to begin with. You need to know the generation a CPU is from for example. Nice info once you find the product though.

Is there a FreeBSD equivalent to `cat /proc/cpuinfo` from the Linux world?


----------



## aragats (Dec 11, 2017)

balanga said:


> I'm thinking of installing VirtualBox and wondered if anyone could offer opinions/advice


Do not expect using USB 2/3 devices with VirtualBox guests since the Extension Pack (which provides USB passing-through) is not supported in FreeBSD.


balanga said:


> how well would a guest OS such as Windows 7 perform?


It performs very well if your hardware supports virtualization and it's enabled (check you BIOS: VT-x or AMD-V).


----------



## Sensucht94 (Dec 12, 2017)

balanga said:


> What's so special about OpenSuSE?





			
				scottro said:
			
		

> my impression is that they meant that OpenSUse in their machine, as a VirtualBox guest, runs so well that if they didn't know it was a VBox guest, they would think it's bare metal


Yes, exactly, thanks scottro 


			
				aragats said:
			
		

> It performs very well if your hardware supports virtualization and it's enabled (check you BIOS: VT-x or AMD-V)


Yes, sorry for not having pointed that out. Actually balanga Vt-x is required only for 64-bit guests, but in any case, with Vt-x enabled, performance boost is relevant and couldn't be more evident, and I wouldn't run a modern graphical guest If I hadn't a UEFI with Vt-x support. Virtualization for I/O, Vt-d, is supported by Virtualbox as well, but I've never tried doing something related to it in Vbox (like VGA passthrough), whereas had it enabled under bhyve in order to passthrough my PCIe  Wireless Internal NIC.



miker said:


> Is there a FreeBSD equivalent to `cat /proc/cpuinfo` from the Linux world?


To check whether CPU supports Vt-x  or not, you can look into dmesg: `cat /var/run/dmesg.boot | egrep CPU`. If available, there should be a string dedicated to VT-x support, while eventual EPT availability should be listed under "features"
In macOS I would check this with `sysctl machdep.cpu.features`, but I don't know if such a machdep variable is available under FreeBSD


----------



## p3rj (Dec 12, 2017)

miker said:


> Is there a FreeBSD equivalent to `cat /proc/cpuinfo` from the Linux world?


You could try sysutils/lscpu. For my system, the output is 
	
	



```
Architecture:            amd64
Byte Order:              Little Endian
Total CPU(s):            8
Thread(s) per core:      2
Core(s) per socket:      4
Socket(s):               1
Vendor:                  GenuineIntel
CPU family:              6
Model:                   94
Model name:              Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
Stepping:                3
L1d cache:               32K
L1i cache:               32K
L2 cache:                256K
L3 cache:                8M
Flags:                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 cflsh ds acpi mmx fxsr sse sse2 ss htt tm pbe sse3 pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline aes xsave osxsave avx f16c rdrnd fsgsbase tsc_adjust sgx bmi1 hle avx2 smep bmi2 erms invpcid rtm fpcsds mpx rdseed adx smap clflushopt intel_pt syscall nx pdpe1gb rdtscp lm lahf_lm lzcnt
```
Though for a quick check, using `grep` as suggested by Sensucht94 is probably sufficient.


----------



## balanga (Dec 12, 2017)

Sensucht94 said:


> In macOS I would check this with `sysctl machdep.cpu.features`, but I don't know if such a machdep variable is available under FreeBSD




```
sysctl machdep.cpu.features
sysctl: unknown oid 'machdep.cpu.features'
```


----------



## Phishfry (Dec 12, 2017)

Try this: `dmesg | grep Feature`


----------



## aragats (Dec 12, 2017)

Phishfry said:


> Try this:  dmesg | grep Feature


The lines are "broken", you should add `-A1` (1 line after as well):
`dmesg | grep -A1 Feature`


----------



## balanga (Dec 13, 2017)

aragats said:


> The lines are "broken", you should add `-A1` (1 line after as well):
> `dmesg | grep -A1 Feature`




`dmesg | grep -A1 Feature`

```
Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0x1fbae3ff<SSE3,PCLMULQDQ,DTES64,MON,DS_CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,TSCDLT,AESNI,XSAVE,OSXSAVE,AVX>
  AMD Features=0x28100000<NX,RDTSCP,LM>
  AMD Features2=0x1<LAHF>
  XSAVE Features=0x1<XSAVEOPT>
  VT-x: (disabled in BIOS) PAT,HLT,MTF,PAUSE,EPT,UG,VPID
```

This is on a ThinkPad T420.


----------



## aragats (Dec 13, 2017)

balanga said:


> VT-x: (disabled in BIOS)


So go into BIOS and enable it!


----------



## hedwards (Dec 15, 2017)

balanga said:


> I'm thinking of installing VirtualBox and wondered if anyone could offer opinions/advice on how easy it is to set up and use, what are the hardware requirements and how well would a guest OS such as Windows 7 perform?


It works very well on my system. I forget when I put my current system together, but it's years old at this point. Just make sure you've got plenty of RAM and give it a processor core or two.  At this point having enough RAM to give to the VM and have available to the system is probably a bigger issue than processing power is.

On my machine, I've found that the disk i/o stalls unless I check the box for using the host machine's cache and there's no support for usb 2.0 or 3.0

Personally, I use React OS whenever possible as it's much faster, but I do use Windows 7 for some things and it's generally pretty stable and reasonably speedy.


----------



## balanga (Dec 15, 2017)

Can anyone say if the FreeBSD Handbook Chapter is uptodate as far as Virtual Box goes?


----------



## hedwards (Dec 15, 2017)

balanga said:


> Can anyone say if the FreeBSD Handbook Chapter is uptodate as far as Virtual Box goes?


Skimming through it, I don't see anything out of date about it.


----------



## linux->bsd (Dec 19, 2017)

balanga said:


> Can anyone say if the FreeBSD Handbook Chapter is uptodate as far as Virtual Box goes?



If you have Bhyve enabled, you'll need to unload its kernel module or VirtualBox won't start a VM: `kldunload vmm`. You might then need to load VirtualBox's modules: `kldload vboxdrv vboxnet`. Or you can simply make the /etc/rc.conf mods listed in the Handbook, comment out the /boot/loader.conf line loading vmm.ko, and reboot.


----------



## Snurg (Dec 19, 2017)

balanga said:


> This is on a ThinkPad T420.


Just in case your question is about installing Vbox on a T420...
I have a T420 (no Nvidia) and I can confirm that VirtualBox performs very well (Windows 10 client).
However, resume fails after suspend if Vbox is running. 
And I didn't remember do any special things except following the post-installation instructions of Vbox.


----------



## max21 (Dec 23, 2017)

balanga said:


> I'm thinking of installing VirtualBox and wondered if anyone could offer opinions/advice on how easy it is to set up and use, what are the hardware requirements and how well would a guest OS such as Windows 7 perform?



I been using Virtualbox since learning how to install it (it took a year after it was invented for FreeBSD).   From that that I never had a issue with it.  I even installed the official Windows 7- Upgrade DVD inside a empty Virtualbox … it took as a full RELEASE of Windows-7 

Windows inside of Virtualbox don’t have no memory problems what-so-ever.  So give it all you can and if the memory runs out memory, no big deal … a large pagefile.sys works faster and better in Virtualbox then on a regular install of Windows on its own partition.  I use bridge-mode so that all Virtual-Machines will have its own. … never had a problem and this is a older FreeBSD Virtualbox I think.  Also FreeBSD-vm on FreeBSD-host is clean and mean; and it returns every drop of memory once that VM is shutdown.

```
virtualbox-ose-4.3.38_1
virtualbox-ose-kmod-4.3.38
```
Just in case you don't know, you install Oracle VirtualBox Guest Additions in Windows.

Anyway, here are the only issues I know of.  If you are copying big files, or using dd + gzip on large files, or moving large files on the host, Windows or any other VM will nearly freeze as you try to work in it.  So wait until the host is finish with those type things.  Using dd along and using most other stuff on the host don’t suffer from this.  For instances, The host can dd if=/dev/zero of=/dev/ada1 bs=64k my entire 500GB backup drive as I do anything inside of any vm with no noticeable slow-down what-so-ever.  That's why I like dd...   making it clean as a whistle as I work.  The best way would be to have 2 hdd's and you will never feel a thing, or nothing you can't handle as you work inside another VM.

```
dd if=/dev/ada0s14 of=/dev/ada1s14 bs=64k - backing up FBSD-2
```
Also, when you delete or do something in an opened folder it sometime may still be there, or something like that.  If it happen, you have to close the folder then open it back up to see it.  I thinks this happen when using shared-folders (virtual-drives).  This might not be the case with newer versions of Virtualbox, but it don’t worry me.  Sometimes, I simply re-open to check.

don't use *Host I/O cache*
don't use *I/O APIC*

. . . if you do, maybe it can solve one of those problems above but it may present another.  I forgot why I don't use Host I/O cache other then total separation.  I fear it may expose the host.  Whatever the case, I don't care.  I believe its a documented fact that if one check I/O APIC then you are stuck with it!  Un-checking will do nothing for you after any version of Windows has been installed on *vBox*.  So do your own testing for each.  It's worth it!


I think it might run well as a small/private productions server without GUI.  Anyway, I dump Windows-7 and Windows-10.  I only use my original XP-vm created on FreeBSD-8.2.  Now that a _long-time-running_ and vBox have never let it down, and I see no differences in speed vs. non-virtual.

EDIT:
I best to correct my every drop statement . . .  I simply look at the top Free value on the host and if it's not 10G _in my case_ when I shutdown my FreeBSD vBox; I never hesitate to restore from backup, because I know I did something wrong or that a process could have broke/stuck-in the VM, such as running a super-intensive rm, mv, or cp.  But if a FreeBSD vBox ever crash, it’s toasted anyway.  Whatever the case, get your most previous work out of there _if possible_ by way of USB, then restore immediately and go figure later.  Never create a crappy backup?

*It can't get better then this:  on 16GB Memory*

```
272-Active  236-Inactive   5892-Wired  404-Buf    9011M-Free    FreeBSD vBox Running
 12-Active    2-Inactive     16-Wired    0-Buf      10G-Free    Memory retain after shutdown
```
I always have Windows-XP vm -- with everything needed open in it -- running first so that I can measure my most active FreeBSD vm from there.
.


----------



## balanga (Jan 10, 2018)

Given the positive feedback about how well Windows performs under VirtualBox, I think I need to give it a try... So how should I set about 'moving' Windows 7 from my 256GB mSata drive to being a guest under VirtualBox on the same drive?


----------



## aragats (Jan 10, 2018)

You can use your disk directly, I did so before switched to bhyve 2 years ago:
https://www.virtualbox.org/manual/ch09.html#rawdisk


----------



## max21 (Jan 11, 2018)

balanga said:


> Given the positive feedback about how well Windows performs under VirtualBox, I think I need to give it a try... So how should I set about 'moving' Windows 7 from my 256GB mSata drive to being a guest under VirtualBox on the same drive?


I don’t think I understand the question correctly.  The only way to safely move a VM is to DD the entire partition.  For me the only hope would be if I had Windows-7 already in a Virtualbox somewhere on the same hard drive IN IT’S OWN PARTITION,  I would get another hard-drive … partition it off the way I need it to be (a brand new everything, might as well) but when you get to the one that is in the same LOCATION as the other one … I would partition it to the exact size or larger and dd the Windows-7 partitions to that location on the new hard drive.  Understand, this location would be the guest of whatever, wherever the new host will be.

It should take even if larger but I always keep a record of my exact sizes.  I would use Linux cfdisk cd to do the dd'ing only.  FreeBSD dd is better but I don't know how to command the CD.  Simple copy don't work for this!

For instances:

```
sda1 FreeBSD
sda2 Linux
sda3 Windows
sda5 D:/ my stuff
sda6 E:/ more stuff
sda7 F:/ virtualbox-FreeBSD-8.2
sda8 G:/ virtualbox-Linux
sda9 H:/ virtualbox-Windows-7
sda10 I/  . . .
```

Just to provide you a sound idea, I would dd *sda9* to *sdb9*.

Most important is to get a copy of the VirtualBox VMs/Windows-7 directory because it has the UUID for that partition/location.  Now your other disk has the same UUID, thanks ONLY due to dd.  That the key to the whole operation.

Virtual machines should be placed on there own partition, not packed up inside C:\ drive or a big ada0s1 hard-drive, but for FreeBSD or where ever it is you can match and dd the slices/partition and delete the rest, _latter_ 

If this is your case… I suggest you get on that from this day on and keep a record for your drive partition sizes ... everywhere …  VM are forever!  Just like jails and your valuable work, you put them on another partition and never where the OS live.

That why I know nothing much about anything else (playing with this all my computing life).

Good luck balanga
.


----------



## Selin (Mar 8, 2018)

max21 said:


> don't use *I/O APIC*


Looks like I have a problem with AIO...
Could you tell me - what shell I do to turn it off (my host is FreeBSD-11.1)?
Thank you


----------



## Selin (Mar 8, 2018)

I've described my problem here:
https://forums.freebsd.org/threads/...ses-under-freebsd-11-1-is-aio-a-reason.65019/
https://forums.virtualbox.org/viewtopic.php?f=2&t=87058&p=415932


----------

