Digging up this topic, as I recently ran Batocera as a VM in VirtualBox.
This is mostly for development purposes, as nadenislamarre said, I would not recommend to use Batocera in a VM environment for actual retrogaming.
First, download the PC x86_64 version of Batocera… you'll have a gzipped file named for example batocera-5.22-x86_64-20190510.img.gz
Unzip the image with:
$ gzip -d batocera-5.22-x86_64-20190510.img.gz
You end up with a 3.0GB batocera-5.22--5.22-x86_64-20190510.img
(compared to the gzipped image that is typically just shy of 1.0GB )
Convert it into a VDI image with:
$ VBoxManage convertdd batocera-5.22-x86_64-20190510.img bato-5.22beta2.vdi
Converting from raw image file="batocera-5.22-x86_64-20190510.img" to file="bato-5.22beta2.vdi"...
Creating dynamic image with size 3226246656 bytes (3077MB)…
The VDI image generated is bato-5.22beta2.vdi
in that case
You can now gzip back your .img $ gzip batocera-5.22-x86_64-20190510.img
(to save about 2GB on your hard drive).
In VirtualBox, you can create a new VM (Menu Machine->New), select type "Linux" and Version "Linux 2.6 / 3.x / 4.x (64-bit)" and press "Continue". Then select the amount of RAM (1GB should be OK for testing/dev purposes), and finally "Use an existing virtual hard disk file" that you point to your freshly created VDI file (bato-5.22beta2.vdi
).
That's it, you can now run this new VM with Batocera on it.