Since the 1980's it has been possible to boot diskless Unix workstations with their root directories mounted using a network file system. Linux has maintained that capability and the Raspbian operating system which runs on the Raspberry Pi is a type of Linux. This thread describes how to set up a Pi Zero to network boot without an SD card and mount its root filesystem from a standard Microsoft Windows CIFS/SMB share using the USB Ethernet gadget. Similar instructions could be used to boot any Pi from a minimal SD card and then mount root from a Windows share over regular Ethernet.
These instructions were tested using the version of Raspbian Lite released October 2018 and Microsoft Windows Vista Home. It is expected that a similar technique will work with other versions of Windows.
Log into Windows and create a subdirectory called Pi.
C:\Users\XXXXXXX>mkdir Pi
Download the files linux-cdc-acm.inf and linux.inf from
https://www.kernel.org/doc/Documentation/usb/
and place them in the Pi directory. These two information files are needed for some versions of Windows to properly configure the Linux USB Ethernet and Serial gadgets.
In preparation for logging in to the Pi Zero later, download and install the putty secure shell program from
https://www.chiark.greenend.org.uk/~sgt ... atest.html
Internet connection sharing ICS defaults to different local addresses with different versions of Windows. Set the local IP number for ICS NAT to 192.168.5.1 by running regedit and clicking
->HKEY_LOCAL_MACHINE
->SYSTEM
->CurrentControlSet
->Services
->SharedAccess
->Parameters
Then change
ScopeAddress 192.168.5.1
ScopeAddressBackup 192.168.5.1
Next, download the Raspbian image from
https://www.raspberrypi.org/downloads/raspbian/
and write it to an SD card.
Now, configure the FAT-formatted boot partition of the SD card as follows. To the end of config.txt add
dtoverlay=dwc2
Further change cmdline.txt to
dwc_otg.lpm_enable=0 dwc_otg.speed=2 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether g_ether.host_addr=02:47:c0:a8:0d:02 g_ether.dev_addr=02:47:c0:a8:0d:01 quiet init=/usr/lib/raspi-config/init_resize.sh
Note that cmdline.txt is a single line. The changes load the Ethernet gadget, force USB2 mode and assign local MAC addresses to each side of the USB network. We also explicitly specify the root directory to be partition 2 of the SD card.
Finally, create an empty file in /boot called ssh to enable secure login, unmount the SD card from the Windows computer and place it in the Pi Zero.
Boot the Pi Zero by connecting it to the Windows PC using a USB cable. After some time the Windows PC should recognize new hardware. It may also pop up a display saying it needs an RNDIS driver. If this happens you can tell Windows to look in the Pi directory where you copied the linux-cdc-acm.inf and linux.inf files earlier. Since the appropriate drivers are already included with Windows, only the information files are needed for the Linux gadgets.
Once the Ethernet gadget is recognized there will be two network devices present on the Windows computer and you need to enable ICS so the DHCP client in Raspbian running on the Zero gets an IP number. Click on
->Control Panel
->Network and Internet
->Network and Sharing Center
->Manage network connections
then right click on the upstream network device and click
->Properties
->Sharing
Check the "Allow other network users to connect through this computer's Internet connection" check box and click
->OK
This will enable ICS which then starts a DHCP and DNS server with NAT for the USB Ethernet gadget. If everything goes well, you should now be able to connect to the Raspberry Pi and login using a command such as
C:\Users\XXXXXXX>putty raspberrypi.mshome.net
with username pi and password raspberry. Here mshome.net is the domain used by the DNS built into Windows ICS.
Before proceding it is worth highlighting that the method just described includes a few items that are different or missing from other posts about attaching a Pi Zero to a Windows computer. First, this post details how to download the missing linux-cdc-acm.inf and linux.inf files if Windows can't find an RNDIS driver. Second, this post uses ICS to setup NAT, DNS and DHCP on the Windows computer. Not only does this allow us to reach the Pi from the Windows computer as raspberrypi.mshome.net but it also allows the Zero to connect to the Internet. Third, the only additional software installed on Windows is the secure shell client putty. In particular, the Bonjour protocol is not needed nor will any NFS or iSCSI servers be required for the sequel.
The next post will discuss how to create a Windows share with an ext4 image file containing a Raspbian root filesystem. If you are following along and discover any errors or have questions please post them here.