joel_kleier

Getting data off ext4 with MacOS

data migration vagrant macos

Ever find yourself in a position where you need to get data on an ext4 partition of a usb drive onto a MacOS machine and you don’t want to install some maybe unstable drivers or muck up your system for a one time thing?

Well! I have a solution for you! Vagrant+VirtualBox+Ubuntu!

Simple Vagrantfile like so:

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/xenial64"
  config.vm.provider "virtualbox" do |vb|
    vb.gui = true
    vb.memory = 1024
    vb.customize ["modifyvm", :id, "--usb", "on"]
    vb.customize ["modifyvm", :id, "--usbxhci", "on"]
  end
end

Note the two vb.customize lines, those are the key. That and making sure your drive isn’t mounted in MacOS (just eject it from the option menu if it pops up).

The first enables the USB integration with VirtualBox, and the second enables the USB 3.0 driver (which I needed).

Once you do the vagrant up bit, and the machine is running, you’ll want to go to the USB menu, and select the drive to attach it to the VM. Then in the guest machine, lsusb to see if the device is seen, and fdisk -l to list out all the drives/partitions seen.

Once you know it’s attached and where it’s located, make a mountable directory, and mount it! IE:

$ sudo mkdir /media/drive
$ sudo mount -t ext4 /dev/sdc1 /media/drive

Now you should be able to copy stuff from /media/drive/* to /vagrant/!!!