I have a Windows 10 VM running headless in VirtualBox on FreeBSD 11.1. It runs without issues. I'd like to enable the VM to access physical CDs/DVDs so that I can insert real discs and open them in the VM.
When I do
VBoxManage storageattach MyVM --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium host:/dev/cd0
the VM no longer starts.
$ VBoxManage startvm MyVM
--type headless Waiting for VM "MyVM" to power on...
VBoxManage: error: The VM session was aborted
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component SessionMachine, interface ISession
I ensured that /etc/devfs.conf
contains
perm cd* 0660
perm xpt0 0660
perm pass* 0660
and my user is in the operator group. Furthermore, the VirtualBox log contains no obvious errors or warnings. The VM just aborts without any useful diagnostic information. Removing the CD device restores the VM to functionality.
Any ideas?
Update: it looks like VBoxHeadless
is shutting down due to a segmentation fault. The cause is still unclear to me. From /var/log/messages
:
May 5 12:05:31 the_computer kernel: vboxdrv: XXXXXXXXXXXXXXXX VMMR0.r0
May 5 12:05:31 the_computer kernel: vboxdrv: XXXXXXXXXXXXXXXX VBoxDDR0.r0
May 5 12:05:31 the_computer kernel: pid 61621 (VBoxHeadless), uid 1001: exited on signal 11
Update 2: The point where VBoxHeadless
aborts is where the VM initializes ATA devices. Without the CD device, I see the following in the log:
...
00:00:01.280311 VD#0: Cancelling all active requests
00:00:01.280468 PIIX3 ATA: LUN#0: no unit
...
but when I add it back in, I get
...
00:00:00.273730 VD#0: Cancelling all active requests
[end of file]
I think that your error is that you should define the storage as
IDE Controller
rather than SATA Controller
.
The command should rather look like:
VBoxManage storageattach MyVM --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium host:/dev/cd0
In case of a problem, try this :
$ VBoxManage storagectl MyVM --name "IDE Controller" --remove
$ VBoxManage storagectl MyVM --name "IDE Controller" --add ide
$ VBoxManage storageattach MyVM --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium host:/dev/cd0
According to the FreeBSD Handbook §21.6.3: VirtualBox™ Host DVD/CD Access…
HAL needs to run for VirtualBox™ DVD/CD functions to work
Thus you need to…
enable it in
/etc/rc.conf
and start it if it is not already running
This is done by adding hald_enable="YES"
to your/etc/rc.conf
file and then executing
# service hald start
This is in addition to the requirement for the user needing access to /dev/xpt0
, /dev/cdN
, and /dev/passN
, which according to the same section of the handbook is "usually achieved by making the user a member of operator
", and correcting the device's permissions "by adding these lines to /etc/devfs.conf
"
perm cd* 0660
perm xpt0 0660
perm pass* 0660
and (so that the system will make use of these changes) restarting the devfs
service
# service devfs restart
If after all of this your VM still won't start while connected to your host CD/DVD drive, consider following this advice (taken from the same page as above):
If needed, create an empty IDE CD/DVD device first. Then choose the Host Drive from the popup menu for the virtual CD/DVD drive selection.
If you can't use the mentioned 'popup menu', I think (from reading the documentation) that the following should be the command-line equivalent:
With the VM powered off: Attach an empty, virtual IDE CD/DVD device
VBoxManage storageattach MyVM --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium emptydrive
Boot up your VM:
VBoxManage startvm MyVM
While the VM is still running: Switch to using the host drive
VBoxManage storageattach MyVM --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium host:/dev/cd0
It appears that there may be a bug in VirtualBox that's preventing this from working on your system. I suggest that the issue be reported to the VirtualBox developers on the project's Bugtracker.
Until this issue is fixed, I recommend working around the issue by making an ISO file from your physical disc(s) for use with VirtualBox. (Some people may prefer this anyway.)
Read the block and volume size of the disc so that you can make a perfect ISO
(this step isn't really necessary, but an ISO made without it will have a different checksum than the original ISO file used to make the CD because of "A pair of zero data blocks at the end", plus the volume size can be useful later)
isoinfo -d -i /dev/cd0 | grep -i -E 'block size|volume size'
You'll get output similar to this:
Logical block size is: 2048
Volume size is: 327867
Use dd
to copy the contents of the disc
dd if=/dev/cd0 of=<cd name>.iso bs=<block size from step 1> count=<volume size from step 1>
dd if=/dev/cd0 of=MyVirtualCD.iso bs=2048 count=327867
bs
and count
, like so:dd if=/dev/cd0 of=MyVirtualCD.iso
dd
it may support showing it's status by adding status=progress
to the above command lineIf you're using an older version of dd
, or want a nicer looking progress indicator, you can install pv
via "The Ports Collection" or "FreshPorts", and pipe the dd
output through pv
to see statistics, and since we know the volume size from step 1, an accurate progress bar:
dd if=/dev/cd0 | pv -s <volume size from step 1> | dd of=<cd name>.iso
In our example, this would be as follows:
dd if=/dev/cd0 of=MyVirtualCD.iso | pv -s 327867 | dd of=MyVirtualCD.iso
Now you can attach the ISO to the VM and boot it:
VBoxManage storageattach MyVM --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium /path/to/MyVirtualCD.iso
VBoxManage startvm MyVM
emptydrive
medium mentioned earlier, the empty virtual CD drive will be available for you to use the same storageattach
command while the VM is running to swap in one of your virtual CDs whenever you like.Sources:
FreeBSD Handbook, VBoxManage docs, Thomas-Krenn Wiki, Ask Ubuntu answer by "phoibos"
User contributions licensed under CC BY-SA 3.0