VirtualBox: boot from USB image

Projects like OPNsense.org provide you with an .img file that you would dd to a USB device to boot from. This is not obvious how to use from VirtualBox. You need to convert that into a VMDK file. Basically, the command I used was:

vboxmanage convertfromraw OPNsense-19.7-OpenSSL-serial-amd64.img /tank/VMs/4544-opnsense-19-freebsd/opensense-19.7-usb.vmdk –format vmdk

Then attach that VMDK file to your virtual SATA controller and when you boot really quick! Hit F12 and choose option 2. That’s your USB device.

 

Notes on Updating Centos7 to 4.3.3

Upgrades! Sometimes they are a lot of homework.

Enabled Centos-Plus repos and elrepo for recent kernels. I figured out I want to install kernel-ml, kernel-ml-headers, kernel-ml-devel. That last one escaped me but is necessary because you need it when you do a dkms install.

So after updating that stuff, I was able to dkms install spl/0.6.5.3, dkms install zfs/0.6.5.3. I also made sure to modprobe spl zfs. Linked /usr/lib/systemd/system/zfs.target into /etc/systemd/system/sysinit.target.wants. Reboot. Make sure zfs pool returns.

To get vboxdrv all working I needed to make sure I installed the vboxdriver. That is /usr/sbin/rcvboxdrv. Easy to forget, that’s rather new. Then (as root) do a vboxmanage extpack install ~/Downloads/VirtualBox-extpack-5.0.6.extpack and that will keep your guest vms from blocking on missing USB-UHCI drivers.

Then go back and read my prev post on updating grub. I kept booting into kernel 3.10.x and wondering why grub2-install /dev/sda wasn’t doing it’s job. Ubuntu did the right amount of work with the update-grub2 script, I’ll say.

Converting Virtualbox disk to ZFS volumes

I am trying to create zvol backed virtualbox guests using ZFS on Linux. Hopefully this is not too ambitious.

  1. Find size of original .VDI disk image: vboxmanage showhdinfo Fedora19.vdi
  2. Pass that file size into zfs create: zfs create -V40960M tank/VMs/Fedora19
  3. Convert .vdi file to raw, best if you can do this from one hd to another. In my case I’m reading from a zvol and writing to an ssd: vboxmanage clonehd Fedora19.vdi ~/tmp/Fedora19.raw –format RAW
  4. Load that back into a raw parition image: dd if=~/tmp/Fedora19.raw of=/dev/zvol/tank/VMs/9101-f19 bs=1280k
  5. now we can check partitions: vboxmanage internalcommands listpartitions –rawdisk /dev/zvol/tank/VMs/9101-f19
  6. Then we can create a vmdk file for the raw parition: vboxmanage internalcommands createrawvmdk -filename ~/VirtualBox\ VMs/9101-f19/9101-f19-B.vmdk -rawdisk /dev/zvol/tank/VMs/9101-f19 -partitions 1,2,3
  7. create an idea controller: vboxmanage storagectl …vboxmanage storagectl 9101-f19-B –name IDE –add ide
  8. add blank version of hard drive: vboxmanage storageattach 9101-f19-B –storagectl IDE –port 0 –device 0 –mtype normal –type hdd –medium none
  9. add hard drive: vboxmanage storageattach 9101-f19-B –storagectl IDE –port 0 –device 0 –mtype normal –type hdd –medium “/home/jreynolds/VirtualBox VMs/9101-f19-B/9101-f19-B.vmdk”
  10. …attach the CD rom and then repair the system…somehow my disk image stopped being bootable. :-(