[Nexus 5 General] buildsaurabh:
For all those complaining insufficient information to flash Preview 2 of Android M to your nexus 5, here is the comprehensive guide to flashing the preview.

Install ADB and Fastboot to your computer

Follow this link http://xdaforums.com/showthread.php?t=2588979&__utma=248941774.236267929.1403796127.1403796127.1403796127.1&__utmb=248941774.4.10.1403796127&__utmc=248941774&__utmx=-&__utmz=248941774.1403796127.1.1.utmcsr=google%7Cutmccn=%28organic%29%7Cutmcmd=organic%7Cutmctr=%28not%20provided%29&__utmv=-&__utmk=25906750

For MAC/linux

Follow this link

http://xdaforums.com/showthread.php?t=2564453

Remember to head into settings > developer options and enable USB Debugging first.

download Android M Developer Preview from Google website for your specific device http://developer.android.com/preview/download.html

unzip these files to a folder you can access Desktop preferably

If your Nexus is not bootloader unlocked you should do that first.

Open a Terminal in the adb folder and type the command below then hit enter.

adb reboot bootloader

In Fastboot type:

fastboot oem unlock

Then hit enter. Follow the on-screen instructions and choose to erase the device. Wait a minute or so for it to unlock. This removes everything on your device.

If your bootloader is already unlocked, reember to wipe data before flashing. Do this by using these commands in cmd or terminal

fastboot devices

fastboot erase userdata

fastboot erase cache

fastboot reboot

How to Flash the Image

Now open the folder containing the unzipped Android M System Image file you downloaded. Type cmd in the address bar. Type the following commands posted below and hit enter. On a Mac you can open Terminal in the folder by enabling terminal shortcuts in settings. This is key for Mac users. Head to System Preferences and select Keyboard > Shortcuts > Services. Find “New Terminal at Folder” in the settings and click the box. Now when you’re in Finder, just right-click a folder and you’re shown the open to open Terminal.

Once in terminal simply copy and paste the commands below to install the Android M beta to your Nexus 5, Nexus 6, Nexus 9, or even the Nexus Player.

flash-all.bat

This will flash all of the needed files. If you are on a Mac or other computer you will need to type;

sudo ./flash-all.sh

This will push all of the files and update your device to the just released Android M developer preview beta. The files will start pushing and installing and your Nexus device may reboot and you will see an Android figure and then a moving Android logo. The logo screen may stay for a long time. Don’t unplug the device. This may last 10 minutes or longer.

It’s worth noting that some users may experience a “missing system.img” error and the installation will be aborted. This is because the way you’re trying to flash the update. Instructions on how to get around this can be found right here. Essentially users will need to unzip the update.zip folder and move all the images to the original folder we mentioned above, then manually flash them one by one, vs the flash-all command mentioned above. Only do this if you run into issues.

If you run into bootloop, follow this guide http://xdaforums.com/google-nexus-5/help/bootloop-android-m-preview-2-t3154608/post61802470#post61802470

ENJOY!

Credits: Cory Gunther http://www.gottabemobile.com/2015/05/28/install-android-m-beta-download/