- Download the Raspbian Lite image from https://downloads.raspberrypi.org/raspbian_lite_latest (add .torrent to get a torrent)
- Unzip the download to extract the .img file
- Insert a FAT32-formatted SD card, and copy the image over:
diskutil listto identify the disk number, e.g./dev/disk2diskutil unmountDisk /dev/disk2sudo dd bs=1m if=image.img of=/dev/rdisk2
- Before unmounting, edit a couple of files to activate internet-over-USB. The image mounted for me at
/Volumes/boot.- In
config.txt, add this as the last line of the file:dtoverlay=dwc2 - In
cmdline.txt, add this as a parameter, just after therootwaitparameter:modules-load=dwc2,g_ether
- In
- Unmount the SD card (via Finder) and stick it in the Raspberry Pi.
- Attach a USB cable from your Mac to the RPi via the "USB" port on the RPi. This should power the RPi, and it will start to boot up.
- Give it a few minutes to boot. Open the Network preference panel (System Preferences -> Network) on your Mac, and you should see a new networking device called something like "RNDIS/Ethernet Gadget". For now it should be set to "Configure via DHCP" - it will have a link-local address.
- Once the RPi boots, you should be able to SSH to it with
ssh pi@raspberrypi.local. The password israspberry. - Over SSH, edit
/etc/network/interfacesto add a USB interface - add the following lines:
allow-hotplug usb0
iface usb0 inet static
address 192.168.2.2
netmask 255.255.255.0
gateway 192.168.2.1
- Next, set up
resolv.confto use192.168.2.1for name resolution - edit/etc/resolvconf.conf, and uncomment/edit thenameserversline to readnameservers=192.168.2.1. - Finally, on your Mac, configure the RNDIS/Ethernet Gadget interface with the following parameters:
- Configure IPV4:
Manually- IP Address:192.168.2.1- Subnet Mask:255.255.255.0- Router: (none) - Under Advanced -> DNS, add your favorite DNS server, like8.8.8.8or your home router. - Under the "Sharing" preferences pane, turn on Internet Sharing, and share your Mac's active network connection with the RNDIS/Ethernet Gadget interface.
- Reboot the RPi. After it comes back up, you should still be able to connect via
ssh pi@raspberrypi.local, and the device should now have the IP address192.168.2.2and access to the Internet!
It's easier to just set up "sharing options" -> "internet sharing", it will auto-update the DNS and use the
.localresolver, for exampleraspberrypi.localwill then resolve to192.168.2.2in my case.