This is part 3 of the 4-part series on VirtualBox. This post shows you how to access, from your guest OS, a flash drive mounted on the Debian host. Parts 1, 2 and 4 demonstrate how to build a FreeBSD virtual machine using VirtualBox on a Debian host, perform post-installation tasks, and share folders.
Prerequisites
The VirtualBox extension pack must be installed on the VirtualBox host. See part 2 for instructions.
Configuring USB
Follow the steps below to configure VirtualBox USB.
-
Add user to
vboxusers
group.
VirtualBox access to the host's USB drives is only granted to users of thevboxusers
group. Asroot
on the host, run the following command to add each VirtualBox user (e.g.,peter
) to the group.# usermod -aG vboxusers peter
-
Power off VM.
VirtualBox defaults to using USB Controller 1.1 (OHCI). Modern hardware uses USB Controller 2.0(EHCI) and USB Controller 3.0(xHCI). Before you can change the USB controller protocol, the virtual machine must be powered off. -
Open
VirtualBox Manager
, clickSettings
, and selectUSB
. -
Specify USB Controller.
Select eitherUSB 2.0 (EHCI) Controller
orUSB 3.0 (xHCI) Controller
according to your actual hardware.
Note that you can addUSB Device Filters
to define the types of USB drives which will be automatically made visible to the guest OS. Be forewarned that the USB drive, once made visible to the guest OS, will no longer be available to the host. More on the use of device filters in the next section.
Accessing USB drive
Below is the step-by-step procedure to mount and access a flash drive.
-
Insert the flash drive into your host machine's USB port.
-
Unmount the flash drive (if it is auto-mounted on your host).
Making it available to the guest will automatically and instantly unmount it from the host. To avoid any data loss due to pending writes to the drive, it is a good practice to explicitly unmount the drive prior to handing control to the guest. -
Power on the FreeBSD guest.
-
Assign USB drive to guest OS.
Open the virtual system console, and right click theUSB drive
icon.
Click to select your USB drive.
Note that this is a 1-time assignment only. Please see instructions at the end of the section on how to automatically assign this particular USB drive for all subsequent sessions. -
Login to FreeBSD, and mount the drive.
You can mount a MS-DOS based flash drive by running the following commands as root. Replace/dev/da0s1
with the proper device identifier for your USB drive. (You can find out the exact device ID by first runningdmesg
to identify the device name, e.g.da0
, andfdisk
to reveal the disk partition structure, e.g.,s1
.)# mkdir -p /media/usb # mount -t msdosfs /dev/da0s1 /media/usb
To unmount the drive,# umount /media/usb
To always automatically assign a particular USB drive to the guest OS, open the
VirtualBox Manager
, click Settings
, and then USB
.
Finally, click
Add USB device filter (with the + sign)
icon, and select the USB drive that is currently inserted in the host.
No comments:
Post a Comment