VirtualBox USB Flash for ZFS

To set up your USB Flash drives as pass-through in VirtualBox, here is what you can do.

Next, plug in your flash drive and record its device. For me, it was /dev/sde. Look in /var/log/syslog, or dmesg output, for the “[sde] Attached SCSI removable disk” line. My device looked like this:

ls -l /dev/sde
brw-rw---- 1 root disk 8, 64 Nov 24 15:22 /dev/sde

If you don’t run virtualbox as root (and you should not), then you’ll need to use the group to access /dev/sde. Above, you can see it is “disk”.
Now, make sure the user that is running virtualbox is in the “disk” group (e.g. ‘tim’ user):

sudo usermod -a G disk tim

After this, you may or may not have to reboot. Run “groups” as your user. Make sure you see “disk” listed. If not, reboot (or maybe just logout and login).

Then, for each USB Flash drive, run this VBoxManage command:
(Note: this command just creates a *.vmdk file that “links” to a raw device. It does not touch or alter the device, but it does make sure your current user has permissions to the device):

VBoxManage internalcommands createrawvmdk -filename usbflash1.vmdk -rawdisk /dev/sde1
chown tim:tim usbflash1.vmdk

Then, in the virtualbox GUI, under settings, choose Storage, then “add hard disk”, then “Choose existing disk”, then select the usbflash1.vmdk file created above.

See the ZFS Fkash Drives on how to create your ZFS volume from the USB Flash drive(s).

Next up: plugging the USB Flash drives into a different ZFS instance.
(In case it is not clear, the trade-off here is between:
1) Two separate USB flash drives, which can be used by just about any computer, but must be manually kept in sync, and manually compared looking for differences, versus
2) Two flash drives as a single ZFS mirror volume, where ZFS makes sure the contents are the same and scrubs them to make sure they stay that way. However, you need a ZFS system to mount and use them.)

The contents of usbflash1.vmdk:

# Disk DescriptorFile

# Extent description
RW 15130017 FLAT "/dev/sde1" 0

# The disk Data Base 

ddb.virtualHWVersion = "4"
This entry was posted in ZFS. Bookmark the permalink.